/[gentoo-projects]/pax-utils/symtree.sh
Gentoo

Diff of /pax-utils/symtree.sh

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.3 Revision 1.4
1#!/bin/bash 1#!/bin/bash
2
3source lddtree /../..source.lddtree || exit 1
4 2
5argv0=${0##*/} 3argv0=${0##*/}
6 4
7usage() { 5usage() {
8 cat <<-EOF 6 cat <<-EOF
20sym_list() { 18sym_list() {
21 # with large strings, bash is much slower than sed 19 # with large strings, bash is much slower than sed
22 local type=$1; shift 20 local type=$1; shift
23 echo "%${type}%$@" | sed "s:,:,%${type}%:g" 21 echo "%${type}%$@" | sed "s:,:,%${type}%:g"
24} 22}
23find_elf() {
24 echo "$2" | awk -F/ -v lib="$1" '$NF == lib {print}'
25}
25show_elf() { 26show_elf() {
26 local elf=$1 27 local elf=$1
27 local rlib lib libs 28 local rlib lib libs
28 local resolved=$(find_elf "${elf}") 29 local resolved=$(realpath "${elf}")
30 local resolved_libs=$(lddtree -l "${resolved}")
29 31
30 printf "%s\n" "${resolved}" 32 printf "%s\n" "${resolved}"
31 33
32 libs=$(scanelf -qF '#F%n' "${resolved}") 34 libs=$(scanelf -qF '#F%n' "${resolved}")
33 35
34 local u uu d dd 36 local u uu d dd
35 u=$(scanelf -q -F'%s#F' -s'%u%' "${elf}") 37 u=$(scanelf -q -F'%s#F' -s'%u%' "${elf}")
36 for lib in ${libs//,/ } ; do 38 for lib in ${libs//,/ } ; do
37 lib=${lib##*/} 39 lib=${lib##*/}
38 rlib=$(find_elf "${lib}" "${resolved}") 40 rlib=$(find_elf "${lib}" "${resolved_libs}")
39 41
40 d=$(scanelf -qF'%s#F' -s`sym_list d "${u}"` "${rlib}") 42 d=$(scanelf -qF'%s#F' -s`sym_list d "${u}"` "${rlib}")
41 if [[ -n ${d} ]] ; then 43 if [[ -n ${d} ]] ; then
42 dd=${dd:+${dd},}${d} 44 dd=${dd:+${dd},}${d}
43 printf "%4s%s => %s\n" "" "${lib}" "${d}" 45 printf "%4s%s => %s\n" "" "${lib}" "${d}"

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

  ViewVC Help
Powered by ViewVC 1.1.20