haampie / libtree

ldd as a tree
MIT License
2.63k stars 60 forks source link

Missing library in example? #67

Closed vsoch closed 2 years ago

vsoch commented 2 years ago

Why doesn't the output for vim show libm.so.6?

If I inspect with readelf it's definitely in needed. Do you do an additional filtering?

$ readelf -d /usr/bin/vim

Dynamic section at offset 0x2a8360 contains 36 entries:
  Tag        Type                         Name/Value
 0x0000000000000001 (NEEDED)             Shared library: [libm.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libtinfo.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libselinux.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libcanberra.so.0]
 0x0000000000000001 (NEEDED)             Shared library: [libacl.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libgpm.so.2]
 0x0000000000000001 (NEEDED)             Shared library: [libdl.so.2]
 0x0000000000000001 (NEEDED)             Shared library: [libpython3.8.so.1.0]
 0x0000000000000001 (NEEDED)             Shared library: [libpthread.so.0]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]

I wrote my own tool, and I see it in the tree, and when I look at symbols it finds there, I find:

$ elfcall gen /usr/bin/vim
==/lib/i386-linux-gnu/libm.so.6==
acos                asin                atan                atan2
cos                 cosh                cosh                floor
fmod                log                 fmod                pow
sin                 sinh                pow                 tan

thanks!

haampie commented 2 years ago

It's documented in man libtree / libtree --help / the readme on github:

* For brevity, the following libraries are not shown by default:
  libc.so, libpthread.so, libm.so, libgcc_s.so, libstdc++.so, 
  ld-linux-x86-64.so, libdl.so, libc.musl-x86_64.so, ld-linux.so, ld64.so, 
  ld-linux-aarch64.so.

Also note that glibc is moving towards merging lib{c,pthread,m,dl} into the dynamic linker ld-linux.so, which is what musl libc has been doing for a while. That means those libraries will not be explicitly loaded, they are already loaded when the kernel invokes the runtime linker. So, in that sense I don't think it hurts to hide libc libraries by default.

You could make an argument that libstdc++.so and libgcc_s.so shouldn't be hidden by default, but I find it a bit too verbose.

haampie commented 2 years ago

Closing for now, feel free to reopen