Skip to content

How to separate debugging symbols from an ELF executable

License

Notifications You must be signed in to change notification settings

GabrielMajeri/separate-symbols

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Separate debugging symbols with ELF (Linux) binaries

This repository is a tutorial on how to separate the debugging symbols from the final executable, and still be able to debug it.

Requirements

Note: some of this tutorial also applies to MinGW.

Instructions

First, the executable is built, and it contains the debugging symbols.

clang -g main.c -o main

Then the debugging symbols are extracted into a new file.

objcopy --only-keep-debug main main.dbg

The final executable is stripped of debugging symbols.

objcopy --strip-debug main

Additionally, a debug link can be added to allow GDB to find the file with the debugging symbols.

objcopy --add-gnu-debuglink=main.dbg main

If everything works well GDB should say something like:

Reading symbols from main...Reading symbols from /some/directory/separate-symbols/main.dbg...done.
done.

You can also run GDB and add the file manually:

(gdb) exec-file main
(gdb) symbol-file main.dbg

Credits

Inspired by this answer on StackOverflow.

Also check the GDB manual.

About

How to separate debugging symbols from an ELF executable

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published