Skip to content

Commit 8385bba

Browse files
committed
new article brk
1 parent 70645ef commit 8385bba

File tree

3 files changed

+68
-3
lines changed

3 files changed

+68
-3
lines changed

2022/03/list_package_file.md

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,29 @@
11
# [package file list](/2022/03/list_package_file.md)
22

3-
## pacman
3+
## package file list
44

5+
```
56
pacman -Ql bcc
7+
yum/dnf repoquery -l bcc
8+
```
69

7-
## yum/dnf
10+
## which package contains file
811

9-
yum/dnf repoquery -l bcc
12+
`pacman -F` or `dnf provides`
13+
14+
```
15+
[w@ww temp]$ pacman -F libssl.so
16+
core/openssl 1.1.1.m-1 [installed]
17+
usr/lib/libssl.so
18+
core/openssl-1.0 1.0.2.u-1
19+
usr/lib/openssl-1.0/libssl.so
20+
community/cuda-tools 11.6.0-1
21+
opt/cuda/nsight_compute/host/linux-desktop-glibc_2_11_3-x64/libssl.so
22+
opt/cuda/nsight_systems/host-linux-x64/libssl.so
23+
community/libressl 3.4.2-1
24+
usr/lib/libressl/libssl.so
25+
multilib/lib32-openssl 1:1.1.1.m-1 [installed]
26+
usr/lib32/libssl.so
27+
multilib/lib32-openssl-1.0 1.0.2.u-1
28+
usr/lib32/openssl-1.0/libssl.so
29+
```

2022/04/brk.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# [brk](/2022/04/brk.md)
2+
3+
用 strace -f 看进程系统调用(-f 参数表示记录子进程调用)时经常能看到 brk(NULL) 这个系统调用,因好奇而写下本文
4+
5+
## brk 与进程地址空间
6+
7+
brk/sbrk 看上去就是设置进程地址空间的 BSS(放常量字符串的) 区跟堆之间的分界线指针
8+
9+
<https://www.cnblogs.com/arnoldlu/p/10272466.html>
10+
11+
这篇文章说 top 里面 VIRT 列是虚拟内存占用而 RES 列才是实际占用内存
12+
13+
## ldd 动态库
14+
15+
```
16+
ldd a.out
17+
linux-vdso.so.1 (0x00007ffcd9db5000)
18+
libc.so.6 => /usr/lib/libc.so.6 (0x00007f6e57fc3000)
19+
/lib64/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2 (0x00007f6e58202000)
20+
```
21+
22+
1. vdso 是为了解决 glibc 跟内核版本兼容问题
23+
2. libc.so 我很熟悉了
24+
3. ld-linux-x86-64.so 是所有带动态库可执行文件的 linker + 解释器?
25+
26+
也就 ./a.out 的执行会变成 /lib64/ld-linux-x86-64.so.2 ./a.out 然后再 execve
27+
28+
rust 应用会额外多一个 libgcc_s.so 的动态库引入 gcc runtime 的一些符号和 main/_start 函数吧
29+
30+
## clone & fork
31+
32+
国内的文章喜欢说 clone 是轻量级的 fork
33+
34+
不管是 clone 还是 fork 复制当前进程都是 Copy On Write 开销较小
35+
36+
Rust 的 spawn 用的是 clone (不清楚什么时候会用 posix_spawn)
37+
38+
根据 man 文档说也就 clone 提供了更细粒度的子进程控制,例如父子进程共享虚拟内存
39+
40+
## strace 必经流程
41+
42+
1. execve
43+
2. brk
44+
3. mmap (进程地址空间动态库)

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
- [归档 - 吴翱翔的博客](/)
22
- **2022-04**
3+
- [brk](/2022/04/brk.md)
34
- [用时序图理解接口业务](/2022/04/uml_sequence_diagram.md)
45
- **2022-03**
56
- [docker scratch](/2022/03/docker_scratch.md)

0 commit comments

Comments
 (0)