Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 589434

Summary: app-misc/pax-utils: scanelf: --needed should walk DT_RPATH/DT_RUNPATH paths
Product: Gentoo Linux Reporter: James Le Cuirot <chewi>
Component: Current packagesAssignee: Gentoo Toolchain Maintainers <toolchain>
Status: CONFIRMED ---    
Severity: enhancement CC: arfrever.fta
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---

Description James Le Cuirot gentoo-dev 2016-07-23 09:03:29 UTC
I can't work out what scanelf is supposed to return for NEEDED entries that are missing or rely on the RPATH when --use-ldpath or --ldcache are given.

With --use-ldpath, such entries are returned without a path, such as libfoo.so. With --ldcache, such entries are blank. Neither is very helpful if you can't tell the difference between missing entries and entries relying on the RPATH. Perhaps we need a --use-rpath option?

Even if the RPATH were resolved, which behaviour is more correct? Returning missing entries as blank doesn't tell you which ones are actually missing. On the other hand, returning them without a path would still conflict with entries found in the same directory via the RPATH unless you always prepend the latter with "./".
Comment 1 SpanKY gentoo-dev 2016-07-23 19:09:37 UTC
please provide concrete examples of what you're looking at.  the man page is pretty clear as to what both flags do when paired with -n.  if you're getting blank paths, it's either an invalid load, or you have a pathological case that isn't handled currently.
Comment 2 James Le Cuirot gentoo-dev 2016-07-23 19:52:08 UTC
I've written a script to scan the Steam library directory for missing dependencies. Now that it's almost finished, I realise I may not need this as much as I thought I did but there's still room for improvement. Here's some output to demonstrate the issue.

$ scanelf -r Alien\ Isolation/bin/AlienIsolation
 TYPE   RPATH FILE 
ET_EXEC $ORIGIN/../lib Alien Isolation/bin/AlienIsolation

$ scanelf -n Alien\ Isolation/bin/AlienIsolation
 TYPE   NEEDED FILE 
ET_EXEC libpcre.so.3,libjpeg.so.8,libCoreFoundation.so.476,libcurl.so.4,libvorbis.so.0,libpthread.so.0,librt.so.1,libdl.so.2,libSDL2-2.0.so.0,libSDL2_image-2.0.so.0,libz.so.1,libfreetype.so.6,libfontconfig.so.1,libstdc++.so.6,libm.so.6,libgcc_s.so.1,libc.so.6,ld-linux-x86-64.so.2 Alien Isolation/bin/AlienIsolation

$ scanelf -n --use-ldpath Alien\ Isolation/bin/AlienIsolation
 TYPE   NEEDED FILE 
ET_EXEC /usr/lib64/libpcre.so.3,libjpeg.so.8,libCoreFoundation.so.476,/usr/lib64/libcurl.so.4,/usr/lib64/libvorbis.so.0,/lib64/libpthread.so.0,/lib64/librt.so.1,/lib64/libdl.so.2,/usr/lib64/libSDL2-2.0.so.0,/usr/lib64/libSDL2_image-2.0.so.0,/lib64/libz.so.1,/usr/lib64/libfreetype.so.6,/usr/lib64/libfontconfig.so.1,/usr/lib/gcc/x86_64-pc-linux-gnu/5.3.0/32/libstdc++.so.6,/lib64/libm.so.6,/usr/lib/gcc/x86_64-pc-linux-gnu/5.3.0/32/libgcc_s.so.1,/lib64/libc.so.6,/lib64/ld-linux-x86-64.so.2 Alien Isolation/bin/AlienIsolation

$ scanelf -n --ldcache Alien\ Isolation/bin/AlienIsolation
 TYPE   NEEDED FILE 
