making stabs visible to gdb

Tavis Ormandy
Wed Aug 3 05:11:46 GMT 2022

Hello, I have a stripped binary I don't have the source for that I would
like to debug in gdb. I thought writing some .stabs statements in gas
would be a nice easy way to record the symbols I know about, like this:

.equ N_FUN, 0x24
.equ N_PSYM, 0xa0
.stabs "example:f-11", N_FUN, 0, 0, 0x8005bba
.stabs "foo:p*-8", N_PSYM, 0, 0, 8
.stabs "bar:p-10", N_PSYM, 0, 0, 12

I think this describes a function like this at address 0x8005bba:

void example(unsigned int *foo, unsigned long bar)

If I assemble that (as -gstabs), then add-symbol-file a.out, gdb knows
about it but won't resolve it in backtraces.

(gdb) add-symbol-file a.out
(gdb) info address example
Symbol "example" is a function at address 0x8005bba.
(gdb) pt example
type = void (unsigned int *, unsigned long)
(gdb) bt
#1  0x0000000008005bba in ?? ()     <-- unresolved

What am I doing wrong?

Also, is there a better way to accomplish what I'm trying to do?


 _o)            $ lynx
 /\\  _o)  _o)  $ finger
_\_V _( ) _( )  @taviso

More information about the Binutils mailing list