creating debuginfo manually [slightly offtopic]

Akos PASZTORY <[email protected]>
Newsgroups gmane.comp.gdb.devel
Message-ID <CAJwHcF7qmFBwjZhJAmK9vKW2_BsMyWZFcbcH=pqsYmd30VR6zA@mail.gmail.com>
I was debugging some reverse engineering challenges and wondered: is
it possible to define debuginfo semi-manually?

Let's say I have a stripped binary but I already learned that there is
an array of structs at location 0x0804abcd.
I would like to teach that also to gdb, probably via symbol-file.  (Or?)

I was thinking how to create this debuginfo file.  I came up with this ugly way:

$ cat dummy.c
struct chunkdesc {
    void *offset;
    unsigned int len;
};

struct chunkdesc chunks[3];
void main() {}
$ cc -m32 -g -O0 -Wl,--defsym=chunks=0x0804abcd dummy.c -o dummy.elf

and use "symbol-file dummy.elf" in gdb.  This seems to work for this
case, but I cannot define function prototypes this way.

Is there any better way to do this?
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.