fix: pacman 3.5.4() addon script - (copy addin etc files keeping permissions) - templ...
[cmdllinux.git] / scripts / _gdb_compress_debug.sh
bloba4537a449da6a71bf1215a21326a008a5cdb2255
1 # From gdb info
3 # Extract the dynamic symbols from the main binary, there is no need
4 # to also have these in the normal symbol table.
5 nm -D $1 --format=posix --defined-only \
6 | awk '{ print $1 }' | sort > dynsyms
8 # Extract all the text (i.e. function) symbols from the debuginfo.
9 # (Note that we actually also accept "D" symbols, for the benefit
10 # of platforms like PowerPC64 that use function descriptors.)
11 nm $1 --format=posix --defined-only \
12 | awk '{ if ($2 == "T" || $2 == "t" || $2 == "D") print $1 }' \
13 | sort > funcsyms
15 # Keep all the function symbols not already in the dynamic symbol
16 # table.
17 comm -13 dynsyms funcsyms > keep_symbols
19 # Separate full debug info into debug binary.
20 objcopy --only-keep-debug $1 debug
22 # Copy the full debuginfo, keeping only a minimal set of symbols and
23 # removing some unnecessary sections.
24 objcopy -S --remove-section .gdb_index --remove-section .comment \
25 --keep-symbols=keep_symbols debug mini_debuginfo
27 # Drop the full debug info from the original binary.
28 strip --strip-all -R .comment $1
30 # Inject the compressed data into the .gnu_debugdata section of the
31 # original binary.
32 xz -c mini_debuginfo > mini_debuginfo.xz
33 objcopy --add-section .gnu_debugdata=mini_debuginfo.xz $1