diff options
author | Thierry Vignaud <tv@mageia.org> | 2012-07-27 17:38:50 +0000 |
---|---|---|
committer | Thierry Vignaud <tv@mageia.org> | 2012-07-27 17:38:50 +0000 |
commit | e8cee3d3957786e8682ddf7077659575a2cf8052 (patch) | |
tree | 4d7470b2af92def5f6ffd4a1ee7e58b104b003c0 /find-debuginfo.sh | |
parent | 745375fc12c97c3560fed10a066a5cdc6f8cd457 (diff) | |
download | rpm-setup-e8cee3d3957786e8682ddf7077659575a2cf8052.tar rpm-setup-e8cee3d3957786e8682ddf7077659575a2cf8052.tar.gz rpm-setup-e8cee3d3957786e8682ddf7077659575a2cf8052.tar.bz2 rpm-setup-e8cee3d3957786e8682ddf7077659575a2cf8052.tar.xz rpm-setup-e8cee3d3957786e8682ddf7077659575a2cf8052.zip |
add support for mini debug packages (disabled by default)
(https://fedoraproject.org/wiki/Features/MiniDebugInfo)
Diffstat (limited to 'find-debuginfo.sh')
-rwxr-xr-x | find-debuginfo.sh | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/find-debuginfo.sh b/find-debuginfo.sh index 3427fdb..c2bc7df 100755 --- a/find-debuginfo.sh +++ b/find-debuginfo.sh @@ -2,7 +2,7 @@ #find-debuginfo.sh - automagically generate debug info and file list #for inclusion in an rpm spec file. # -# Usage: find-debuginfo.sh [--strict-build-id] [-g] [-r] +# Usage: find-debuginfo.sh [--strict-build-id] [-g] [-r] [-m] # [-o debugfiles.list] # [[-l filelist]... [-p 'pattern'] -o debuginfo.list] # [builddir] @@ -29,6 +29,9 @@ strip_g=false # with -r arg, pass --reloc-debug-sections to eu-strip. strip_r=false +# with -m arg, add minimal debuginfo to binary. +include_minidebug=false + # Barf on missing build IDs. strict=false @@ -43,6 +46,9 @@ while [ $# -gt 0 ]; do -g) strip_g=true ;; + -m) + include_minidebug=true + ;; -o) if [ -z "${lists[$nout]}" -a -z "${ptns[$nout]}" ]; then out=$2 @@ -106,6 +112,32 @@ strip_to_debug() [ -n "$DISABLE_DEBUG" ] || chmod 444 "$1" || exit } +add_minidebug() +{ + local debuginfo="$1" + local binary="$2" + + local dynsyms=`mktemp` + local funcsyms=`mktemp` + local keep_symbols=`mktemp` + local mini_debuginfo=`mktemp` + + # Extract the dynamic symbols from the main binary, there is no need to also have these + # in the normal symbol table + nm -D "$binary" --format=posix --defined-only | awk '{ print $1 }' | sort > "$dynsyms" + # Extract all the text (i.e. function) symbols from the debuginfo + nm "$debuginfo" --format=posix --defined-only | awk '{ if ($2 == "T" || $2 == "t") print $1 }' | sort > "$funcsyms" + # Keep all the function symbols not already in the dynamic symbol table + comm -13 "$dynsyms" "$funcsyms" > "$keep_symbols" + # Copy the full debuginfo, keeping only a minumal set of symbols and removing some unnecessary sections + objcopy -S --remove-section .gdb_index --remove-section .comment --keep-symbols="$keep_symbols" "$debuginfo" "$mini_debuginfo" &> /dev/null + #Inject the compressed data into the .gnu_debugdata section of the original binary + xz "$mini_debuginfo" + mini_debuginfo="${mini_debuginfo}.xz" + objcopy --add-section .gnu_debugdata="$mini_debuginfo" "$binary" + rm -f "$dynsyms" "$funcsyms" "$keep_symbols" "$mini_debuginfo" +} + # Make a relative symlink to $1 called $3$2 shopt -s extglob link_relative() @@ -272,6 +304,9 @@ while read nlinks inum f; do chmod u-w "$f" fi + $include_minidebug && add_minidebug "${debugfn}" "$f" + + if [ -n "$id" ]; then make_id_link "$id" "$dn/$(basename $f)" make_id_link "$id" "/usr/lib/debug$dn/$bn" .debug |