gdb allows you to put a program’s debugging information in a ?le separate from the executable itself, in a way that allows gdb to find and load the debugging information automatically. Since debugging information can be very large — sometimes larger than the executable code itself — some systems distribute debugging information for their executables in separate files, which users can install only when they need to debug a problem.
If an executable’s debugging information has been extracted to a separate file, the executable should contain a debug link giving the name of the debugging information file(with no directory components), and a checksum of its contents.
1. Link the executable as normal. Assuming that is is called "foo":
gcc -g -o foo foo.c
2. Run "objcopy --only-keep-debug foo foo.dbg" to create a file containing the debugging info.
3. Run "objcopy --strip-debug foo" to create a stripped executable
4. Run "objcopy --add-gnu-debuglink=foo.dbg foo" to add a link to the debugging info into the stripped executable.
5. Run "objdump -s -j .gnu_debuglink fp" to verify debug link:
brian@debian:~/ctest$ objdump -s -j .gnu_debuglink fp
fp: file format elf32-i386
Contents of section .gnu_debuglink:
0000 66702e64 62670000 67b83207 fp.dbg..g.2.
brian@debian:~/ctest$
阅读(1385) | 评论(0) | 转发(0) |