From: Tavis Ormandy <taviso@gmail.com>
To: gdb@sourceware.org
Subject: adding custom stabs symbols
Date: Wed, 3 Aug 2022 17:42:53 -0000 (UTC) [thread overview]
Message-ID: <tcec2s$io$1@ciao.gmane.io> (raw)
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
reply other threads:[~2022-08-03 17:43 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='tcec2s$io$1@ciao.gmane.io' \
--to=taviso@gmail.com \
--cc=gdb@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).