From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 16E9F1381FA for ; Sun, 1 Jun 2014 02:05:53 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id CD933E0824; Sun, 1 Jun 2014 02:05:50 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 515E8E0824 for ; Sun, 1 Jun 2014 02:05:50 +0000 (UTC) Received: from spoonbill.gentoo.org (spoonbill.gentoo.org [81.93.255.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 5B07833FEA4 for ; Sun, 1 Jun 2014 02:05:49 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by spoonbill.gentoo.org (Postfix) with ESMTP id A154F181A9 for ; Sun, 1 Jun 2014 02:05:47 +0000 (UTC) From: "Anthony G. Basile" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Anthony G. Basile" Message-ID: <1401588627.0ebc3cb8dc5588d7be43b07cfd24fed93e8523a2.blueness@gentoo> Subject: [gentoo-commits] proj/elfix:master commit in: misc/ldd/ X-VCS-Repository: proj/elfix X-VCS-Files: misc/ldd/ldd.py X-VCS-Directories: misc/ldd/ X-VCS-Committer: blueness X-VCS-Committer-Name: Anthony G. Basile X-VCS-Revision: 0ebc3cb8dc5588d7be43b07cfd24fed93e8523a2 X-VCS-Branch: master Date: Sun, 1 Jun 2014 02:05:47 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: cc5f23b9-f0ba-47a0-ab57-824c56f98292 X-Archives-Hash: db6d8d4c386e21bc3ce7f9f824ac0a10 commit: 0ebc3cb8dc5588d7be43b07cfd24fed93e8523a2 Author: Anthony G. Basile gentoo org> AuthorDate: Sun Jun 1 02:10:27 2014 +0000 Commit: Anthony G. Basile gentoo org> CommitDate: Sun Jun 1 02:10:27 2014 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/elfix.git;a=commit;h=0ebc3cb8 misc/ldd: recursively search all_dt_needed_paths --- misc/ldd/ldd.py | 17 ++++++++++++----- 1 file 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()