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 ED76A138E7A for ; Mon, 20 Jul 2015 04:15:27 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id F2BFCE092C; Mon, 20 Jul 2015 04:15:23 +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 87C7BE092C for ; Mon, 20 Jul 2015 04:15:23 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 1A69D340862 for ; Mon, 20 Jul 2015 04:15:22 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id E8009AD for ; Mon, 20 Jul 2015 04:15:17 +0000 (UTC) From: "Mike Frysinger" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Mike Frysinger" Message-ID: <1437365002.26ee546756ce9e1bb84951bc5cfac3cdde87a2d1.vapier@gentoo> Subject: [gentoo-commits] proj/pax-utils:master commit in: /, tests/lddtree/ X-VCS-Repository: proj/pax-utils X-VCS-Files: lddtree.py lddtree.sh tests/lddtree/dotest.cmp X-VCS-Directories: / tests/lddtree/ X-VCS-Committer: vapier X-VCS-Committer-Name: Mike Frysinger X-VCS-Revision: 26ee546756ce9e1bb84951bc5cfac3cdde87a2d1 X-VCS-Branch: master Date: Mon, 20 Jul 2015 04:15:17 +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: ef914b32-127f-4406-b194-bdcc776e44e9 X-Archives-Hash: ca4d7e9838315f724b3df3e5a0f56aa5 commit: 26ee546756ce9e1bb84951bc5cfac3cdde87a2d1 Author: Mike Frysinger gentoo org> AuthorDate: Mon Jul 20 04:03:22 2015 +0000 Commit: Mike Frysinger gentoo org> CommitDate: Mon Jul 20 04:03:22 2015 +0000 URL: https://gitweb.gentoo.org/proj/pax-utils.git/commit/?id=26ee5467 lddtree: handle direct ldso linkage better If the ELF we're showing is linked directly against the ELF which is used as the ELF interp (i.e. the ldso), make sure we don't list it twice. We want to see it "twice" in the pretty form: $ ./lddtree.py /bin/bash /bin/bash (interpreter => /lib/ld-linux-armhf.so.3) <= here libreadline.so.6 => /lib/libreadline.so.6 libncurses.so.5 => /lib/libncurses.so.5 libc.so.6 => /lib/libc.so.6 ld-linux-armhf.so.3 => /lib/ld-linux-armhf.so.3 <= here But not in the list form (as that is used by scripts): $ ./lddtree.py -l /bin/bash /bin/bash /lib/ld-linux-armhf.so.3 <= only here /lib/libreadline.so.6 /lib/libncurses.so.5 /lib/libc.so.6 We also reconcile a few differences wrt interp display and the sh/py implementations. Reported-by: Tomasz Buchert debian.org> lddtree.py | 13 +++++++++++-- lddtree.sh | 11 +++++++++-- tests/lddtree/dotest.cmp | 10 ++++++++++ 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/lddtree.py b/lddtree.py index 645cfd1..9330295 100755 --- a/lddtree.py +++ b/lddtree.py @@ -510,17 +510,26 @@ def _ActionShow(options, elf): chain_libs.pop() shown_libs = set(elf['needed']) + new_libs = elf['needed'][:] chain_libs = [] interp = elf['interp'] if interp: - shown_libs.add(os.path.basename(interp)) + lib = os.path.basename(interp) + shown_libs.add(lib) + # If we are in non-list mode, then we want to show the "duplicate" interp + # lines -- first the header (interp=>xxx), and then the DT_NEEDED line to + # show that the ELF is directly linked against the interp. + # If we're in list mode though, we only want to show the interp once. + # Unless of course we have the --all flag active, then we show everything. + if not options.all and options.list and lib in new_libs: + new_libs.remove(lib) if options.list: print(elf['path']) if not interp is None: print(interp) else: print('%s (interpreter => %s)' % (elf['path'], interp)) - for lib in elf['needed']: + for lib in new_libs: _show(lib, 1) diff --git a/lddtree.sh b/lddtree.sh index a37d499..07be7ab 100755 --- a/lddtree.sh +++ b/lddtree.sh @@ -160,6 +160,11 @@ show_elf() { ) fi interp=${interp##*/} + # If we are in non-list mode, then we want to show the "duplicate" interp + # lines -- first the header (interp=>xxx), and then the DT_NEEDED line to + # show that the ELF is directly linked against the interp. + # If we're in list mode though, we only want to show the interp once. + ${LIST} && allhits+=",${interp}" fi ${LIST} || printf "\n" @@ -170,12 +175,14 @@ show_elf() { local my_allhits if ! ${SHOW_ALL} ; then my_allhits="${allhits}" - allhits="${allhits},${interp},${libs}" + allhits+=",${libs}" fi for lib in ${libs//,/ } ; do lib=${lib##*/} - [[ ,${my_allhits}, == *,${lib},* ]] && continue + # No need for leading comma w/my_allhits as we guarantee it always + # starts with one due to the way we append the value above. + [[ ${my_allhits}, == *,${lib},* ]] && continue find_elf "${lib}" "${resolved}" rlib=${_find_elf} show_elf "${rlib:-${lib}}" $((indent + 4)) "${parent_elfs}" diff --git a/tests/lddtree/dotest.cmp b/tests/lddtree/dotest.cmp index d8992f3..2f04a55 100755 --- a/tests/lddtree/dotest.cmp +++ b/tests/lddtree/dotest.cmp @@ -13,5 +13,15 @@ testit lddtree.*.list rm -f lddtree.*.list +# +# Same as above but with the -a flag +# +for sfx in py sh ; do + lddtree.${sfx} -l -a /bin/bash > lddtree.${sfx}.list-all & +done +wait +testit lddtree.*.list-all +rm -f lddtree.*.list-all + exit ${ret}