为什么 /bin/ls 链接到 libpthread?

为什么 /bin/ls 链接到 libpthread?

真奇怪,ls 是多线程的吗?lslibpthread 可能需要做什么?

ldd /bin/ls
    linux-vdso.so.1 (0x00007ffff7fce000)
    libselinux.so.1 => /lib/x86_64-linux-gnu/libselinux.so.1 (0x00007ffff7f57000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007ffff7d65000)
    libpcre2-8.so.0 => /usr/lib/x86_64-linux-gnu/libpcre2-8.so.0 (0x00007ffff7cd2000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007ffff7ccc000)
    /lib64/ld-linux-x86-64.so.2 (0x00007ffff7fcf000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007ffff7ca9000)

答案1

ls本身并不依赖于libpthread。使用lddtreepax-utilssudo apt install pax-utils)查看依赖关系树:

# lddtree /bin/ls
ls => /bin/ls (interpreter => /lib/ld-linux-armhf.so.3)
    libselinux.so.1 => /lib/arm-linux-gnueabihf/libselinux.so.1
        libpcre.so.3 => /lib/arm-linux-gnueabihf/libpcre.so.3
            libpthread.so.0 => /lib/arm-linux-gnueabihf/libpthread.so.0
        libdl.so.2 => /lib/arm-linux-gnueabihf/libdl.so.2
    libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6
    ld-linux-armhf.so.3 => /lib/ld-linux-armhf.so.3

ldd显示文件链接到的所有共享库,包括间接依赖项。

相关内容