adding custom stabs symbols

Tavis Ormandy taviso@gmail.com
Wed Aug 3 17:42:53 GMT 2022


Hello, I tried asking this on the binutils list but thought I would try
here too.

I have a stripped binary I don't have the source for that I would
like to debug in gdb. I know where some functions and globals are, so I
thought a clever solution might be writing some .stabs statements in
gas, 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

https://sourceware.org/binutils/docs/as/Stab.html

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

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

That sort of works, if I assemble it (as -gstabs), then add-symbol-file
a.out, gdb knows about the address and type. The problem is it 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?

This is still better than nothing, at least I can put breakpoints on the
names and print globals, but is there a better way to accomplish what
I'm trying to do?

Tavis.

-- 
 _o)            $ lynx lock.cmpxchg8b.com
 /\\  _o)  _o)  $ finger taviso@sdf.org
_\_V _( ) _( )  @taviso



More information about the Gdb mailing list