|
|
5523e9 |
--- rpm-4.10.0/macros.in 2012-06-11 11:16:21.216952339 +0200
|
|
|
5523e9 |
+++ rpm-4.10.0/macros.in.minidebug 2012-06-11 11:16:23.686912455 +0200
|
|
|
5523e9 |
@@ -175,7 +175,7 @@
|
|
|
5523e9 |
# the script. See the script for details.
|
|
|
5523e9 |
#
|
|
|
5523e9 |
%__debug_install_post \
|
|
|
5523e9 |
- %{_rpmconfigdir}/find-debuginfo.sh %{?_missing_build_ids_terminate_build:--strict-build-id} %{?_find_debuginfo_dwz_opts} %{?_find_debuginfo_opts} "%{_builddir}/%{?buildsubdir}"\
|
|
|
5523e9 |
+ %{_rpmconfigdir}/find-debuginfo.sh %{?_missing_build_ids_terminate_build:--strict-build-id} %{?_include_minidebuginfo:-m} %{?_find_debuginfo_dwz_opts} %{?_find_debuginfo_opts} "%{_builddir}/%{?buildsubdir}"\
|
|
|
5523e9 |
%{nil}
|
|
|
5523e9 |
|
|
|
5523e9 |
# Template for debug information sub-package.
|
|
|
5523e9 |
@@ -418,6 +418,12 @@ package or when debugging this package.\
|
|
|
5523e9 |
#%_missing_build_ids_terminate_build 1
|
|
|
5523e9 |
|
|
|
5523e9 |
#
|
|
|
5523e9 |
+# Include minimal debug information in build binaries.
|
|
|
5523e9 |
+# Requires _enable_debug_packages.
|
|
|
5523e9 |
+#
|
|
|
5523e9 |
+#%_include_minidebuginfo 1
|
|
|
5523e9 |
+
|
|
|
5523e9 |
+#
|
|
|
5523e9 |
# Use internal dependency generator rather than external helpers?
|
|
|
5523e9 |
%_use_internal_dependency_generator 1
|
|
|
5523e9 |
|
|
|
5523e9 |
--- rpm-4.10.0/scripts/find-debuginfo.sh 2012-06-11 11:16:09.698138273 +0200
|
|
|
5523e9 |
+++ rpm-4.10.0/scripts/find-debuginfo.sh.minidebug 2012-06-11 11:16:13.399078526 +0200
|
|
|
5523e9 |
@@ -2,7 +2,7 @@
|
|
|
5523e9 |
#find-debuginfo.sh - automagically generate debug info and file list
|
|
|
5523e9 |
#for inclusion in an rpm spec file.
|
|
|
5523e9 |
#
|
|
|
5523e9 |
-# Usage: find-debuginfo.sh [--strict-build-id] [-g] [-r]
|
|
|
5523e9 |
+# Usage: find-debuginfo.sh [--strict-build-id] [-g] [-r] [-m]
|
|
|
5523e9 |
# [-o debugfiles.list]
|
|
|
5523e9 |
# [--run-dwz] [--dwz-low-mem-die-limit N]
|
|
|
5523e9 |
# [--dwz-max-die-limit N]
|
|
|
5523e9 |
@@ -29,6 +29,9 @@ strip_g=false
|
|
|
5523e9 |
# with -r arg, pass --reloc-debug-sections to eu-strip.
|
|
|
5523e9 |
strip_r=false
|
|
|
5523e9 |
|
|
|
5523e9 |
+# with -m arg, add minimal debuginfo to binary.
|
|
|
5523e9 |
+include_minidebug=false
|
|
|
5523e9 |
+
|
|
|
5523e9 |
# Barf on missing build IDs.
|
|
|
5523e9 |
strict=false
|
|
|
5523e9 |
|
|
|
5523e9 |
@@ -43,6 +46,9 @@ while [ $# -gt 0 ]; do
|
|
|
5523e9 |
-g)
|
|
|
5523e9 |
strip_g=true
|
|
|
5523e9 |
;;
|
|
|
5523e9 |
+ -m)
|
|
|
5523e9 |
+ include_minidebug=true
|
|
|
5523e9 |
+ ;;
|
|
|
5523e9 |
-o)
|
|
|
5523e9 |
if [ -z "${lists[$nout]}" -a -z "${ptns[$nout]}" ]; then
|
|
|
5523e9 |
out=$2
|
|
|
5523e9 |
@@ -105,6 +111,32 @@ strip_to_debug()
|
|
|
5523e9 |
chmod 444 "$1" || exit
|
|
|
5523e9 |
}
|
|
|
5523e9 |
|
|
|
5523e9 |
+add_minidebug()
|
|
|
5523e9 |
+{
|
|
|
5523e9 |
+ local debuginfo="$1"
|
|
|
5523e9 |
+ local binary="$2"
|
|
|
5523e9 |
+
|
|
|
5523e9 |
+ local dynsyms=`mktemp`
|
|
|
5523e9 |
+ local funcsyms=`mktemp`
|
|
|
5523e9 |
+ local keep_symbols=`mktemp`
|
|
|
5523e9 |
+ local mini_debuginfo=`mktemp`
|
|
|
5523e9 |
+
|
|
|
5523e9 |
+ # Extract the dynamic symbols from the main binary, there is no need to also have these
|
|
|
5523e9 |
+ # in the normal symbol table
|
|
|
5523e9 |
+ nm -D "$binary" --format=posix --defined-only | awk '{ print $1 }' | sort > "$dynsyms"
|
|
|
5523e9 |
+ # Extract all the text (i.e. function) symbols from the debuginfo
|
|
|
5523e9 |
+ nm "$debuginfo" --format=posix --defined-only | awk '{ if ($2 == "T" || $2 == "t") print $1 }' | sort > "$funcsyms"
|
|
|
5523e9 |
+ # Keep all the function symbols not already in the dynamic symbol table
|
|
|
5523e9 |
+ comm -13 "$dynsyms" "$funcsyms" > "$keep_symbols"
|
|
|
5523e9 |
+ # Copy the full debuginfo, keeping only a minumal set of symbols and removing some unnecessary sections
|
|
|
5523e9 |
+ objcopy -S --remove-section .gdb_index --remove-section .comment --keep-symbols="$keep_symbols" "$debuginfo" "$mini_debuginfo" &> /dev/null
|
|
|
5523e9 |
+ #Inject the compressed data into the .gnu_debugdata section of the original binary
|
|
|
5523e9 |
+ xz "$mini_debuginfo"
|
|
|
5523e9 |
+ mini_debuginfo="${mini_debuginfo}.xz"
|
|
|
5523e9 |
+ objcopy --add-section .gnu_debugdata="$mini_debuginfo" "$binary"
|
|
|
5523e9 |
+ rm -f "$dynsyms" "$funcsyms" "$keep_symbols" "$mini_debuginfo"
|
|
|
5523e9 |
+}
|
|
|
5523e9 |
+
|
|
|
5523e9 |
# Make a relative symlink to $1 called $3$2
|
|
|
5523e9 |
shopt -s extglob
|
|
|
5523e9 |
link_relative()
|
|
|
5523e9 |
@@ -260,6 +292,9 @@ while read nlinks inum f; do
|
|
|
5523e9 |
chmod u-w "$f"
|
|
|
5523e9 |
fi
|
|
|
5523e9 |
|
|
|
5523e9 |
+ $include_minidebug && add_minidebug "${debugfn}" "$f"
|
|
|
5523e9 |
+
|
|
|
5523e9 |
+
|
|
|
5523e9 |
if [ -n "$id" ]; then
|
|
|
5523e9 |
make_id_link "$id" "$dn/$(basename $f)"
|
|
|
5523e9 |
make_id_link "$id" "/usr/lib/debug$dn/$bn" .debug
|