summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Ludd <solar@gentoo.org>2005-12-15 14:58:24 +0000
committerNed Ludd <solar@gentoo.org>2005-12-15 14:58:24 +0000
commitb359a5fef3a5a17524487f7bb91ff23f9ba373ba (patch)
tree422269904e0599f5e349805c789628da23a63187 /bin/prepstrip
parentferringb says: i pity the fool who doesnt use better style (diff)
downloadportage-multirepo-b359a5fef3a5a17524487f7bb91ff23f9ba373ba.tar.gz
portage-multirepo-b359a5fef3a5a17524487f7bb91ff23f9ba373ba.tar.bz2
portage-multirepo-b359a5fef3a5a17524487f7bb91ff23f9ba373ba.zip
- initial commit of split elf debug code
svn path=/main/trunk/; revision=2374
Diffstat (limited to 'bin/prepstrip')
-rwxr-xr-xbin/prepstrip71
1 files changed, 35 insertions, 36 deletions
diff --git a/bin/prepstrip b/bin/prepstrip
index eadc5b24..e86e5fe3 100755
--- a/bin/prepstrip
+++ b/bin/prepstrip
@@ -5,44 +5,43 @@
if [ "${FEATURES//*nostrip*/true}" == "true" ] || [ "${RESTRICT//*nostrip*/true}" == "true" ] ; then
echo "nostrip"
- STRIP="/bin/false"
- PORTAGE_STRIP_FLAGS=""
-else
- STRIP=${STRIP:-${CHOST}-strip}
- type -p -- ${STRIP} > /dev/null || STRIP=strip
- PORTAGE_STRIP_FLAGS=${PORTAGE_STRIP_FLAGS:---strip-unneeded}
+ exit 0
fi
+STRIP="${STRIP:-${CHOST}-strip}"
+type -p -- ${STRIP} > /dev/null || STRIP=strip
+
+PORTAGE_STRIP_FLAGS=${PORTAGE_STRIP_FLAGS:---strip-unneeded}
+
banner=1
-retval=0
-
-for x in "$@" ; do
- if [ -d "${x}" ]; then
- # We only want files. So make a pass for each directory and call again.
- find "${x}" -type f \( -perm -0100 -or -perm -0010 -or -perm -0001 -or -name '*.so' -or -name '*.so.*' \) -print0 |
- $XARGS -0 -n500 prepstrip
- else
- if [ ${banner} -eq 1 ] ; then
- echo "strip: ${STRIP} ${PORTAGE_STRIP_FLAGS}"
- banner=0
- fi
-
- f=$(file "${x}") || continue
- [ -z "${f}" ] && continue
-
- if [ -z "${f/*current ar archive*/}" ]; then
- echo " ${x:${#D}:${#x}}"
- ${STRIP} -g "${x}"
- fi
- if [ -z "${f/*SB executable*/}" ]; then
- echo " ${x:${#D}:${#x}}"
- ${STRIP} "${x}"
- fi
- if [ -z "${f/*SB shared object*/}" ]; then
- echo " ${x:${#D}:${#x}}"
- ${STRIP} ${PORTAGE_STRIP_FLAGS} "${x}"
- fi
+
+save_elf_debug() {
+ local x=$1
+ local y="${D}/usr/lib/debug/${x:${#D}:${#x}}"
+
+ [ "${FEATURES//*splitdebug*/true}" != "true" ] && return 0
+
+ mkdir -p $(dirname ${y})
+ ${CHOST}-objcopy --only-keep-debug ${x} ${y}.debug
+ ${CHOST}-objcopy --add-gnu-debuglink=${y}.debug ${x}
+}
+
+for x in $(scanelf -yRBF%F $@) $(for y in "$@"; do find $y -type f -name '*.a' -print0 ; done); do
+ if [ ${banner} -eq 1 ] ; then
+ echo "strip: ${STRIP} ${PORTAGE_STRIP_FLAGS}"
+ banner=0
fi
-done
-exit ${retval}
+ f=$(file "${x}") || continue
+ [ -z "${f}" ] && continue
+
+ if [ -z "${f/*current ar archive*/}" ]; then
+ echo " ${x:${#D}:${#x}}"
+ ${STRIP} -g "${x}"
+ fi
+ if [ -z "${f/*SB executable*/}" ] || [ -z "${f/*SB shared object*/}" ]; then
+ echo " ${x:${#D}:${#x}}"
+ save_elf_debug "${x}"
+ ${STRIP} ${PORTAGE_STRIP_FLAGS} "${x}"
+ fi
+done