1.1 --- a/scripts/xldd.in Wed Nov 24 21:01:46 2010 +0100
1.2 +++ b/scripts/xldd.in Tue Nov 23 21:36:01 2010 +0100
1.3 @@ -11,8 +11,8 @@
1.4 prefix="${0%-ldd}"
1.5 gcc="${prefix}-gcc"
1.6 readelf="${prefix}-readelf"
1.7 -fake_load_addr="$((0xdeadbeef))"
1.8 -fake_load_addr_sys="$((0x8badf00d))"
1.9 +fake_load_addr_root="$((0xdeadbeef))"
1.10 +fake_load_addr_sysroot="$((0x8badf00d))"
1.11 ld_library_path="/lib:/usr/lib"
1.12
1.13 do_error() {
1.14 @@ -160,18 +160,21 @@
1.15 do_report_needed_found() {
1.16 local needed="${1}"
1.17 local path="${2}"
1.18 - local system="${3}"
1.19 + local origin="${3}"
1.20 local loadaddr
1.21 local sys
1.22
1.23 - if [ -z "${system}" ]; then
1.24 - loadaddr="${fake_load_addr}"
1.25 - else
1.26 - loadaddr="${fake_load_addr_sys}"
1.27 - if [ -n "${show_system}" ]; then
1.28 - sys=" [*]"
1.29 - fi
1.30 - fi
1.31 + case "${origin}" in
1.32 + root)
1.33 + loadaddr="${fake_load_addr_root}"
1.34 + ;;
1.35 + sysroot)
1.36 + loadaddr="${fake_load_addr_sysroot}"
1.37 + if [ -n "${show_system}" ]; then
1.38 + sys=" [*]"
1.39 + fi
1.40 + ;;
1.41 + esac
1.42
1.43 printf "%8s%s => %s (0x%0*x)%s\n" \
1.44 "" \
1.45 @@ -185,39 +188,37 @@
1.46 # Search a needed file, scanning ${lib_dir} in the root directory
1.47 do_find_needed() {
1.48 local needed="${1}"
1.49 + local -a list
1.50 local found
1.51 - local found_sysroot
1.52 - local d
1.53 + local where
1.54 + local base
1.55 + local d i
1.56
1.57 do_trace "Searching for '${needed}'\n"
1.58
1.59 - for d in "${needed_search_path[@]}"; do
1.60 - do_trace "-> looking in '${d}'\n"
1.61 - if [ -f "${root}${d}/${needed}" ]; then
1.62 - found="${d}/${needed}"
1.63 - do_trace "---> found\n"
1.64 - break
1.65 - fi
1.66 + list=( \
1.67 + "root:${root}" \
1.68 + "sysroot:${sysroot}" \
1.69 + )
1.70 +
1.71 + for i in "${list[@]}"; do
1.72 + where="${i%%:*}"
1.73 + base="${i#*:}"
1.74 + for d in "${needed_search_path[@]}"; do
1.75 + do_trace "-> looking in '${d}' (${where})\n"
1.76 + if [ -f "${base}${d}/${needed}" ]; then
1.77 + found="${d}/${needed}"
1.78 + do_trace "---> found\n"
1.79 + break 2
1.80 + fi
1.81 + done
1.82 done
1.83 - if [ -z "${found}" ]; then
1.84 - for d in "${needed_search_path[@]}"; do
1.85 - do_trace "-> looking in '${d}' (sysroot)\n"
1.86 - if [ -f "${sysroot}${d}/${needed}" ]; then
1.87 - found_sysroot="${d}/${needed}"
1.88 - do_trace "---> found\n"
1.89 - break
1.90 - fi
1.91 - done
1.92 - fi
1.93
1.94 if [ -n "${found}" ]; then
1.95 - do_report_needed_found "${needed}" "${found}"
1.96 - do_process_file "${root}${found}"
1.97 - elif [ -n "${found_sysroot}" ]; then
1.98 - do_report_needed_found "${needed}" "${found_sysroot}" "sys"
1.99 - do_process_file "${sysroot}${found_sysroot}"
1.100 + do_report_needed_found "${needed}" "${found}" "${where}"
1.101 + do_process_file "${base}${found}"
1.102 else
1.103 - printf "%8c%s not found\n" "" "${needed}"
1.104 + printf "%8s%s not found\n" "" "${needed}"
1.105 fi
1.106 }
1.107