ET_EXEC ,,,/usr/lib64/libcurl.so.4,/usr/lib64/libvorbis.so.0,/lib64/libpthread.so.0,/lib64/librt.so.1,/lib64/libdl.so.2,/usr/lib64/libSDL2-2.0.so.0,/usr/lib64/libSDL2_image-2.0.so.0,/lib64/libz.so.1,/usr/lib64/libfreetype.so.6,/usr/lib64/libfontconfig.so.1,/usr/lib/gcc/x86_64-pc-linux-gnu/5.3.0/libstdc++.so.6,/lib64/libm.so.6,/usr/lib/gcc/x86_64-pc-linux-gnu/5.3.0/libgcc_s.so.1,/lib64/libc.so.6,/lib64/ld-linux-x86-64.so.2 Alien Isolation/bin/AlienIsolation

$ ldd Alien\ Isolation/bin/AlienIsolation 
Alien Isolation/bin/AlienIsolation: /usr/lib64/libldap_r-2.4.so.2: no version information available (required by /mnt/steam/SteamLibrary/SteamApps/common/Alien Isolation/bin/../lib/x86_64/libcurl.so.4)
Alien Isolation/bin/AlienIsolation: /usr/lib64/liblber-2.4.so.2: no version information available (required by /mnt/steam/SteamLibrary/SteamApps/common/Alien Isolation/bin/../lib/x86_64/libcurl.so.4)
Alien Isolation/bin/AlienIsolation: /usr/lib64/libssl.so.1.0.0: no version information available (required by /mnt/steam/SteamLibrary/SteamApps/common/Alien Isolation/bin/../lib/x86_64/libcurl.so.4)
Alien Isolation/bin/AlienIsolation: /usr/lib64/libssl.so.1.0.0: no version information available (required by /mnt/steam/SteamLibrary/SteamApps/common/Alien Isolation/bin/../lib/x86_64/libcurl.so.4)
Alien Isolation/bin/AlienIsolation: /usr/lib64/libcrypto.so.1.0.0: no version information available (required by /mnt/steam/SteamLibrary/SteamApps/common/Alien Isolation/bin/../lib/x86_64/libcurl.so.4)
	linux-vdso.so.1 (0x00007ffc30f7c000)
	libpcre.so.3 => /usr/lib64/libpcre.so.3 (0x00007feca72aa000)
	libjpeg.so.8 => not found
	libCoreFoundation.so.476 => /mnt/steam/SteamLibrary/SteamApps/common/Alien Isolation/bin/../lib/x86_64/libCoreFoundation.so.476 (0x00007feca6f07000)
	libcurl.so.4 => /mnt/steam/SteamLibrary/SteamApps/common/Alien Isolation/bin/../lib/x86_64/libcurl.so.4 (0x00007feca6c90000)
	libvorbis.so.0 => /usr/lib64/libvorbis.so.0 (0x00007feca6a64000)
	libpthread.so.0 => /lib64/libpthread.so.0 (0x00007feca6848000)
	librt.so.1 => /lib64/librt.so.1 (0x00007feca6640000)
	libdl.so.2 => /lib64/libdl.so.2 (0x00007feca643c000)
	libSDL2-2.0.so.0 => /usr/lib64/libSDL2-2.0.so.0 (0x00007feca6133000)
	libSDL2_image-2.0.so.0 => /usr/lib64/libSDL2_image-2.0.so.0 (0x00007feca5f10000)
	libz.so.1 => /lib64/libz.so.1 (0x00007feca5cfa000)
	libfreetype.so.6 => /usr/lib64/libfreetype.so.6 (0x00007feca763e000)
	libfontconfig.so.1 => /usr/lib64/libfontconfig.so.1 (0x00007feca5ab6000)
	libstdc++.so.6 => /usr/lib/gcc/x86_64-pc-linux-gnu/5.3.0/libstdc++.so.6 (0x00007feca56be000)
	libm.so.6 => /lib64/libm.so.6 (0x00007feca53bb000)
	libgcc_s.so.1 => /usr/lib/gcc/x86_64-pc-linux-gnu/5.3.0/libgcc_s.so.1 (0x00007feca51a4000)
	libc.so.6 => /lib64/libc.so.6 (0x00007feca4e0b000)
	/lib64/ld-linux-x86-64.so.2 (0x00007feca751c000)
	libuuid.so.1 => /lib64/libuuid.so.1 (0x00007feca4c06000)
	libicui18n.so.51 => /mnt/steam/SteamLibrary/SteamApps/common/Alien Isolation/bin/../lib/x86_64/libicui18n.so.51 (0x00007feca47ef000)
	libicuuc.so.51 => /mnt/steam/SteamLibrary/SteamApps/common/Alien Isolation/bin/../lib/x86_64/libicuuc.so.51 (0x00007feca445e000)
	libidn.so.11 => /usr/lib64/libidn.so.11 (0x00007feca422b000)
	librtmp.so.0 => not found
	libssl.so.1.0.0 => /usr/lib64/libssl.so.1.0.0 (0x00007feca3fbd000)
	libcrypto.so.1.0.0 => /usr/lib64/libcrypto.so.1.0.0 (0x00007feca3b81000)
	libgssapi_krb5.so.2 => /usr/lib64/libgssapi_krb5.so.2 (0x00007feca3935000)
	liblber-2.4.so.2 => /usr/lib64/liblber-2.4.so.2 (0x00007feca3726000)
	libldap_r-2.4.so.2 => /usr/lib64/libldap_r-2.4.so.2 (0x00007feca34d2000)
	libogg.so.0 => /usr/lib64/libogg.so.0 (0x00007feca32cb000)
	libpulse.so.0 => /usr/lib64/libpulse.so.0 (0x00007feca3076000)
	libX11.so.6 => /usr/lib64/libX11.so.6 (0x00007feca2d34000)
	libXext.so.6 => /usr/lib64/libXext.so.6 (0x00007feca2b22000)
	libXcursor.so.1 => /usr/lib64/libXcursor.so.1 (0x00007feca2917000)
	libXi.so.6 => /usr/lib64/libXi.so.6 (0x00007feca2707000)
	libXrandr.so.2 => /usr/lib64/libXrandr.so.2 (0x00007feca24fc000)
	libXxf86vm.so.1 => /usr/lib64/libXxf86vm.so.1 (0x00007feca22f6000)
	libwayland-egl.so.1 => /usr/lib64/libwayland-egl.so.1 (0x00007feca20f4000)
	libwayland-client.so.0 => /usr/lib64/libwayland-client.so.0 (0x00007feca1ee5000)
	libwayland-cursor.so.0 => /usr/lib64/libwayland-cursor.so.0 (0x00007feca1cdd000)
	libxkbcommon.so.0 => /usr/lib64/libxkbcommon.so.0 (0x00007feca1a9d000)
	libpng16.so.16 => /usr/lib64/libpng16.so.16 (0x00007feca1868000)
	libjpeg.so.62 => /usr/lib64/libjpeg.so.62 (0x00007feca160f000)
	libtiff.so.5 => /usr/lib64/libtiff.so.5 (0x00007feca139a000)
	libwebp.so.5 => /usr/lib64/libwebp.so.5 (0x00007feca113b000)
	libbz2.so.1 => /lib64/libbz2.so.1 (0x00007feca0f2b000)
	libexpat.so.1 => /usr/lib64/libexpat.so.1 (0x00007feca7609000)
	libicudata.so.51 => /mnt/steam/SteamLibrary/SteamApps/common/Alien Isolation/bin/../lib/x86_64/libicudata.so.51 (0x00007fec9f7e1000)
	libkrb5.so.3 => /usr/lib64/libkrb5.so.3 (0x00007fec9f509000)
	libk5crypto.so.3 => /usr/lib64/libk5crypto.so.3 (0x00007fec9f2d8000)
	libcom_err.so.2 => /lib64/libcom_err.so.2 (0x00007fec9f0d4000)
	libkrb5support.so.0 => /usr/lib64/libkrb5support.so.0 (0x00007fec9eec8000)
	libkeyutils.so.1 => /lib64/libkeyutils.so.1 (0x00007feca7603000)
	libresolv.so.2 => /lib64/libresolv.so.2 (0x00007fec9ecb1000)
	libsasl2.so.3 => /usr/lib64/libsasl2.so.3 (0x00007fec9ea93000)
	libgnutls.so.30 => /usr/lib64/libgnutls.so.30 (0x00007fec9e76f000)
	libpulsecommon-9.0.so => /usr/lib64/pulseaudio/libpulsecommon-9.0.so (0x00007fec9e4e8000)
	libjson-c.so.2 => /usr/lib64/libjson-c.so.2 (0x00007fec9e2dd000)
	libdbus-1.so.3 => /usr/lib64/libdbus-1.so.3 (0x00007fec9e096000)
	libxcb.so.1 => /usr/lib64/libxcb.so.1 (0x00007fec9de73000)
	libXrender.so.1 => /usr/lib64/libXrender.so.1 (0x00007fec9dc69000)
	libXfixes.so.3 => /usr/lib64/libXfixes.so.3 (0x00007fec9da63000)
	libffi.so.6 => /usr/lib64/libffi.so.6 (0x00007fec9d85a000)
	libtasn1.so.6 => /usr/lib64/libtasn1.so.6 (0x00007feca75ed000)
	libnettle.so.6 => /usr/lib64/libnettle.so.6 (0x00007feca75b4000)
	libhogweed.so.4 => /usr/lib64/libhogweed.so.4 (0x00007feca757f000)
	libgmp.so.10 => /usr/lib64/libgmp.so.10 (0x00007fec9d5e1000)
	libX11-xcb.so.1 => /usr/lib64/libX11-xcb.so.1 (0x00007fec9d3df000)
	libICE.so.6 => /usr/lib64/libICE.so.6 (0x00007fec9d1c3000)
	libSM.so.6 => /usr/lib64/libSM.so.6 (0x00007fec9cfbb000)
	libXtst.so.6 => /usr/lib64/libXtst.so.6 (0x00007fec9cdb5000)
	libsndfile.so.1 => /usr/lib64/libsndfile.so.1 (0x00007fec9cb3e000)
	libXau.so.6 => /usr/lib64/libXau.so.6 (0x00007fec9c93a000)
	libXdmcp.so.6 => /usr/lib64/libXdmcp.so.6 (0x00007fec9c734000)
	libFLAC.so.8 => /usr/lib64/libFLAC.so.8 (0x00007fec9c4f8000)
	libvorbisenc.so.2 => /usr/lib64/libvorbisenc.so.2 (0x00007fec9c245000)
	libbsd.so.0 => /usr/lib64/libbsd.so.0 (0x00007feca7566000)
