I use `lddtree` on Arch Linux and I noticed the following issue: `ldd` and `lddtree` results differ when modifying the libraries rpath. So I have a project `Main` which depends on LibA which depends on LibB. Then I screw the rpath: patchelf *.so --set-rpath 'somethingwrong/' Then notice the difference between the 2 outputs: $ ldd Main !10084 linux-vdso.so.1 (0x00007ffcfabf7000) libLibA.so => /home/gogoprog/code/lddtreebug/build/libLibA.so (0x00007f45217fc000) libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007f45215bc000) libm.so.6 => /usr/lib/libm.so.6 (0x00007f4521478000) libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007f452145d000) libc.so.6 => /usr/lib/libc.so.6 (0x00007f4521291000) /lib64/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2 (0x00007f4521808000) libLibB.so => not found $ lddtree Main !10085 Main (interpreter => /lib64/ld-linux-x86-64.so.2) libLibA.so => /home/gogoprog/code/lddtreebug/build/libLibA.so libLibB.so => /home/gogoprog/code/lddtreebug/build/libLibB.so libstdc++.so.6 => /usr/lib/libstdc++.so.6 libm.so.6 => /usr/lib/libm.so.6 libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 libc.so.6 => /usr/lib/libc.so.6 The depending library `libB` is found with `lddtree` but should not. It seems that `rpath` info is not used with `lddtree`. These outputs are from Arch Linux. I did not test on Gentoo yet. I made a repo here to reproduce: https://github.com/gogoprog/lddtree-issue Might be related to https://bugs.gentoo.org/655478 .
your custom patching isn't the issue. cmake is applying -rpath to the main program and lddtree is using that to find not only its own libs, but dependencies of those libs. to repro: gcc -x c - -fPIC -shared -o libB.so <<<'' gcc -x c - -fPIC -shared -o libA.so -L. -lB <<<'' gcc -x c - -o main -L. -lA -Wl,-rpath,$PWD <<<'int main(){}' ldd ./main lddtree ./main will need to change lddtree to only apply rpath/runpath settings to the immediate linkage lookup rather than all children