summaryrefslogtreecommitdiffstats
path: root/bin/ebuild-helpers
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2011-10-11 00:49:48 -0400
committerMike Frysinger <vapier@gentoo.org>2011-10-11 10:18:48 -0400
commit51579fb34c19519a585ce2d052a270b6d84a2d97 (patch)
treedfddba9df824215a0bdb69acda945579d972b510 /bin/ebuild-helpers
parentd4fdc3f5c04e556ce217e004ed461c9f05146c0f (diff)
downloadportage-51579fb34c19519a585ce2d052a270b6d84a2d97.tar.gz
portage-51579fb34c19519a585ce2d052a270b6d84a2d97.tar.bz2
portage-51579fb34c19519a585ce2d052a270b6d84a2d97.zip
prepstrip: add support for elfutils strip
If people use strip from the elfutils package, take advantage of some of its neat features (like splitting + stripping in one step). Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'bin/ebuild-helpers')
-rwxr-xr-xbin/ebuild-helpers/prepstrip64
1 files changed, 46 insertions, 18 deletions
diff --git a/bin/ebuild-helpers/prepstrip b/bin/ebuild-helpers/prepstrip
index 7a08ababb..7f158c29d 100755
--- a/bin/ebuild-helpers/prepstrip
+++ b/bin/ebuild-helpers/prepstrip
@@ -34,10 +34,26 @@ for t in STRIP:strip OBJCOPY:objcopy READELF:readelf ; do
type -P -- ${!v} >/dev/null || eval ${v}=${t}
done
-# We'll leave out -R .note for now until we can check out the relevance
-# of the section when it has the ALLOC flag set on it ...
-export SAFE_STRIP_FLAGS="--strip-unneeded"
-export PORTAGE_STRIP_FLAGS=${PORTAGE_STRIP_FLAGS-${SAFE_STRIP_FLAGS} -R .comment}
+# Figure out what tool set we're using to strip stuff
+unset SAFE_STRIP_FLAGS DEF_STRIP_FLAGS SPLIT_STRIP_FLAGS
+case $(${STRIP} --version 2>/dev/null) in
+*elfutils*) # dev-libs/elfutils
+ # elfutils default behavior is always safe, so don't need to specify
+ # any flags at all
+ SAFE_STRIP_FLAGS=""
+ DEF_STRIP_FLAGS="--remove-comment"
+ SPLIT_STRIP_FLAGS="-f"
+ ;;
+*GNU*) # sys-devel/binutils
+ # We'll leave out -R .note for now until we can check out the relevance
+ # of the section when it has the ALLOC flag set on it ...
+ SAFE_STRIP_FLAGS="--strip-unneeded"
+ DEF_STRIP_FLAGS="-R .comment"
+ SPLIT_STRIP_FLAGS=
+ ;;
+esac
+: ${PORTAGE_STRIP_FLAGS=${SAFE_STRIP_FLAGS} ${DEF_STRIP_FLAGS}}
+
prepstrip_sources_dir=/usr/src/debug/${CATEGORY}/${PF}
type -P debugedit >/dev/null && debugedit_found=true || debugedit_found=false
@@ -95,8 +111,12 @@ save_elf_debug() {
ln "${D}usr/lib/debug/${!inode:${#D}}.debug" "$y"
else
eval $inode=\$x
- ${OBJCOPY} --only-keep-debug "${x}" "${y}"
- ${OBJCOPY} --add-gnu-debuglink="${y}" "${x}"
+ if [[ -e ${T}/prepstrip.split.debug ]] ; then
+ mv "${T}"/prepstrip.split.debug "${y}"
+ else
+ ${OBJCOPY} --only-keep-debug "${x}" "${y}"
+ ${OBJCOPY} --add-gnu-debuglink="${y}" "${x}"
+ fi
local args="a-x,o-w"
[[ -g ${x} || -u ${x} ]] && args+=",go-r"
chmod ${args} "${y}"
@@ -117,6 +137,24 @@ save_elf_debug() {
fi
}
+process_elf() {
+ local x=$1 strip_flags=${*:2}
+
+ vecho " ${x:${#D}}"
+ save_elf_sources "${x}"
+
+ if ${strip_this} ; then
+ # see if we can split & strip at the same time
+ if [[ -n ${SPLIT_STRIP_FLAGS} ]] ; then
+ ${STRIP} ${strip_flags} -f "${T}"/prepstrip.split.debug "${x}"
+ save_elf_debug "${x}"
+ else
+ save_elf_debug "${x}"
+ ${STRIP} ${strip_flags} "${x}"
+ fi
+ fi
+}
+
# The existance of the section .symtab tells us that a binary is stripped.
# We want to log already stripped binaries, as this may be a QA violation.
# They prevent us from getting the splitdebug data.
@@ -186,19 +224,9 @@ do
${STRIP} -g "${x}"
fi
elif [[ ${f} == *"SB executable"* || ${f} == *"SB shared object"* ]] ; then
- vecho " ${x:${#D}}"
- save_elf_sources "${x}"
- if ${strip_this} ; then
- save_elf_debug "${x}"
- ${STRIP} ${PORTAGE_STRIP_FLAGS} "${x}"
- fi
+ process_elf "${x}" ${PORTAGE_STRIP_FLAGS}
elif [[ ${f} == *"SB relocatable"* ]] ; then
- vecho " ${x:${#D}}"
- save_elf_sources "${x}"
- if ${strip_this} ; then
- [[ ${x} == *.ko ]] && save_elf_debug "${x}"
- ${STRIP} ${SAFE_STRIP_FLAGS} "${x}"
- fi
+ process_elf "${x}" ${SAFE_STRIP_FLAGS}
fi
done