1 |
The readelf utility is much more common than debugedit. |
2 |
|
3 |
Signed-off-by: Mike Frysinger <vapier@g.o> |
4 |
--- |
5 |
bin/ebuild-helpers/prepstrip | 32 +++++++++++++++++++++++--------- |
6 |
1 files changed, 23 insertions(+), 9 deletions(-) |
7 |
|
8 |
diff --git a/bin/ebuild-helpers/prepstrip b/bin/ebuild-helpers/prepstrip |
9 |
index 67ceead..7a08aba 100755 |
10 |
--- a/bin/ebuild-helpers/prepstrip |
11 |
+++ b/bin/ebuild-helpers/prepstrip |
12 |
@@ -26,10 +26,13 @@ if ${RESTRICT_strip} || ${FEATURES_nostrip} ; then |
13 |
${FEATURES_installsources} || exit 0 |
14 |
fi |
15 |
|
16 |
-STRIP=${STRIP:-${CHOST}-strip} |
17 |
-type -P -- ${STRIP} > /dev/null || STRIP=strip |
18 |
-OBJCOPY=${OBJCOPY:-${CHOST}-objcopy} |
19 |
-type -P -- ${OBJCOPY} > /dev/null || OBJCOPY=objcopy |
20 |
+# look up the tools we might be using |
21 |
+for t in STRIP:strip OBJCOPY:objcopy READELF:readelf ; do |
22 |
+ v=${t%:*} # STRIP |
23 |
+ t=${t#*:} # strip |
24 |
+ eval ${v}=\"${!v:-${CHOST}-${t}}\" |
25 |
+ type -P -- ${!v} >/dev/null || eval ${v}=${t} |
26 |
+done |
27 |
|
28 |
# We'll leave out -R .note for now until we can check out the relevance |
29 |
# of the section when it has the ALLOC flag set on it ... |
30 |
@@ -65,8 +68,15 @@ save_elf_sources() { |
31 |
local x=$1 |
32 |
local inode=$(inode_var_name "$x") |
33 |
[[ -n ${!inode} ]] && return 0 |
34 |
- debugedit -b "${WORKDIR}" -d "${prepstrip_sources_dir}" \ |
35 |
- -l "${T}"/debug.sources "${x}" |
36 |
+ |
37 |
+ # since we're editing the ELF here, we should recompute the build-id |
38 |
+ # (the -i flag below). save that output so we don't need to recompute |
39 |
+ # it later on in the save_elf_debug step. |
40 |
+ buildid=$(debugedit -i \ |
41 |
+ -b "${WORKDIR}" \ |
42 |
+ -d "${prepstrip_sources_dir}" \ |
43 |
+ -l "${T}"/debug.sources \ |
44 |
+ "${x}") |
45 |
} |
46 |
|
47 |
save_elf_debug() { |
48 |
@@ -78,9 +88,6 @@ save_elf_debug() { |
49 |
# dont save debug info twice |
50 |
[[ ${x} == *".debug" ]] && return 0 |
51 |
|
52 |
- # this will recompute the build-id, but for now that's ok |
53 |
- local buildid="$( ${debugedit_found} && debugedit -i "${x}" )" |
54 |
- |
55 |
mkdir -p "${y%/*}" |
56 |
|
57 |
local inode=$(inode_var_name "$x") |
58 |
@@ -95,6 +102,12 @@ save_elf_debug() { |
59 |
chmod ${args} "${y}" |
60 |
fi |
61 |
|
62 |
+ # if we don't already have build-id from debugedit, look it up |
63 |
+ if [[ -z ${buildid} ]] ; then |
64 |
+ # convert the readelf output to something useful |
65 |
+ buildid=$(${READELF} -x .note.gnu.build-id "${x}" 2>/dev/null \ |
66 |
+ | awk '$NF ~ /GNU/ { getline; printf $2$3$4$5; getline; print $2 }') |
67 |
+ fi |
68 |
if [[ -n ${buildid} ]] ; then |
69 |
local buildid_dir="${D}usr/lib/debug/.build-id/${buildid:0:2}" |
70 |
local buildid_file="${buildid_dir}/${buildid:2}" |
71 |
@@ -165,6 +178,7 @@ do |
72 |
# actually causes problems. install sources for all |
73 |
# elf types though cause that stuff is good. |
74 |
|
75 |
+ buildid= |
76 |
if [[ ${f} == *"current ar archive"* ]] ; then |
77 |
vecho " ${x:${#D}}" |
78 |
if ${strip_this} ; then |
79 |
-- |
80 |
1.7.6.1 |