Comment 3 James Le Cuirot gentoo-dev 2016-07-23 20:00:47 UTC
The blank libpcre.so.3 may be a red herring as I'd forgotten that I'd manually created a symlink to libpcre.so.1 (Debian versions it differently) a couple of weeks ago. libjpeg.so.8 really is missing and libCoreFoundation.so.476 can only be found via the RPATH.
Comment 4 SpanKY gentoo-dev 2016-11-12 07:15:56 UTC
these issues should all be fixed w/1.1.7.  lemme know how it works for you.
Comment 5 James Le Cuirot gentoo-dev 2016-11-12 21:25:35 UTC
I've seen the git log and I'm not sure exactly which change relates to this but I can see that --ldcache doesn't return blank entries any more.

You still can't tell RPATH-dependent libraries apart from libraries that cannot be found at all but at least it's more consistent now.

As I said, I didn't really need this in the end but thanks for improving it anyway. I may need it later.
Comment 6 SpanKY gentoo-dev 2016-11-14 14:29:11 UTC
(In reply to James Le Cuirot from comment #5)
> You still can't tell RPATH-dependent libraries apart from libraries that
> cannot be found at all but at least it's more consistent now.

i don't know what you mean by this ... ldd/lddtree/scanelf have never given a marker that shows how a library was found.  if an ELF has a RPATH entry, then they should be respecting it and searching that path.

can you post an example of what you're talking about ?
Comment 7 James Le Cuirot gentoo-dev 2016-11-15 11:05:47 UTC
(In reply to SpanKY from comment #6)
> (In reply to James Le Cuirot from comment #5)
> > You still can't tell RPATH-dependent libraries apart from libraries that
> > cannot be found at all but at least it's more consistent now.
> 
> i don't know what you mean by this ... ldd/lddtree/scanelf have never given
> a marker that shows how a library was found.  if an ELF has a RPATH entry,
> then they should be respecting it and searching that path.
> 
> can you post an example of what you're talking about ?

Let's consider libCoreFoundation.so from the example above. It's only available via the RPATH entry of $ORIGIN/../lib. Here's what ldd shows.

$ ldd Alien\ Isolation/bin/AlienIsolation | fgrep libCoreFoundation
	libCoreFoundation.so.476 => /mnt/steam/SteamLibrary/SteamApps/common/Alien Isolation/bin/../lib/x86_64/libCoreFoundation.so.476 (0x00007fb36dddf000)

Here's what scanelf shows.

$ scanelf -n --use-ldpath Alien\ Isolation/bin/AlienIsolation
 TYPE   NEEDED FILE 
ET_EXEC libpcre.so.3,/usr/lib64/libjpeg.so.8,libCoreFoundation.so.476,/usr/lib64/libcurl.so.4,/usr/lib64/libvorbis.so.0,/lib64/libpthread.so.0,/lib64/librt.so.1,/lib64/libdl.so.2,/usr/lib64/libSDL2-2.0.so.0,/usr/lib64/libSDL2_image-2.0.so.0,/lib64/libz.so.1,/usr/lib64/libfreetype.so.6,/usr/lib64/libfontconfig.so.1,/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/32/libstdc++.so.6,/lib64/libm.so.6,/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/32/libgcc_s.so.1,/lib64/libc.so.6,/lib64/ld-linux-x86-64.so.2 Alien Isolation/bin/AlienIsolation

See how it's simply shown as libCoreFoundation.so.476 without a path. Now let's move the library out the way. ldd says it's not found.

$ ldd Alien\ Isolation/bin/AlienIsolation | fgrep libCoreFoundation
	libCoreFoundation.so.476 => not found

scanelf's output is exactly the same as before.

$ scanelf -n --use-ldpath Alien\ Isolation/bin/AlienIsolation
 TYPE   NEEDED FILE 
ET_EXEC libpcre.so.3,/usr/lib64/libjpeg.so.8,libCoreFoundation.so.476,/usr/lib64/libcurl.so.4,/usr/lib64/libvorbis.so.0,/lib64/libpthread.so.0,/lib64/librt.so.1,/lib64/libdl.so.2,/usr/lib64/libSDL2-2.0.so.0,/usr/lib64/libSDL2_image-2.0.so.0,/lib64/libz.so.1,/usr/lib64/libfreetype.so.6,/usr/lib64/libfontconfig.so.1,/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/32/libstdc++.so.6,/lib64/libm.so.6,/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/32/libgcc_s.so.1,/lib64/libc.so.6,/lib64/ld-linux-x86-64.so.2 Alien Isolation/bin/AlienIsolation

I guess what I'm really trying to say is that resolution via RPATH still isn't working here. Perhaps it's not dealing with $ORIGIN?
Comment 8 SpanKY gentoo-dev 2016-11-15 18:08:23 UTC
scanelf today does not handle any rpath tags, $ORIGIN or otherwise.  i can look into adding support for it for --needed output.  no ETA though.
Comment 9 Sergei Trofimovich (RETIRED) gentoo-dev 2018-04-20 06:12:01 UTC
*** Bug 653586 has been marked as a duplicate of this bug. ***