3 # this function is slight modification of the one used in RPM
4 # found at https://bugzilla.redhat.com/show_bug.cgi?id=834073
5 # written by Alexander Larsson <alexl@redhat.com>
8 debuginfo="$1" ## we don't have separate debuginfo file
14 mini_debuginfo=`mktemp`
16 # Extract the dynamic symbols from the main binary, there is no need to also have these
17 # in the normal symbol table
18 nm -D "$binary" --format=posix --defined-only | awk '{ print $1 }' | sort > "$dynsyms"
19 # Extract all the text (i.e. function) symbols from the debuginfo
20 nm "$debuginfo" --format=posix --defined-only | awk '{ if ($2 == "T" || $2 == "t") print $1 }' | sort > "$funcsyms"
21 # Keep all the function symbols not already in the dynamic symbol table
22 comm -13 "$dynsyms" "$funcsyms" > "$keep_symbols"
23 # Copy the full debuginfo, keeping only a minumal set of symbols and removing some unnecessary sections
24 objcopy -S --remove-section .gdb_index --remove-section .comment --keep-symbols="$keep_symbols" "$debuginfo" "$mini_debuginfo" &> /dev/null
25 #Inject the compressed data into the .gnu_debugdata section of the original binary
27 mini_debuginfo="${mini_debuginfo}.xz"
28 objcopy --add-section .gnu_debugdata="$mini_debuginfo" "$binary"
29 rm -f "$dynsyms" "$funcsyms" "$keep_symbols" "$mini_debuginfo"
31 strip "$binary" ## throw away the symbol table
36 TEMPDIR=`mktemp --tmpdir -d libunwind-test-XXXXXXXXXX`
37 trap "rm -r -- $TEMPDIR" EXIT
39 cp crasher $TEMPDIR/crasher
40 if [ "$1" = "-minidebuginfo" ]; then
41 add_minidebug $TEMPDIR/crasher
48 ./crasher backing_files
50 COREFILE=$TEMPDIR/core*
52 # magic option -testcase enables checking for the specific contents of the stack
53 ./test-coredump-unwind $COREFILE -testcase `cat $TEMPDIR/backing_files`