[Bug other/82857] libbacktrace: please support binaries stripped with dwz -m (following the .gnu_debugaltlink)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82857 --- Comment #5 from Tom de Vries --- Created attachment 44962 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44962=edit WIP patch, handles DW_FORM_GNU_strp_alt With this patch, the test-case from comment 1 passes: ... Non-stripped 1 Stripped 0 Stripped with debuglink 1 Stripped with debuglink to compressed with objcopy 1 Stripped with debuglink to compressed with dwz 1 Stripped with debuglink to compressed with dwz -m 1 ... In more detail, we get the backtrace with function name 'main', and the full path for bt.c: ... 0x400eff main /data/gcc_versions/devel/bt.c:20 0x7fe303fcaf49 __libc_start_main ../csu/libc-start.c:308 0x400da9 ??? ../sysdeps/x86_64/start.S:120 0x ??? ???:0 ...
[Bug other/82857] libbacktrace: please support binaries stripped with dwz -m (following the .gnu_debugaltlink)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82857 --- Comment #4 from Tom de Vries --- Created attachment 44957 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44957=edit WIP patch, follows .gnu_debugaltlink
[Bug other/82857] libbacktrace: please support binaries stripped with dwz -m (following the .gnu_debugaltlink)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82857 --- Comment #3 from Tom de Vries --- The dwz man shows: ... -M NAME --multifile-name NAME Specify the name of the common file that should be put into the .gnu_debugaltlink section alongside with its build ID. By default dwz puts there the argument of the -m option. ... The debugaltlink looks like: ... $ objdump -s a.out.debug Contents of section .gnu_debugaltlink: 636f6d6d 6f6e2e64 65627567 00583730 common.debug.X70 0010 8a56187b b2abdbbd 93929f3f f623059e .V.{...?.#.. 0020 2f / ... and given that this is the buildid of common.debug: ... $ file common.debug common.debug: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), BuildID[sha1]=5837308a56187bb2abdbbd93929f3ff623059e2f, with debug_info, not stripped ... indeed .gnu_debugaltlink looks like the zero-terminated "common.debug" string followed by the buildid.
[Bug other/82857] libbacktrace: please support binaries stripped with dwz -m (following the .gnu_debugaltlink)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82857 Ian Lance Taylor changed: What|Removed |Added CC||ian at airs dot com --- Comment #2 from Ian Lance Taylor --- Are there any docs for the dwz -m format or for .gnu.debugaltlink?
[Bug other/82857] libbacktrace: please support binaries stripped with dwz -m (following the .gnu_debugaltlink)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82857 Tom de Vries changed: What|Removed |Added Status|UNCONFIRMED |NEW Last reconfirmed||2018-11-01 CC||vries at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #1 from Tom de Vries --- Test-case: ... $ cat bt.c #include "backtrace.h" int main (void) { struct backtrace_state *state = backtrace_create_state ("./a.out", 0, NULL, NULL); backtrace_print (state, 0, stderr); return 0; } ... Test script: ... $ cat test.sh #!/bin/sh ### rm -Rf a.out ./a.out.debug ### src=bt.c pwd=$(pwd -P) gcc_src=$pwd/src gcc_build=$pwd/build CFLAGS="-I $gcc_src/libbacktrace" LDFLAGS="-lbacktrace -L $gcc_build/libbacktrace/.libs/" gcc $src -O0 -g $CFLAGS $LDFLAGS ### echo "Non-stripped" ./a.out 2>&1 | grep -c /bt.c ### cp a.out a.out.debug strip --only-keep-debug a.out.debug cp a.out.debug a.out.debug.saved ### objcopy --strip-debug ./a.out #strip a.out echo "Stripped" ./a.out 2>&1 | grep -c /bt.c ### objcopy --add-gnu-debuglink=a.out.debug ./a.out echo "Stripped with debuglink" ./a.out 2>&1 | grep -c /bt.c ### objcopy a.out.debug --compress-debug-sections=zlib # We need to reset the debuglink, because the checksum has changed objcopy -R .gnu_debuglink ./a.out objcopy --add-gnu-debuglink=a.out.debug ./a.out echo "Stripped with debuglink to compressed with objcopy" ./a.out 2>&1 | grep -c /bt.c ### cp a.out.debug.saved a.out.debug dwz a.out.debug # We need to reset the debuglink, because the checksum has changed objcopy -R .gnu_debuglink ./a.out objcopy --add-gnu-debuglink=a.out.debug ./a.out echo "Stripped with debuglink to compressed with dwz" ./a.out 2>&1 | grep -c /bt.c ### cp a.out.debug.saved a.out.debug cp a.out.debug.saved a.out.2.debug dwz -m common.debug a.out.debug a.out.2.debug # We need to reset the debuglink, because the checksum has changed objcopy -R .gnu_debuglink ./a.out objcopy --add-gnu-debuglink=a.out.debug ./a.out echo "Stripped with debuglink to compressed with dwz -m" ./a.out 2>&1 | grep -c /bt.c ... Test output: ... $ ./test.sh Non-stripped 1 Stripped 0 Stripped with debuglink 1 Stripped with debuglink to compressed with objcopy 1 Stripped with debuglink to compressed with dwz 1 Stripped with debuglink to compressed with dwz -m 0 ... Confirmed on master.