* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.sh
@ 2007-12-31 23:33 Mike Frysinger (vapier)
0 siblings, 0 replies; 15+ messages in thread
From: Mike Frysinger (vapier) @ 2007-12-31 23:33 UTC (permalink / raw
To: gentoo-commits
vapier 07/12/31 23:33:27
Added: lddtree.sh
Log:
print the ELF dependency tree as a ......... tree
Revision Changes Path
1.1 pax-utils/lddtree.sh
file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/lddtree.sh?rev=1.1&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/lddtree.sh?rev=1.1&content-type=text/plain
Index: lddtree.sh
===================================================================
#!/bin/bash
argv0=${0##*/}
usage() {
cat <<-EOF
Display ELF dependencies as a tree
Usage: ${argv0} [options] <ELF file[s]>
Options:
-a Show all duplicated dependencies
-x Run with debugging
-h Show this help output
EOF
exit ${1:-0}
}
SHOW_ALL=false
SET_X=false
opts="hax"
getopt -Q -- "${opts}" "$@" || exit 1
eval set -- $(getopt -- "${opts}" "$@")
while [[ -n $1 ]] ; do
case $1 in
-a) SHOW_ALL=true;;
-x) SET_X=true;;
-h) usage;;
--) shift; break;;
-*) usage 1;;
esac
shift
done
${SET_X} && set -x
ret=0
error() {
echo "${argv0}: $*" 1>&2
ret=1
return 1
}
find_elf() {
local elf=$1 needed_by=$2
if [[ ${elf} == */* ]] && [[ -e ${elf} ]] ; then
echo "${elf}"
return 0
else
check_paths() {
local elf=$1 ; shift
local path
for path in "$@" ; do
if [[ -e ${path}/${elf} ]] ; then
echo "${path}/${elf}"
return 0
fi
done
return 1
}
check_paths "${elf}" $(scanelf -qF '#F%r' "${needed_by}") && return 0
check_paths "${elf}" $(sed -e 's:^[[:space:]]*#.*::' /etc/ld.so.conf) && return 0
fi
return 1
}
show_elf() {
local elf=$1 indent=$2 parent_elfs=$3
local rlib lib libs
local interp resolved=$(find_elf "${elf}")
elf=${elf##*/}
printf "%${indent}s%s => " "" "${elf}"
if [[ ,${parent_elfs}, == *,${elf},* ]] ; then
printf "!!! circular loop !!!\n" ""
return
fi
parent_elfs="${parent_elfs},${elf}"
printf "${resolved:-not found}"
if [[ ${indent} -eq 0 ]] ; then
interp=$(scanelf -qF '#F%i' "${elf}")
printf " (interpreter => ${interp:-none})"
interp=${interp##*/}
fi
printf "\n"
[[ -z ${resolved} ]] && return
libs=$(scanelf -qF '#F%n' "${resolved}")
local my_allhits
if ! ${SHOW_ALL} ; then
my_allhits="${allhits}"
allhits="${allhits},${interp},${libs}"
fi
for lib in ${libs//,/ } ; do
lib=${lib##*/}
[[ ,${my_allhits}, == *,${lib},* ]] && continue
rlib=$(find_elf "${lib}" "${resolved}")
show_elf "${rlib:-${lib}}" $((indent + 4)) "${parent_elfs}"
done
}
for elf in "$@" ; do
if [[ ! -e ${elf} ]] ; then
error "${elf}: file does not exist"
elif [[ ! -r ${elf} ]] ; then
error "${elf}: file is not readable"
elif [[ -d ${elf} ]] ; then
error "${elf}: is a directory"
else
allhits=""
[[ ${elf} != */* ]] && elf="./${elf}"
show_elf "${elf}" 0 ""
fi
done
exit ${ret}
--
gentoo-commits@gentoo.org mailing list
^ permalink raw reply [flat|nested] 15+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.sh
@ 2007-12-31 23:36 Mike Frysinger (vapier)
0 siblings, 0 replies; 15+ messages in thread
From: Mike Frysinger (vapier) @ 2007-12-31 23:36 UTC (permalink / raw
To: gentoo-commits
vapier 07/12/31 23:36:42
Modified: lddtree.sh
Log:
missed one elf->resolved change
Revision Changes Path
1.2 pax-utils/lddtree.sh
file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/lddtree.sh?rev=1.2&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/lddtree.sh?rev=1.2&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/lddtree.sh?r1=1.1&r2=1.2
Index: lddtree.sh
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.sh,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- lddtree.sh 31 Dec 2007 23:33:27 -0000 1.1
+++ lddtree.sh 31 Dec 2007 23:36:41 -0000 1.2
@@ -79,7 +79,7 @@
parent_elfs="${parent_elfs},${elf}"
printf "${resolved:-not found}"
if [[ ${indent} -eq 0 ]] ; then
- interp=$(scanelf -qF '#F%i' "${elf}")
+ interp=$(scanelf -qF '#F%i' "${resolved}")
printf " (interpreter => ${interp:-none})"
interp=${interp##*/}
fi
--
gentoo-commits@gentoo.org mailing list
^ permalink raw reply [flat|nested] 15+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.sh
@ 2007-12-31 23:46 Mike Frysinger (vapier)
0 siblings, 0 replies; 15+ messages in thread
From: Mike Frysinger (vapier) @ 2007-12-31 23:46 UTC (permalink / raw
To: gentoo-commits
vapier 07/12/31 23:46:00
Modified: lddtree.sh
Log:
if lib cannot be found in rpath/ld.so.conf, check standard library paths
Revision Changes Path
1.3 pax-utils/lddtree.sh
file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/lddtree.sh?rev=1.3&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/lddtree.sh?rev=1.3&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/lddtree.sh?r1=1.2&r2=1.3
Index: lddtree.sh
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.sh,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- lddtree.sh 31 Dec 2007 23:36:41 -0000 1.2
+++ lddtree.sh 31 Dec 2007 23:45:59 -0000 1.3
@@ -61,6 +61,7 @@
}
check_paths "${elf}" $(scanelf -qF '#F%r' "${needed_by}") && return 0
check_paths "${elf}" $(sed -e 's:^[[:space:]]*#.*::' /etc/ld.so.conf) && return 0
+ check_paths "${elf}" /lib* /usr/lib* /usr/local/lib* && return 0
fi
return 1
}
--
gentoo-commits@gentoo.org mailing list
^ permalink raw reply [flat|nested] 15+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.sh
@ 2009-12-01 10:16 Mike Frysinger (vapier)
0 siblings, 0 replies; 15+ messages in thread
From: Mike Frysinger (vapier) @ 2009-12-01 10:16 UTC (permalink / raw
To: gentoo-commits
vapier 09/12/01 10:16:30
Modified: lddtree.sh
Log:
allow lddtree to be sourced by other scripts to share common funcs
Revision Changes Path
1.5 pax-utils/lddtree.sh
file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/lddtree.sh?rev=1.5&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/lddtree.sh?rev=1.5&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/lddtree.sh?r1=1.4&r2=1.5
Index: lddtree.sh
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.sh,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- lddtree.sh 17 Jan 2008 04:37:19 -0000 1.4
+++ lddtree.sh 1 Dec 2009 10:16:30 -0000 1.5
@@ -16,27 +16,6 @@
exit ${1:-0}
}
-SHOW_ALL=false
-SET_X=false
-
-([[ $1 == "" ]] || [[ $1 == --help ]]) && usage 1
-opts="hax"
-getopt -Q -- "${opts}" "$@" || exit 1
-eval set -- $(getopt -- "${opts}" "$@")
-while [[ -n $1 ]] ; do
- case $1 in
- -a) SHOW_ALL=true;;
- -x) SET_X=true;;
- -h) usage;;
- --) shift; break;;
- -*) usage 1;;
- esac
- shift
-done
-
-${SET_X} && set -x
-
-ret=0
error() {
echo "${argv0}: $*" 1>&2
ret=1
@@ -105,6 +84,30 @@
done
}
+# XXX: internal hack
+if [[ $1 != "/../..source.lddtree" ]] ; then
+
+SHOW_ALL=false
+SET_X=false
+
+([[ $1 == "" ]] || [[ $1 == --help ]]) && usage 1
+opts="hax"
+getopt -Q -- "${opts}" "$@" || exit 1
+eval set -- $(getopt -- "${opts}" "$@")
+while [[ -n $1 ]] ; do
+ case $1 in
+ -a) SHOW_ALL=true;;
+ -x) SET_X=true;;
+ -h) usage;;
+ --) shift; break;;
+ -*) usage 1;;
+ esac
+ shift
+done
+
+${SET_X} && set -x
+
+ret=0
for elf in "$@" ; do
if [[ ! -e ${elf} ]] ; then
error "${elf}: file does not exist"
@@ -118,5 +121,6 @@
show_elf "${elf}" 0 ""
fi
done
-
exit ${ret}
+
+fi
^ permalink raw reply [flat|nested] 15+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.sh
@ 2009-12-01 10:17 Mike Frysinger (vapier)
0 siblings, 0 replies; 15+ messages in thread
From: Mike Frysinger (vapier) @ 2009-12-01 10:17 UTC (permalink / raw
To: gentoo-commits
vapier 09/12/01 10:17:05
Modified: lddtree.sh
Log:
cache rpath/ldso lookups when possible to speed things up
Revision Changes Path
1.6 pax-utils/lddtree.sh
file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/lddtree.sh?rev=1.6&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/lddtree.sh?rev=1.6&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/lddtree.sh?r1=1.5&r2=1.6
Index: lddtree.sh
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.sh,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- lddtree.sh 1 Dec 2009 10:16:30 -0000 1.5
+++ lddtree.sh 1 Dec 2009 10:17:05 -0000 1.6
@@ -39,8 +39,20 @@
done
return 1
}
- check_paths "${elf}" $(scanelf -qF '#F%r' "${needed_by}") && return 0
- check_paths "${elf}" $(sed -e 's:^[[:space:]]*#.*::' /etc/ld.so.conf) && return 0
+ if [[ ${__last_needed_by} != ${needed_by} ]] ; then
+ __last_needed_by=${needed_by}
+ __last_needed_by_rpaths=$(scanelf -qF '#F%r' "${needed_by}" | sed 's|:| |g')
+ fi
+ check_paths "${elf}" ${__last_needed_by_rpaths} && return 0
+ if [[ -z ${__ldso_paths} ]] ; then
+ if [[ -r /etc/ld.so.conf ]] ; then
+ __ldso_paths=$(sed -e 's:^[[:space:]]*#.*::' /etc/ld.so.conf)
+ fi
+ : ${__ldso_paths:= }
+ fi
+ if [[ ${__ldso_paths} != " " ]] ; then
+ check_paths "${elf}" ${__ldso_paths} && return 0
+ fi
check_paths "${elf}" /lib* /usr/lib* /usr/local/lib* && return 0
fi
return 1
^ permalink raw reply [flat|nested] 15+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.sh
@ 2011-03-03 21:05 Mike Frysinger (vapier)
0 siblings, 0 replies; 15+ messages in thread
From: Mike Frysinger (vapier) @ 2011-03-03 21:05 UTC (permalink / raw
To: gentoo-commits
vapier 11/03/03 21:05:04
Modified: lddtree.sh
Log:
lddtree: handle "include" in ld.so.conf and LD_LIBRARY_PATH
Revision Changes Path
1.8 pax-utils/lddtree.sh
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.sh?rev=1.8&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.sh?rev=1.8&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.sh?r1=1.7&r2=1.8
Index: lddtree.sh
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.sh,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- lddtree.sh 9 Feb 2010 05:47:04 -0000 1.7
+++ lddtree.sh 3 Mar 2011 21:05:04 -0000 1.8
@@ -22,6 +22,8 @@
return 1
}
+unset c_last_needed_by
+unset c_ldso_paths
find_elf() {
local elf=$1 needed_by=$2
if [[ ${elf} == */* ]] && [[ -e ${elf} ]] ; then
@@ -32,6 +34,7 @@
local elf=$1 ; shift
local path
for path in "$@" ; do
+ # XXX: This lacks ELF EM/EI_CLASS/EI_DATA/... checking (multilib)
if [[ -e ${path}/${elf} ]] ; then
echo "${path}/${elf}"
return 0
@@ -39,20 +42,50 @@
done
return 1
}
- if [[ ${__last_needed_by} != ${needed_by} ]] ; then
- __last_needed_by=${needed_by}
- __last_needed_by_rpaths=$(scanelf -qF '#F%r' "${needed_by}" | sed 's|:| |g')
+
+ if [[ ${c_last_needed_by} != ${needed_by} ]] ; then
+ c_last_needed_by=${needed_by}
+ c_last_needed_by_rpaths=$(scanelf -qF '#F%r' "${needed_by}" | sed 's|:| |g')
+ fi
+ check_paths "${elf}" ${c_last_needed_by_rpaths} && return 0
+
+ if [[ -n ${LD_LIBRARY_PATH} ]] ; then
+ # Need to handle empty paths as $PWD,
+ # and handle spaces in between the colons
+ local p path=${LD_LIBRARY_PATH}
+ while : ; do
+ p=${path%%:*}
+ check_paths "${elf}" "${path:-${PWD}}" && return 0
+ [[ ${path} == *:* ]] || break
+ path=${path#*:}
+ done
fi
- check_paths "${elf}" ${__last_needed_by_rpaths} && return 0
- if [[ -z ${__ldso_paths} ]] ; then
+
+ if [[ -z ${c_ldso_paths} ]] ; then
if [[ -r /etc/ld.so.conf ]] ; then
- __ldso_paths=$(sed -e 's:^[[:space:]]*#.*::' /etc/ld.so.conf)
+ read_ldso_conf() {
+ local line p
+ for p in "$@" ; do
+ while read line ; do
+ case ${line} in
+ "#"*) ;;
+ "include "*) read_ldso_conf ${line#* } ;;
+ *) c_ldso_paths="${c_ldso_paths} ${line}" ;;
+ esac
+ done <"${p}"
+ done
+ }
+ # the 'include' command is relative
+ pushd /etc >/dev/null
+ read_ldso_conf /etc/ld.so.conf
+ popd >/dev/null
fi
- : ${__ldso_paths:= }
+ : ${c_ldso_paths:= }
fi
- if [[ ${__ldso_paths} != " " ]] ; then
- check_paths "${elf}" ${__ldso_paths} && return 0
+ if [[ ${c_ldso_paths} != " " ]] ; then
+ check_paths "${elf}" ${c_ldso_paths} && return 0
fi
+
check_paths "${elf}" /lib* /usr/lib* /usr/local/lib* && return 0
fi
return 1
^ permalink raw reply [flat|nested] 15+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.sh
@ 2011-03-03 21:49 Ned Ludd (solar)
0 siblings, 0 replies; 15+ messages in thread
From: Ned Ludd (solar) @ 2011-03-03 21:49 UTC (permalink / raw
To: gentoo-commits
solar 11/03/03 21:49:29
Modified: lddtree.sh
Log:
- add a cvs Header to lddtree.sh
Revision Changes Path
1.9 pax-utils/lddtree.sh
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.sh?rev=1.9&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.sh?rev=1.9&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.sh?r1=1.8&r2=1.9
Index: lddtree.sh
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.sh,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- lddtree.sh 3 Mar 2011 21:05:04 -0000 1.8
+++ lddtree.sh 3 Mar 2011 21:49:29 -0000 1.9
@@ -1,4 +1,5 @@
#!/bin/bash
+# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.sh,v 1.9 2011/03/03 21:49:29 solar Exp $
argv0=${0##*/}
^ permalink raw reply [flat|nested] 15+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.sh
@ 2011-03-23 2:23 Mike Frysinger (vapier)
0 siblings, 0 replies; 15+ messages in thread
From: Mike Frysinger (vapier) @ 2011-03-23 2:23 UTC (permalink / raw
To: gentoo-commits
vapier 11/03/23 02:23:35
Modified: lddtree.sh
Log:
lddtree: make sure conf files exist before we try to read them #360041 by Rafał Mużyło
Revision Changes Path
1.10 pax-utils/lddtree.sh
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.sh?rev=1.10&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.sh?rev=1.10&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.sh?r1=1.9&r2=1.10
Index: lddtree.sh
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.sh,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- lddtree.sh 3 Mar 2011 21:49:29 -0000 1.9
+++ lddtree.sh 23 Mar 2011 02:23:34 -0000 1.10
@@ -1,5 +1,5 @@
#!/bin/bash
-# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.sh,v 1.9 2011/03/03 21:49:29 solar Exp $
+# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.sh,v 1.10 2011/03/23 02:23:34 vapier Exp $
argv0=${0##*/}
@@ -67,6 +67,9 @@
read_ldso_conf() {
local line p
for p in "$@" ; do
+ # if the glob didnt match anything #360041,
+ # or the files arent readable, skip it
+ [[ -r ${p} ]] || continue
while read line ; do
case ${line} in
"#"*) ;;
^ permalink raw reply [flat|nested] 15+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.sh
@ 2012-11-03 0:06 Mike Frysinger (vapier)
0 siblings, 0 replies; 15+ messages in thread
From: Mike Frysinger (vapier) @ 2012-11-03 0:06 UTC (permalink / raw
To: gentoo-commits
vapier 12/11/03 00:06:10
Modified: lddtree.sh
Log:
lddtree: check for correct abi types before showing a match #364079 by Marc-Antoine Perennou
Revision Changes Path
1.11 pax-utils/lddtree.sh
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.sh?rev=1.11&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.sh?rev=1.11&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.sh?r1=1.10&r2=1.11
Index: lddtree.sh
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.sh,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- lddtree.sh 23 Mar 2011 02:23:34 -0000 1.10
+++ lddtree.sh 3 Nov 2012 00:06:10 -0000 1.11
@@ -1,5 +1,5 @@
#!/bin/bash
-# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.sh,v 1.10 2011/03/23 02:23:34 vapier Exp $
+# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.sh,v 1.11 2012/11/03 00:06:10 vapier Exp $
argv0=${0##*/}
@@ -23,22 +23,30 @@
return 1
}
-unset c_last_needed_by
-unset c_ldso_paths
+elf_specs() {
+ scanelf -BF '#F%a %M %D %I' "$1"
+}
+
+lib_paths_fallback="/lib* /usr/lib* /usr/local/lib*"
+c_ldso_paths_loaded='false'
find_elf() {
+ _find_elf=''
+
local elf=$1 needed_by=$2
if [[ ${elf} == */* ]] && [[ -e ${elf} ]] ; then
- echo "${elf}"
+ _find_elf=${elf}
return 0
else
check_paths() {
local elf=$1 ; shift
- local path
- for path in "$@" ; do
- # XXX: This lacks ELF EM/EI_CLASS/EI_DATA/... checking (multilib)
- if [[ -e ${path}/${elf} ]] ; then
- echo "${path}/${elf}"
- return 0
+ local path pe
+ for path ; do
+ pe="${path%/}/${elf#/}"
+ if [[ -e ${pe} ]] ; then
+ if [[ $(elf_specs "${pe}") == "${elf_specs}" ]] ; then
+ _find_elf=${pe}
+ return 0
+ fi
fi
done
return 1
@@ -62,11 +70,13 @@
done
fi
- if [[ -z ${c_ldso_paths} ]] ; then
+ if ! ${c_ldso_paths_loaded} ; then
+ c_ldso_paths_loaded='true'
+ c_ldso_paths=()
if [[ -r /etc/ld.so.conf ]] ; then
read_ldso_conf() {
local line p
- for p in "$@" ; do
+ for p ; do
# if the glob didnt match anything #360041,
# or the files arent readable, skip it
[[ -r ${p} ]] || continue
@@ -74,7 +84,7 @@
case ${line} in
"#"*) ;;
"include "*) read_ldso_conf ${line#* } ;;
- *) c_ldso_paths="${c_ldso_paths} ${line}" ;;
+ *) c_ldso_paths+=( "${line}" ) ;;
esac
done <"${p}"
done
@@ -84,13 +94,12 @@
read_ldso_conf /etc/ld.so.conf
popd >/dev/null
fi
- : ${c_ldso_paths:= }
fi
- if [[ ${c_ldso_paths} != " " ]] ; then
- check_paths "${elf}" ${c_ldso_paths} && return 0
+ if [[ ${#c_ldso_paths[@]} -gt 0 ]] ; then
+ check_paths "${elf}" "${c_ldso_paths[@]}" && return 0
fi
- check_paths "${elf}" /lib* /usr/lib* /usr/local/lib* && return 0
+ check_paths "${elf}" ${lib_paths_ldso:-${lib_paths_fallback}} && return 0
fi
return 1
}
@@ -98,7 +107,9 @@
show_elf() {
local elf=$1 indent=$2 parent_elfs=$3
local rlib lib libs
- local interp resolved=$(find_elf "${elf}")
+ local interp resolved
+ find_elf "${elf}"
+ resolved=${_find_elf}
elf=${elf##*/}
printf "%${indent}s%s => " "" "${elf}"
@@ -109,8 +120,15 @@
parent_elfs="${parent_elfs},${elf}"
printf "${resolved:-not found}"
if [[ ${indent} -eq 0 ]] ; then
+ elf_specs=$(elf_specs "${resolved}")
interp=$(scanelf -qF '#F%i' "${resolved}")
+
printf " (interpreter => ${interp:-none})"
+ if [[ -r ${interp} ]] ; then
+ # Extract the default lib paths out of the ldso.
+ lib_paths_ldso=$(strings "${interp}" | grep '^/.*lib')
+ lib_paths_ldso=${lib_paths_ldso//:/ }
+ fi
interp=${interp##*/}
fi
printf "\n"
@@ -128,7 +146,8 @@
for lib in ${libs//,/ } ; do
lib=${lib##*/}
[[ ,${my_allhits}, == *,${lib},* ]] && continue
- rlib=$(find_elf "${lib}" "${resolved}")
+ find_elf "${lib}" "${resolved}"
+ rlib=${_find_elf}
show_elf "${rlib:-${lib}}" $((indent + 4)) "${parent_elfs}"
done
}
@@ -153,7 +172,9 @@
${SET_X} && set -x
ret=0
-for elf in "$@" ; do
+for elf ; do
+ unset lib_paths_ldso
+ unset c_last_needed_by
if [[ ! -e ${elf} ]] ; then
error "${elf}: file does not exist"
elif [[ ! -r ${elf} ]] ; then
^ permalink raw reply [flat|nested] 15+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.sh
@ 2012-11-04 7:20 Mike Frysinger (vapier)
0 siblings, 0 replies; 15+ messages in thread
From: Mike Frysinger (vapier) @ 2012-11-04 7:20 UTC (permalink / raw
To: gentoo-commits
vapier 12/11/04 07:20:43
Modified: lddtree.sh
Log:
lddtree: add ROOT support #430366 by Richard Yao
Revision Changes Path
1.12 pax-utils/lddtree.sh
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.sh?rev=1.12&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.sh?rev=1.12&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.sh?r1=1.11&r2=1.12
Index: lddtree.sh
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.sh,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- lddtree.sh 3 Nov 2012 00:06:10 -0000 1.11
+++ lddtree.sh 4 Nov 2012 07:20:43 -0000 1.12
@@ -1,8 +1,12 @@
#!/bin/bash
-# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.sh,v 1.11 2012/11/03 00:06:10 vapier Exp $
+# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.sh,v 1.12 2012/11/04 07:20:43 vapier Exp $
argv0=${0##*/}
+: ${ROOT:=/}
+[[ ${ROOT} != */ ]] && ROOT="${ROOT}/"
+[[ ${ROOT} != /* ]] && ROOT="${PWD}${ROOT}"
+
usage() {
cat <<-EOF
Display ELF dependencies as a tree
@@ -10,9 +14,10 @@
Usage: ${argv0} [options] <ELF file[s]>
Options:
- -a Show all duplicated dependencies
- -x Run with debugging
- -h Show this help output
+ -a Show all duplicated dependencies
+ -x Run with debugging
+ -h Show this help output
+ -R <root> Use this ROOT filesystem tree
EOF
exit ${1:-0}
}
@@ -27,7 +32,7 @@
scanelf -BF '#F%a %M %D %I' "$1"
}
-lib_paths_fallback="/lib* /usr/lib* /usr/local/lib*"
+lib_paths_fallback="${ROOT}lib* ${ROOT}usr/lib* ${ROOT}usr/local/lib*"
c_ldso_paths_loaded='false'
find_elf() {
_find_elf=''
@@ -73,7 +78,7 @@
if ! ${c_ldso_paths_loaded} ; then
c_ldso_paths_loaded='true'
c_ldso_paths=()
- if [[ -r /etc/ld.so.conf ]] ; then
+ if [[ -r ${ROOT}etc/ld.so.conf ]] ; then
read_ldso_conf() {
local line p
for p ; do
@@ -84,14 +89,14 @@
case ${line} in
"#"*) ;;
"include "*) read_ldso_conf ${line#* } ;;
- *) c_ldso_paths+=( "${line}" ) ;;
+ *) c_ldso_paths+=( "${ROOT}${line#/}" ) ;;
esac
done <"${p}"
done
}
# the 'include' command is relative
- pushd /etc >/dev/null
- read_ldso_conf /etc/ld.so.conf
+ pushd "${ROOT}"etc >/dev/null
+ read_ldso_conf "${ROOT}"etc/ld.so.conf
popd >/dev/null
fi
fi
@@ -122,12 +127,15 @@
if [[ ${indent} -eq 0 ]] ; then
elf_specs=$(elf_specs "${resolved}")
interp=$(scanelf -qF '#F%i' "${resolved}")
+ [[ -n ${interp} ]] && interp="${ROOT}${interp#/}"
printf " (interpreter => ${interp:-none})"
if [[ -r ${interp} ]] ; then
# Extract the default lib paths out of the ldso.
- lib_paths_ldso=$(strings "${interp}" | grep '^/.*lib')
- lib_paths_ldso=${lib_paths_ldso//:/ }
+ lib_paths_ldso=$(
+ strings "${interp}" | \
+ sed -nr -e "/^\/.*lib/{s|^/?|${ROOT}|;s|/$||;s|/?:/?|\n${ROOT}|g;p}"
+ )
fi
interp=${interp##*/}
fi
@@ -158,11 +166,12 @@
SHOW_ALL=false
SET_X=false
-while getopts hax OPT ; do
+while getopts haxR: OPT ; do
case ${OPT} in
a) SHOW_ALL=true;;
x) SET_X=true;;
h) usage;;
+ R) ROOT="${OPTARG%/}/";;
?) usage 1;;
esac
done
^ permalink raw reply [flat|nested] 15+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.sh
@ 2012-11-10 7:19 Mike Frysinger (vapier)
0 siblings, 0 replies; 15+ messages in thread
From: Mike Frysinger (vapier) @ 2012-11-10 7:19 UTC (permalink / raw
To: gentoo-commits
vapier 12/11/10 07:19:35
Modified: lddtree.sh
Log:
lddtree: normalize linux osabi to sysv since they are compatible (with glibc) #442024
Revision Changes Path
1.14 pax-utils/lddtree.sh
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.sh?rev=1.14&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.sh?rev=1.14&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.sh?r1=1.13&r2=1.14
Index: lddtree.sh
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.sh,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- lddtree.sh 4 Nov 2012 07:26:24 -0000 1.13
+++ lddtree.sh 10 Nov 2012 07:19:35 -0000 1.14
@@ -2,7 +2,7 @@
# Copyright 2007-2012 Gentoo Foundation
# Copyright 2007-2012 Mike Frysinger <vapier@gentoo.org>
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.sh,v 1.13 2012/11/04 07:26:24 vapier Exp $
+# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.sh,v 1.14 2012/11/10 07:19:35 vapier Exp $
argv0=${0##*/}
@@ -32,7 +32,10 @@
}
elf_specs() {
- scanelf -BF '#F%a %M %D %I' "$1"
+ # With glibc, the NONE, SYSV, and LINUX OSABI's are compatible.
+ # NONE and SYSV are the same thing, so normalize LINUX to NONE. #442024
+ scanelf -BF '#F%a %M %D %I' "$1" | \
+ sed 's: LINUX$: NONE:'
}
lib_paths_fallback="${ROOT}lib* ${ROOT}usr/lib* ${ROOT}usr/local/lib*"
^ permalink raw reply [flat|nested] 15+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.sh
@ 2012-11-10 7:26 Mike Frysinger (vapier)
0 siblings, 0 replies; 15+ messages in thread
From: Mike Frysinger (vapier) @ 2012-11-10 7:26 UTC (permalink / raw
To: gentoo-commits
vapier 12/11/10 07:26:53
Modified: lddtree.sh
Log:
lddtree: add a -V (--version) flag
Revision Changes Path
1.15 pax-utils/lddtree.sh
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.sh?rev=1.15&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.sh?rev=1.15&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.sh?r1=1.14&r2=1.15
Index: lddtree.sh
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.sh,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- lddtree.sh 10 Nov 2012 07:19:35 -0000 1.14
+++ lddtree.sh 10 Nov 2012 07:26:53 -0000 1.15
@@ -2,7 +2,7 @@
# Copyright 2007-2012 Gentoo Foundation
# Copyright 2007-2012 Mike Frysinger <vapier@gentoo.org>
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.sh,v 1.14 2012/11/10 07:19:35 vapier Exp $
+# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.sh,v 1.15 2012/11/10 07:26:53 vapier Exp $
argv0=${0##*/}
@@ -19,12 +19,19 @@
Options:
-a Show all duplicated dependencies
-x Run with debugging
- -h Show this help output
-R <root> Use this ROOT filesystem tree
+ -h Show this help output
+ -V Show version information
EOF
exit ${1:-0}
}
+version() {
+ local id='$Id: lddtree.sh,v 1.15 2012/11/10 07:26:53 vapier Exp $'
+ id=${id##*,v }
+ exec echo "lddtree-${id% * Exp*}"
+}
+
error() {
echo "${argv0}: $*" 1>&2
ret=1
@@ -172,11 +179,12 @@
SHOW_ALL=false
SET_X=false
-while getopts haxR: OPT ; do
+while getopts haxVR: OPT ; do
case ${OPT} in
a) SHOW_ALL=true;;
x) SET_X=true;;
h) usage;;
+ V) version;;
R) ROOT="${OPTARG%/}/";;
?) usage 1;;
esac
^ permalink raw reply [flat|nested] 15+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.sh
@ 2013-01-02 17:37 Mike Frysinger (vapier)
0 siblings, 0 replies; 15+ messages in thread
From: Mike Frysinger (vapier) @ 2013-01-02 17:37 UTC (permalink / raw
To: gentoo-commits
vapier 13/01/02 17:37:27
Modified: lddtree.sh
Log:
lddtree.sh: fix by Loïc Yhuel for LD_LIBRARY_PATH processing #449718
Revision Changes Path
1.18 pax-utils/lddtree.sh
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.sh?rev=1.18&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.sh?rev=1.18&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.sh?r1=1.17&r2=1.18
Index: lddtree.sh
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.sh,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- lddtree.sh 15 Nov 2012 20:35:04 -0000 1.17
+++ lddtree.sh 2 Jan 2013 17:37:27 -0000 1.18
@@ -2,7 +2,7 @@
# Copyright 2007-2012 Gentoo Foundation
# Copyright 2007-2012 Mike Frysinger <vapier@gentoo.org>
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.sh,v 1.17 2012/11/15 20:35:04 vapier Exp $
+# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.sh,v 1.18 2013/01/02 17:37:27 vapier Exp $
argv0=${0##*/}
@@ -28,7 +28,7 @@
}
version() {
- local id='$Id: lddtree.sh,v 1.17 2012/11/15 20:35:04 vapier Exp $'
+ local id='$Id: lddtree.sh,v 1.18 2013/01/02 17:37:27 vapier Exp $'
id=${id##*,v }
exec echo "lddtree-${id% * Exp*}"
}
@@ -84,7 +84,7 @@
local p path=${LD_LIBRARY_PATH}
while : ; do
p=${path%%:*}
- check_paths "${elf}" "${path:-${PWD}}" && return 0
+ check_paths "${elf}" "${p:-${PWD}}" && return 0
[[ ${path} == *:* ]] || break
path=${path#*:}
done
^ permalink raw reply [flat|nested] 15+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.sh
@ 2013-01-22 2:12 Mike Frysinger (vapier)
0 siblings, 0 replies; 15+ messages in thread
From: Mike Frysinger (vapier) @ 2013-01-22 2:12 UTC (permalink / raw
To: gentoo-commits
vapier 13/01/22 02:12:35
Modified: lddtree.sh
Log:
lddtree.sh: fix whitespace in usage string
Revision Changes Path
1.19 pax-utils/lddtree.sh
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.sh?rev=1.19&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.sh?rev=1.19&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.sh?r1=1.18&r2=1.19
Index: lddtree.sh
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.sh,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- lddtree.sh 2 Jan 2013 17:37:27 -0000 1.18
+++ lddtree.sh 22 Jan 2013 02:12:35 -0000 1.19
@@ -2,7 +2,7 @@
# Copyright 2007-2012 Gentoo Foundation
# Copyright 2007-2012 Mike Frysinger <vapier@gentoo.org>
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.sh,v 1.18 2013/01/02 17:37:27 vapier Exp $
+# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.sh,v 1.19 2013/01/22 02:12:35 vapier Exp $
argv0=${0##*/}
@@ -20,7 +20,7 @@
-a Show all duplicated dependencies
-x Run with debugging
-R <root> Use this ROOT filesystem tree
- -l Display output in a flat format
+ -l Display output in a flat format
-h Show this help output
-V Show version information
EOF
@@ -28,7 +28,7 @@
}
version() {
- local id='$Id: lddtree.sh,v 1.18 2013/01/02 17:37:27 vapier Exp $'
+ local id='$Id: lddtree.sh,v 1.19 2013/01/22 02:12:35 vapier Exp $'
id=${id##*,v }
exec echo "lddtree-${id% * Exp*}"
}
^ permalink raw reply [flat|nested] 15+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.sh
@ 2013-04-05 22:45 Mike Frysinger (vapier)
0 siblings, 0 replies; 15+ messages in thread
From: Mike Frysinger (vapier) @ 2013-04-05 22:45 UTC (permalink / raw
To: gentoo-commits
vapier 13/04/05 22:45:48
Modified: lddtree.sh
Log:
lddtree.sh: add --no-auto-root behavior to match lddtree.py
Revision Changes Path
1.21 pax-utils/lddtree.sh
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.sh?rev=1.21&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.sh?rev=1.21&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.sh?r1=1.20&r2=1.21
Index: lddtree.sh
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.sh,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- lddtree.sh 5 Apr 2013 22:04:41 -0000 1.20
+++ lddtree.sh 5 Apr 2013 22:45:48 -0000 1.21
@@ -2,7 +2,7 @@
# Copyright 2007-2013 Gentoo Foundation
# Copyright 2007-2013 Mike Frysinger <vapier@gentoo.org>
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.sh,v 1.20 2013/04/05 22:04:41 vapier Exp $
+# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.sh,v 1.21 2013/04/05 22:45:48 vapier Exp $
argv0=${0##*/}
@@ -17,18 +17,19 @@
Usage: ${argv0} [options] <ELF file[s]>
Options:
- -a Show all duplicated dependencies
- -x Run with debugging
- -R <root> Use this ROOT filesystem tree
- -l Display output in a flat format
- -h Show this help output
- -V Show version information
+ -a Show all duplicated dependencies
+ -x Run with debugging
+ -R <root> Use this ROOT filesystem tree
+ --no-auto-root Do not automatically prefix input ELFs with ROOT
+ -l Display output in a flat format
+ -h Show this help output
+ -V Show version information
EOF
exit ${1:-0}
}
version() {
- local id='$Id: lddtree.sh,v 1.20 2013/04/05 22:04:41 vapier Exp $'
+ local id='$Id: lddtree.sh,v 1.21 2013/04/05 22:45:48 vapier Exp $'
id=${id##*,v }
exec echo "lddtree-${id% * Exp*}"
}
@@ -189,16 +190,23 @@
SHOW_ALL=false
SET_X=false
LIST=false
+AUTO_ROOT=true
-while getopts haxVR:l OPT ; do
+while getopts haxVR:l-: OPT ; do
case ${OPT} in
- a) SHOW_ALL=true;;
- x) SET_X=true;;
- h) usage;;
- V) version;;
- R) ROOT="${OPTARG%/}/";;
- l) LIST=true;;
- ?) usage 1;;
+ a) SHOW_ALL=true;;
+ x) SET_X=true;;
+ h) usage;;
+ V) version;;
+ R) ROOT="${OPTARG%/}/";;
+ l) LIST=true;;
+ -) # Long opts ftw.
+ case ${OPTARG} in
+ no-auto-root) AUTO_ROOT=false;;
+ *) usage 1;;
+ esac
+ ;;
+ ?) usage 1;;
esac
done
shift $((OPTIND - 1))
@@ -210,6 +218,9 @@
for elf ; do
unset lib_paths_ldso
unset c_last_needed_by
+ if ${AUTO_ROOT} && [[ ${elf} == /* ]] ; then
+ elf="${ROOT}${elf#/}"
+ fi
if [[ ! -e ${elf} ]] ; then
error "${elf}: file does not exist"
elif [[ ! -r ${elf} ]] ; then
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2013-04-05 22:45 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-10 7:26 [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.sh Mike Frysinger (vapier)
-- strict thread matches above, loose matches on Subject: below --
2013-04-05 22:45 Mike Frysinger (vapier)
2013-01-22 2:12 Mike Frysinger (vapier)
2013-01-02 17:37 Mike Frysinger (vapier)
2012-11-10 7:19 Mike Frysinger (vapier)
2012-11-04 7:20 Mike Frysinger (vapier)
2012-11-03 0:06 Mike Frysinger (vapier)
2011-03-23 2:23 Mike Frysinger (vapier)
2011-03-03 21:49 Ned Ludd (solar)
2011-03-03 21:05 Mike Frysinger (vapier)
2009-12-01 10:17 Mike Frysinger (vapier)
2009-12-01 10:16 Mike Frysinger (vapier)
2007-12-31 23:46 Mike Frysinger (vapier)
2007-12-31 23:36 Mike Frysinger (vapier)
2007-12-31 23:33 Mike Frysinger (vapier)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox