On Sat, 23 Apr 2005 12:15:32 +0200
Spider <[EMAIL PROTECTED]> wrote:

> So, I know it isn't foolproof, don't expect it to be.  However,
> feedback would be nice, patches and so on.   

I think that for binaries you could filter the ldd output to keep
only the libs that are directly linked to, since that's what
should really become dependencies. See atttached patch for a
possible quick and dirty implementation.

Example without the patch:
% echo /usr/games/bin/abuse.sdl | ./depreverse.orig
/lib/libdl.so.2
/lib/libncursesw.so.5
/lib/libnsl.so.1
/lib/tls/libc.so.6
/lib/tls/libm.so.6
/lib/tls/libpthread.so.0
/usr/lib/gcc/i686-pc-linux-gnu/3.4.3-20050110/libgcc_s.so.1
/usr/lib/gcc/i686-pc-linux-gnu/3.4.3-20050110/libstdc++.so.6
/usr/lib/libaa.so.1
/usr/lib/libcaca.so.0
/usr/lib/libSDL-1.2.so.0
/usr/lib/libslang-utf8.so.1
/usr/lib/libvga.so.1
/usr/lib/libX11.so.6
/usr/lib/libXext.so.6
/usr/lib/libXxf86vm.so.1
/usr/lib/opengl/xorg-x11/lib/libGL.so.1

The same with the patch:
% echo /usr/games/bin/abuse.sdl | ./depreverse
/lib/libnsl.so.1
/lib/tls/libc.so.6
/lib/tls/libm.so.6
/lib/tls/libpthread.so.0
/usr/lib/gcc/i686-pc-linux-gnu/3.4.3-20050110/libgcc_s.so.1
/usr/lib/gcc/i686-pc-linux-gnu/3.4.3-20050110/libstdc++.so.6
/usr/lib/libSDL-1.2.so.0
/usr/lib/opengl/xorg-x11/lib/libGL.so.1

-- 
TGL.
--- depreverse.orig	2005-04-23 13:35:49.000000000 +0200
+++ depreverse	2005-04-23 14:03:07.000000000 +0200
@@ -111,7 +111,8 @@
 # since we already tested if executables are executable, we only need one pass to test both theese lists.
 for FILE in $EXELIST $LIBLIST ; do
 	if [ -r $FILE ]; then
-		ldd $FILE |grep -v 'libNoVersion.so' | grep -v 'linux-gate.so' | awk '/=>/ { print $3 }'
+		needed_libs_regexp="$(objdump -p $FILE | awk '/NEEDED/ { rex=rex "\\|\\<"$2"\\>"} ; END {print substr(rex,3)}')"
+		ldd $FILE | grep "${needed_libs_regexp}" | awk '/=>/ { print $3 }'
 	fi
 done | sort -u | sed "s/['\"]/\\\&/g" | sort -u
 

Reply via email to