Created
May 31, 2024 15:57
-
-
Save jagannath-sahoo/b37055f2239355970b530d80cb141aa5 to your computer and use it in GitHub Desktop.
Compile and Strip Debug info from executable
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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