Alex Rivera | Logout

Adding own symbols for file in gdb

Asked 2011-03-30T15:18:15.730
11

Ok.. so I'm working doing debugging on x86 with gdb. The particular files in question are stripped so I have no symbols from the binary itself. I have no access to the source code, but a rough idea of what's happening under the hood.

My asm knowledge is just about good enough to decide the purpose of a function and decide its purpose. Thus I can decide on my own appropriate names for functions after looking at them for a while, but I would like to be able to inject these as symbols so that once decided upon they can be used in later debugging..

Does anybody know how to load custom symbols into gdb? I've considered recompiling gdb with and adding an extra command to the UI to allow loading of a symbol at an address.. I was wondering if it would be possible to create a dummy object file with the symbols I've defined and then load it using add-symbol-file? Or would it be possible to compile a c program with dummy function and so how force them to be the correct size and at the correct location and then simply load that??

Edit
Report

1 Answer

0

I wouldn't look for a solution in gdb. I would instead try to figure out how to put the symbols back to the binary. Logically, if it is possible to strip the symbols, then it must be possible to add them back. I'd expect linker (ld) or some other tool to allow that.

I recommend to check all the tools in binutils package (objdump, objcopy, nm, ld, ...) - they are capable of many almost miraculous things!

Tomas

answered 2011-03-30T15:33:19.173

Your Answer