Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jagannath-sahoo/b37055f2239355970b530d80cb141aa5 to your computer and use it in GitHub Desktop.
Save jagannath-sahoo/b37055f2239355970b530d80cb141aa5 to your computer and use it in GitHub Desktop.
Compile and Strip Debug info from executable
Compile with debug information:
gcc -g -o main main.c
Separate the debug information:
objcopy --only-keep-debug main main.debug
or
cp main main.debug
strip --only-keep-debug main.debug
Strip debug information from origin file:
objcopy --strip-debug main
or
strip --strip-debug --strip-unneeded main
debug by debuglink mode:
objcopy --add-gnu-debuglink main.debug main
gdb main
You can also use exec file and symbol file separatly:
gdb -s main.debug -e main
or
gdb
(gdb) exec-file main
(gdb) symbol-file main.debug
For details:
(gdb) help exec-file
(gdb) help symbol-file
Ref:
https://sourceware.org/gdb/onlinedocs/gdb/Files.html#Files https://sourceware.org/gdb/onlinedocs/gdb/Separate-Debug-Files.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment