diff options
author | Anthony G. Basile <blueness@gentoo.org> | 2014-05-31 22:10:27 -0400 |
---|---|---|
committer | Anthony G. Basile <blueness@gentoo.org> | 2014-05-31 22:10:27 -0400 |
commit | 0ebc3cb8dc5588d7be43b07cfd24fed93e8523a2 (patch) | |
tree | 169b0120eaa4f8c39fdb90edf426b643da718711 | |
parent | misc/install-xattr: remove argv[0]'s dirname check (diff) | |
download | elfix-0ebc3cb8dc5588d7be43b07cfd24fed93e8523a2.tar.gz elfix-0ebc3cb8dc5588d7be43b07cfd24fed93e8523a2.tar.bz2 elfix-0ebc3cb8dc5588d7be43b07cfd24fed93e8523a2.zip |
misc/ldd: recursively search all_dt_needed_paths
-rwxr-xr-x | misc/ldd/ldd.py | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/misc/ldd/ldd.py b/misc/ldd/ldd.py index 1819607..3574137 100755 --- a/misc/ldd/ldd.py +++ b/misc/ldd/ldd.py @@ -78,7 +78,7 @@ def ldpaths(ld_so_conf='/etc/ld.so.conf'): def dynamic_dt_needed_paths( dt_needed, eclass, paths): """ Search library paths for the library file corresponding - to the DT_NEEDED and ELF Class. + to the given DT_NEEDED and ELF Class. """ dt_needed_paths = {} for n in dt_needed: @@ -97,20 +97,25 @@ def dynamic_dt_needed_paths( dt_needed, eclass, paths): return dt_needed_paths -def all_dt_needed_paths(f, paths): +def all_dynamic_dt_needed_paths(f, paths): + """ Return a dictionary of all the DT_NEEDED => Library Paths for + a given ELF file obtained by recursively following linkage. + """ with open(f, 'rb') as file: try: readelf = ReadElf(file) eclass = readelf.elf_class() # This needs to be iterated until we traverse the entire linkage tree dt_needed = readelf.dynamic_dt_needed() - dt_needed_paths = dynamic_dt_needed_paths( dt_needed, eclass, paths) + dt_needed_paths = dynamic_dt_needed_paths(dt_needed, eclass, paths) for n, lib in dt_needed_paths.items(): - sys.stdout.write('\t%s => %s\n' % (n, lib)) + dt_needed_paths = dict(all_dynamic_dt_needed_paths(lib, paths), **dt_needed_paths) except ELFError as ex: sys.stderr.write('ELF error: %s\n' % ex) sys.exit(1) + return dt_needed_paths + SCRIPT_DESCRIPTION = 'Print shared library dependencies' VERSION_STRING = '%%prog: based on pyelftools %s' % __version__ @@ -136,7 +141,9 @@ def main(): for f in args: if len(args) > 1: sys.stdout.write('%s : \n' % f) - all_dt_needed_paths(f, paths) + all_dt_needed_paths = all_dynamic_dt_needed_paths(f, paths) + for n, lib in all_dt_needed_paths.items(): + sys.stdout.write('\t%s => %s\n' % (n, lib)) if __name__ == '__main__': main() |