Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* importing symbols from unsupported BFD target
@ 2009-06-30 17:05 Tavis Ormandy
  2009-06-30 17:17 ` Daniel Jacobowitz
  0 siblings, 1 reply; 3+ messages in thread
From: Tavis Ormandy @ 2009-06-30 17:05 UTC (permalink / raw)
  To: gdb

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.
-------------------------------------------------------


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-06-30 20:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-30 17:05 importing symbols from unsupported BFD target Tavis Ormandy
2009-06-30 17:17 ` Daniel Jacobowitz
2009-06-30 20:54   ` Tavis Ormandy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox