Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 831912 - app-misc/pax-utils: lddtree applies main ELF's rpath to all children lookups
Summary: app-misc/pax-utils: lddtree applies main ELF's rpath to all children lookups
Status: CONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Toolchain Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-01-23 19:23 UTC by gogoprog
Modified: 2022-01-30 10:35 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description gogoprog 2022-01-23 19:23:51 UTC
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 .
Comment 1 SpanKY gentoo-dev 2022-01-30 10:35:58 UTC
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