summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2011-10-11 00:40:09 -0400
committerMike Frysinger <vapier@gentoo.org>2011-10-11 00:47:47 -0400
commitd4fdc3f5c04e556ce217e004ed461c9f05146c0f (patch)
treeef9aa20a34bc10b6c53798cc42843c7e20b5907b
parent12dc5c56c821336f02338e3374b97e55273aee3c (diff)
downloadportage-d4fdc3f5c04e556ce217e004ed461c9f05146c0f.tar.gz
portage-d4fdc3f5c04e556ce217e004ed461c9f05146c0f.tar.bz2
portage-d4fdc3f5c04e556ce217e004ed461c9f05146c0f.zip
prepstrip: extract buildid with readelf to avoid debugedit when possible
The readelf utility is much more common than debugedit. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
-rwxr-xr-xbin/ebuild-helpers/prepstrip32
1 files changed, 23 insertions, 9 deletions
diff --git a/bin/ebuild-helpers/prepstrip b/bin/ebuild-helpers/prepstrip
index 67ceeadb0..7a08ababb 100755
--- a/bin/ebuild-helpers/prepstrip
+++ b/bin/ebuild-helpers/prepstrip
@@ -26,10 +26,13 @@ if ${RESTRICT_strip} || ${FEATURES_nostrip} ; then
${FEATURES_installsources} || exit 0
fi
-STRIP=${STRIP:-${CHOST}-strip}
-type -P -- ${STRIP} > /dev/null || STRIP=strip
-OBJCOPY=${OBJCOPY:-${CHOST}-objcopy}
-type -P -- ${OBJCOPY} > /dev/null || OBJCOPY=objcopy
+# look up the tools we might be using
+for t in STRIP:strip OBJCOPY:objcopy READELF:readelf ; do
+ v=${t%:*} # STRIP
+ t=${t#*:} # strip
+ eval ${v}=\"${!v:-${CHOST}-${t}}\"
+ 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 ...
@@ -65,8 +68,15 @@ save_elf_sources() {
local x=$1
local inode=$(inode_var_name "$x")
[[ -n ${!inode} ]] && return 0
- debugedit -b "${WORKDIR}" -d "${prepstrip_sources_dir}" \
- -l "${T}"/debug.sources "${x}"
+
+ # since we're editing the ELF here, we should recompute the build-id
+ # (the -i flag below). save that output so we don't need to recompute
+ # it later on in the save_elf_debug step.
+ buildid=$(debugedit -i \
+ -b "${WORKDIR}" \
+ -d "${prepstrip_sources_dir}" \
+ -l "${T}"/debug.sources \
+ "${x}")
}
save_elf_debug() {
@@ -78,9 +88,6 @@ save_elf_debug() {
# dont save debug info twice
[[ ${x} == *".debug" ]] && return 0
- # this will recompute the build-id, but for now that's ok
- local buildid="$( ${debugedit_found} && debugedit -i "${x}" )"
-
mkdir -p "${y%/*}"
local inode=$(inode_var_name "$x")
@@ -95,6 +102,12 @@ save_elf_debug() {
chmod ${args} "${y}"
fi
+ # if we don't already have build-id from debugedit, look it up
+ if [[ -z ${buildid} ]] ; then
+ # convert the readelf output to something useful
+ buildid=$(${READELF} -x .note.gnu.build-id "${x}" 2>/dev/null \
+ | awk '$NF ~ /GNU/ { getline; printf $2$3$4$5; getline; print $2 }')
+ fi
if [[ -n ${buildid} ]] ; then
local buildid_dir="${D}usr/lib/debug/.build-id/${buildid:0:2}"
local buildid_file="${buildid_dir}/${buildid:2}"
@@ -165,6 +178,7 @@ do
# actually causes problems. install sources for all
# elf types though cause that stuff is good.
+ buildid=
if [[ ${f} == *"current ar archive"* ]] ; then
vecho " ${x:${#D}}"
if ${strip_this} ; then