scripts/xldd: avoid reporting duplicates
author"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Wed Nov 24 21:01:46 2010 +0100 (2010-11-24)
changeset 2191226d9684bf3c
parent 2190 9b9a0bb51cfb
child 2192 cbd4539a86ca
scripts/xldd: avoid reporting duplicates

Once a NEEDED dependency has been solved, do not report it
if other dependencies depend on it.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
scripts/xldd.in
     1.1 --- a/scripts/xldd.in	Tue Nov 23 21:35:45 2010 +0100
     1.2 +++ b/scripts/xldd.in	Wed Nov 24 21:01:46 2010 +0100
     1.3 @@ -224,14 +224,26 @@
     1.4  # Scan a file for all NEEDED tags
     1.5  do_process_file() {
     1.6      local file="${1}"
     1.7 +    local n m
     1.8 +    local found
     1.9  
    1.10      do_trace "Parsing file '${file}'\n"
    1.11  
    1.12 -    "${readelf}" -d "${file}"                                           \
    1.13 -    |"${grep}" -E '\(NEEDED\)'                                          \
    1.14 -    |"${sed}" -r -e 's/^.*Shared library:[[:space:]]+\[(.*)\]$/\1/;'    \
    1.15 -    |while read needed; do
    1.16 -        do_find_needed "${needed}"
    1.17 +    for n in $( "${readelf}" -d "${file}"                                           \
    1.18 +                |"${grep}" -E '\(NEEDED\)'                                          \
    1.19 +                |"${sed}" -r -e 's/^.*Shared library:[[:space:]]+\[(.*)\]$/\1/;'    \
    1.20 +              ); do
    1.21 +        found=0
    1.22 +        for m in "${needed_list[@]}"; do
    1.23 +            [ "${n}" = "${m}" ] && found=1 && break
    1.24 +        done
    1.25 +        if [ ${found} -ne 0 ]; then
    1.26 +            do_trace "-> skipping already known dependency '${n}'\n"
    1.27 +            continue
    1.28 +        fi
    1.29 +        do_trace "-> handling new dependency '${n}'\n"
    1.30 +        needed_list+=( "${n}" )
    1.31 +        do_find_needed "${n}"
    1.32       done
    1.33  }
    1.34  
    1.35 @@ -283,4 +295,5 @@
    1.36  done
    1.37  
    1.38  do_trace "Scanning file '${1}'\n"
    1.39 +declare -a needed_list
    1.40  do_process_file "${1}"