动态库实际上在内存中的哪个位置?

时间:2013-11-20 21:06:46

标签: c linux memory dynamic-linking dynamic-library

在linux平台上,

有人能告诉我内存中的动态库在哪里吗?

我了解到动态库是根据GOT进行流程的mmap 这个过程,

是真的吗?

谢谢!

1 个答案:

答案 0 :(得分:1)

您可以通过查看/ proc / pid / maps查看在Linux进程中映射的内容 - 您需要知道的是进程ID。例如:

$ cat /proc/self/maps
00400000-0040b000 r-xp 00000000 08:01 71827604                           /bin/cat
0060a000-0060b000 r--p 0000a000 08:01 71827604                           /bin/cat
0060b000-0060c000 rw-p 0000b000 08:01 71827604                           /bin/cat
00690000-006b1000 rw-p 00000000 00:00 0                                  [heap]
7f07fbaf7000-7f07fbdc0000 r--p 00000000 08:01 18094104                   /usr/lib/locale/locale-archive
7f07fbdc0000-7f07fbf75000 r-xp 00000000 08:01 14552996                   /lib/x86_64-linux-gnu/libc-2.15.so
7f07fbf75000-7f07fc175000 ---p 001b5000 08:01 14552996                   /lib/x86_64-linux-gnu/libc-2.15.so
7f07fc175000-7f07fc179000 r--p 001b5000 08:01 14552996                   /lib/x86_64-linux-gnu/libc-2.15.so
7f07fc179000-7f07fc17b000 rw-p 001b9000 08:01 14552996                   /lib/x86_64-linux-gnu/libc-2.15.so
7f07fc17b000-7f07fc180000 rw-p 00000000 00:00 0 
7f07fc180000-7f07fc1a2000 r-xp 00000000 08:01 14553008                   /lib/x86_64-linux-gnu/ld-2.15.so
7f07fc37e000-7f07fc381000 rw-p 00000000 00:00 0 
7f07fc3a0000-7f07fc3a2000 rw-p 00000000 00:00 0 
7f07fc3a2000-7f07fc3a3000 r--p 00022000 08:01 14553008                   /lib/x86_64-linux-gnu/ld-2.15.so
7f07fc3a3000-7f07fc3a5000 rw-p 00023000 08:01 14553008                   /lib/x86_64-linux-gnu/ld-2.15.so
7fff90e28000-7fff90e49000 rw-p 00000000 00:00 0                          [stack]
7fff90f1f000-7fff90f20000 r-xp 00000000 00:00 0                          [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]

显示已映射的所有内容以运行cat程序。