/ proc / <pid> / map为busybox显示的共享库比ldd更多

时间:2019-01-29 07:56:22

标签: linux shared-libraries busybox

为什么/proc/<pid>/mapsldd程序显示更多的共享库?

这是一个例子:

# ------------ Embedded Linux side ------------
# ps
  .....
  28 root     [jffs2_gcd_mtd2]
  132 root     -/bin/sh                  ---> the target to show
  155 root     [kworker/0:2]
#   # Note: -/bin/sh is actually /bin/busybox

# cat /proc/132/maps
00400000-004bc000 r-xp 00000000 1f:02 34         /bin/busybox
004cc000-004cd000 rw-p 000bc000 1f:02 34         /bin/busybox
004cd000-004ee000 rw-p 00000000 00:00 0          [heap]
775bb000-775cb000 rw-p 00000000 00:00 0 
775cb000-775d6000 r-xp 00000000 1f:02 397        /lib/libnss_files-2.22.so
775d6000-775e5000 ---p 0000b000 1f:02 397        /lib/libnss_files-2.22.so
775e5000-775e6000 r--p 0000a000 1f:02 397        /lib/libnss_files-2.22.so
775e6000-775e7000 rw-p 0000b000 1f:02 397        /lib/libnss_files-2.22.so
775e7000-775ed000 rw-p 00000000 00:00 0 
775ed000-7775a000 r-xp 00000000 1f:02 382        /lib/libc-2.22.so
7775a000-7776a000 ---p 0016d000 1f:02 382        /lib/libc-2.22.so
7776a000-7776d000 r--p 0016d000 1f:02 382        /lib/libc-2.22.so
7776d000-77770000 rw-p 00170000 1f:02 382        /lib/libc-2.22.so
77770000-77772000 rw-p 00000000 00:00 0 
77772000-77795000 r-xp 00000000 1f:02 374        /lib/ld-2.22.so
777a1000-777a2000 rw-p 00000000 00:00 0 
777a3000-777a4000 rw-p 00000000 00:00 0 
777a4000-777a5000 r--p 00022000 1f:02 374        /lib/ld-2.22.so
777a5000-777a6000 rw-p 00023000 1f:02 374        /lib/ld-2.22.so
7fb42000-7fb63000 rwxp 00000000 00:00 0          [stack]
7fff7000-7fff8000 r-xp 00000000 00:00 0          [vdso]
# cksum /bin/busybox
698740119 773496 /bin/busybox

#---------- Then on the PC side ----------------
$ cksum ./busybox
698740119 773496 bin/busybox
$ /usr/local/bin/mips-linux-gnu-ldd  bin/busybox
checking sub-depends for 'not found'
libc.so.6 => not found (0x00000000)
/lib/ld.so.1 => /lib/ld.so.1 (0x00000000)

cksum用于检查文件是否相同。 从PC端ldd跨工具,它显示busybox仅取决于libcld。 但是,在实际的运行时环境中,/proc/132/maps显示了另一个共享库/lib/libnss_files-2.22.so

要确认我们是否具有间接依赖性:

$ /usr/local/bin/mips-linux-gnu-ldd lib/libc.so.6 
/lib/ld.so.1 => /lib/ld.so.1 (0x00000000)

$ /usr/local/bin/mips-linux-gnu-ldd lib/ld.so.1
not a dynamic executable

不。 ldd表明libc依赖于ld,它已经是busybox的依赖项之一。

2 个答案:

答案 0 :(得分:1)

一个进程可以fetch('https://agwebdesign.net/files/JS1simplequizapp/questions.json').then(response => { return response.json(); }).then(data => { // Work with JSON data here console.log(data); }).catch(err => { // Do something for an error here }); 共享对象并将其加载到其地址空间中,而无需将其链接到该对象。这意味着共享对象无需出现在dlopen(3)输出中即可显示在程序的运行实例中。

我并不是说是这种情况,但是您可以开发共享对象,其唯一目的是向具有 open 设计的程序添加(未知)功能以按需合并库。

通常,这些程序不会出现在ldd(1)输出中。

答案 1 :(得分:0)

libnss_files是libc的组件。它是按需加载的,用于在静态文件(如/etc/passwd/etc/hosts)中执行名称查找。 (还有libnss_dns用于DNS查找。)

有关更多信息,请参见NSS (Name Service Switch)的libc文档。

相关问题