alexl
alexl

Reputation: 1914

how to put debug symbols in ar files

how to put debug symbols in ar files

when I run gdb then type symbol-file somelib.a it says 'somelib.a': can't read symbols: File format not recognized.

it did work however for the .o file that made up the .a file

I compiled with gcc -c -g somefile.c

Upvotes: 1

Views: 2481

Answers (1)

ams
ams

Reputation: 25599

Static libraries are not run-time files, and so not interesting to the debugger. The debug info would normally have been pulled out of them and inserted into the final binary at link time.

If you think about it, it's not possible (or meaningful) to load symbols from multiple unlinked .o files either: they would all have the same base address (usually zero) and that wouldn't be helpful. The .a file contains multiple unlinked .o files and would have the exact same problem.

If you've striped your binary you should have kept a corresponding debug file for that (see strip --only-keep-debug), not the libraries that went into it. Only executable binaries and shared libraries have debug info with meaningful addresses in it.

Upvotes: 2

Related Questions