diff options
-rwxr-xr-x | lddtree.py | 13 | ||||
-rwxr-xr-x | lddtree.sh | 11 | ||||
-rwxr-xr-x | tests/lddtree/dotest.cmp | 10 |
3 files changed, 30 insertions, 4 deletions
@@ -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) @@ -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} |