This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
importing symbols from unsupported BFD target
- From: Tavis Ormandy <taviso at sdf dot lonestar dot org>
- To: gdb at sources dot redhat dot com
- Date: Tue, 30 Jun 2009 18:59:06 +0200
- Subject: importing symbols from unsupported BFD target
Hello, I'm trying to setup remote debugging of a partially supported BFD
target. Accessing the target via a GDB stub works perfectly, and I can
examine memory, set breakpoints, etc, but I'm stuck without symbols as BFD
cannot read the symbol table from the input file.
I feel pretty close to getting this working, but I must be missing a minor
detail.
So on the unsupported target system using the native vendor-provided tools,
I export a list of symbols, their (approximate) sizes, and absolute
addresses. Now I need to make gdb understand these, so my first thought was
trying to create a relocatable ELF with a bunch of abs sym definitions and
loading it via symbol-file (I'm happy without type information and so on for
now).
This basically works, `info address symname`, `b symname`, `x/i symname` all
work, but `info symbol address` fails, and stacktraces, info breakpoints,
etc, etc are not symbolised.
Can anyone suggest what I might be missing?
Thanks, Tavis.
Some more detailed information:
The target system is Windows, and I'm trying to debug a kernel issue from a
Linux x86 host using the VMWare GDB guest stub.
So on the guest I can create a list of symbols and convert them into
gas-style absolute symbol declarations:
$ kd -z c:\\windows\\memory.dmp -c 'x /a nt!*;q' \
| bash kd2as.sh > ntoskrnlsyms.s
This command generates a list of declarations from the vendor's native
debugger output, the result looks like this:
...
.global NtCreateFile
.set NtCreateFile, 0x8056e2fc
.size NtCreateFile, 426
.type NtCreateFile, @function
.func NtCreateFile
.endfunc
.global NtCreateNamedPipeFile
.set NtCreateNamedPipeFile, 0x8056e336
.size NtCreateNamedPipeFile, 58
.type NtCreateNamedPipeFile, @function
.func NtCreateNamedPipeFile
.endfunc
...
Currently i mark all symbols as STT_FUNC, which is fine for now, and i can
assemble it on Linux, which generates symbols like so:
$ as -gstabs+ -o ntoskrnlsyms.o ntoskrnlsyms.s
$ readelf --syms ntoskrnlsyms.o | grep NtCreateFile
4993: 8056e2fc 426 FUNC GLOBAL DEFAULT ABS NtCreateFile
gdb accepts it, and it works:
$ gdb -q
(gdb) show version
GNU gdb Fedora (6.8-27.el5)
(gdb) target remote localhost:8832
[New Thread 1]
0x806d0d34 in ?? ()
(gdb) symbol-file ntoskrnlsyms.o
(gdb) info address NtCreateFile
Symbol "NtCreateFile" is a function at address 0x8056e2fc.
(gdb) x/2i NtCreateFile
0x8056e2fc: mov edi,edi
0x8056e2fe: push ebp
(gdb) b NtCreateFile
Breakpoint 1 at 0x8056e301
etc, etc, however:
(gdb) info symbol 0x8056e2fc
No symbol matches 0x8056e2fc.
(gdb) bt
#0 0x8056e301 in ?? ()
#1 0xedb88b44 in ?? ()
#2 0x8053d648 in ?? ()
...
Which is limiting the usefulness of having symbols, if anyone can spot the
problem I'd really appreciate a pointer.
Thanks, Tavis.
--
-------------------------------------
taviso@sdf.lonestar.org | finger me for my pgp key.
-------------------------------------------------------