2011-05-16 18:07:44 +02:00
|
|
|
--- ./scripts/find-debuginfo.sh.orig 2010-12-03 12:11:57.000000000 +0000
|
|
|
|
+++ ./scripts/find-debuginfo.sh 2011-05-11 14:46:18.000000000 +0000
|
|
|
|
@@ -127,6 +127,20 @@ debug_link()
|
2008-09-16 01:28:45 +02:00
|
|
|
link_relative "$t" "$l" "$RPM_BUILD_ROOT"
|
|
|
|
}
|
|
|
|
|
|
|
|
+# Compare two binaries but ignore the .note.gnu.build-id section
|
|
|
|
+elfcmp()
|
|
|
|
+{
|
|
|
|
+ local tmp1=$(mktemp -t ${1##*/}.XXXXXX)
|
|
|
|
+ local tmp2=$(mktemp -t ${2##*/}.XXXXXX)
|
|
|
|
+
|
2008-12-15 11:56:27 +01:00
|
|
|
+ objcopy -R .note.gnu.build-id -R .gnu_debuglink $1 $tmp1
|
|
|
|
+ objcopy -R .note.gnu.build-id -R .gnu_debuglink $2 $tmp2
|
2008-09-16 01:28:45 +02:00
|
|
|
+ cmp -s $tmp1 $tmp2
|
|
|
|
+ local res=$?
|
|
|
|
+ rm -f $tmp1 $tmp2
|
|
|
|
+ return $res
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
# Make a build-id symlink for id $1 with suffix $3 to file $2.
|
|
|
|
make_id_link()
|
|
|
|
{
|
2011-05-16 18:07:44 +02:00
|
|
|
@@ -145,7 +159,7 @@ make_id_link()
|
2008-09-16 01:28:45 +02:00
|
|
|
local other=$(readlink -m "$root_idfile")
|
|
|
|
other=${other#$RPM_BUILD_ROOT}
|
|
|
|
if cmp -s "$root_idfile" "$RPM_BUILD_ROOT$file" ||
|
|
|
|
- eu-elfcmp -q "$root_idfile" "$RPM_BUILD_ROOT$file" 2> /dev/null; then
|
|
|
|
+ elfcmp "$root_idfile" "$RPM_BUILD_ROOT$file" ; then
|
|
|
|
# Two copies. Maybe one has to be setuid or something.
|
|
|
|
echo >&2 "*** WARNING: identical binaries are copied, not linked:"
|
|
|
|
echo >&2 " $file"
|
2011-05-16 18:07:44 +02:00
|
|
|
@@ -174,12 +188,18 @@ strict_error=ERROR
|
2008-09-12 20:37:28 +02:00
|
|
|
$strict || strict_error=WARNING
|
2006-12-19 00:17:44 +01:00
|
|
|
|
|
|
|
# Strip ELF binaries
|
2008-09-12 20:37:28 +02:00
|
|
|
-find "$RPM_BUILD_ROOT" ! -path "${debugdir}/*.debug" -type f \
|
|
|
|
- \( -perm -0100 -or -perm -0010 -or -perm -0001 \) \
|
|
|
|
- -print |
|
|
|
|
-file -N -f - | sed -n -e 's/^\(.*\):[ ]*.*ELF.*, not stripped/\1/p' |
|
2008-09-16 01:28:45 +02:00
|
|
|
-xargs --no-run-if-empty stat -c '%h %D_%i %n' |
|
2009-02-16 17:11:16 +01:00
|
|
|
+find $RPM_BUILD_ROOT ! -path "${debugdir}/*.debug" -type f \( -perm +111 -or -name "*.so*" -or -name "*.ko" \) -print 0 | sort -z |
|
2008-09-16 01:28:45 +02:00
|
|
|
+xargs --no-run-if-empty -0 stat -c '%h %D_%i %n' |
|
2008-09-12 20:37:28 +02:00
|
|
|
while read nlinks inum f; do
|
|
|
|
+ case $(objdump -h $f 2>/dev/null | egrep -o '(debug[\.a-z_]*|gnu.version)') in
|
|
|
|
+ *debuglink*) continue ;;
|
|
|
|
+ *debug*) ;;
|
|
|
|
+ *gnu.version*)
|
|
|
|
+ echo "WARNING: "`echo $f | sed -e "s,^$RPM_BUILD_ROOT/*,/,"`" is already stripped!"
|
|
|
|
+ continue
|
|
|
|
+ ;;
|
|
|
|
+ *) continue ;;
|
|
|
|
+ esac
|
|
|
|
get_debugfn "$f"
|
|
|
|
[ -f "${debugfn}" ] && continue
|
2006-12-19 00:17:44 +01:00
|
|
|
|
2011-05-16 18:07:44 +02:00
|
|
|
@@ -200,8 +220,11 @@ while read nlinks inum f; do
|
2008-09-12 20:37:28 +02:00
|
|
|
fi
|
2006-12-19 00:17:44 +01:00
|
|
|
|
2008-09-12 20:37:28 +02:00
|
|
|
echo "extracting debug info from $f"
|
2008-10-06 16:13:13 +02:00
|
|
|
- id=$(/usr/lib/rpm/debugedit -b "$RPM_BUILD_DIR" -d /usr/src/debug \
|
|
|
|
- -i -l "$SOURCEFILE" "$f") || exit
|
2008-09-12 20:37:28 +02:00
|
|
|
+ mode=$(stat -c %a "$f")
|
|
|
|
+ chmod +w "$f"
|
2008-10-06 16:13:13 +02:00
|
|
|
+ id=$($(DEBUGEDIT=$(which debugedit 2>/dev/null); \
|
|
|
|
+ echo ${DEBUGEDIT:-/usr/lib/rpm/debugedit}) -b "$RPM_BUILD_DIR" \
|
|
|
|
+ -d /usr/src/debug -i -l "$SOURCEFILE" "$f") || exit
|
2008-09-12 20:37:28 +02:00
|
|
|
if [ -z "$id" ]; then
|
2008-10-06 16:13:13 +02:00
|
|
|
echo >&2 "*** ${strict_error}: No build ID note found in $f"
|
|
|
|
$strict && exit 2
|
2011-05-16 18:07:44 +02:00
|
|
|
@@ -218,13 +241,25 @@ while read nlinks inum f; do
|
2008-09-12 20:37:28 +02:00
|
|
|
esac
|
2006-12-19 00:17:44 +01:00
|
|
|
|
2008-09-12 20:37:28 +02:00
|
|
|
mkdir -p "${debugdn}"
|
|
|
|
- if test -w "$f"; then
|
|
|
|
- strip_to_debug "${debugfn}" "$f"
|
|
|
|
- else
|
|
|
|
- chmod u+w "$f"
|
|
|
|
- strip_to_debug "${debugfn}" "$f"
|
|
|
|
- chmod u-w "$f"
|
|
|
|
- fi
|
|
|
|
+ objcopy --only-keep-debug $f $debugfn || :
|
|
|
|
+ (
|
|
|
|
+ shopt -s extglob
|
|
|
|
+ strip_option="--strip-all"
|
|
|
|
+ case "$f" in
|
|
|
|
+ *.ko)
|
|
|
|
+ strip_option="--strip-debug" ;;
|
|
|
|
+ *$STRIP_KEEP_SYMTAB*)
|
|
|
|
+ if test -n "$STRIP_KEEP_SYMTAB"; then
|
|
|
|
+ strip_option="--strip-debug"
|
|
|
|
+ fi
|
|
|
|
+ ;;
|
|
|
|
+ esac
|
|
|
|
+ if test "$NO_DEBUGINFO_STRIP_DEBUG" = true ; then
|
|
|
|
+ strip_option=
|
|
|
|
+ fi
|
|
|
|
+ objcopy --add-gnu-debuglink=$debugfn -R .comment -R .GCC.command.line $strip_option $f
|
|
|
|
+ chmod $mode $f
|
|
|
|
+ ) || :
|
2006-12-19 00:17:44 +01:00
|
|
|
|
2008-09-12 20:37:28 +02:00
|
|
|
if [ -n "$id" ]; then
|
|
|
|
make_id_link "$id" "$dn/$(basename $f)"
|
2011-05-16 18:07:44 +02:00
|
|
|
@@ -253,12 +288,14 @@ if [ -s "$SOURCEFILE" ]; then
|
2008-09-12 20:37:28 +02:00
|
|
|
# stupid cpio creates new directories in mode 0700, fixup
|
|
|
|
find "${RPM_BUILD_ROOT}/usr/src/debug" -type d -print0 |
|
|
|
|
xargs --no-run-if-empty -0 chmod a+rx
|
|
|
|
+ find "${RPM_BUILD_ROOT}/usr/src/debug" -type f -print0 |
|
|
|
|
+ xargs --no-run-if-empty -0 chmod a+r
|
|
|
|
fi
|
2007-04-23 23:21:13 +02:00
|
|
|
|
2008-09-12 20:37:28 +02:00
|
|
|
if [ -d "${RPM_BUILD_ROOT}/usr/lib" -o -d "${RPM_BUILD_ROOT}/usr/src" ]; then
|
|
|
|
((nout > 0)) ||
|
|
|
|
test ! -d "${RPM_BUILD_ROOT}/usr/lib" ||
|
|
|
|
- (cd "${RPM_BUILD_ROOT}/usr/lib"; find debug -type d) |
|
|
|
|
+ (cd "${RPM_BUILD_ROOT}/usr/lib"; test ! -d debug || find debug -type d) |
|
|
|
|
sed 's,^,%dir /usr/lib/,' >> "$LISTFILE"
|
2008-04-09 18:18:03 +02:00
|
|
|
|
2008-09-12 20:37:28 +02:00
|
|
|
(cd "${RPM_BUILD_ROOT}/usr"
|