How to lookup a symbol for vma using BFD?

Dmitry Smirnov divis1969@gmail.com
Wed Aug 6 15:13:00 GMT 2008


Hi,

I need to implement the following functionality:
Using an ELF file, I need to find the symbol (perhaps, not a
function!) for some vma.
Let's suppose I have an array defined as

static const char myArray[] = { <some bytes> };

So, I need to find a symbol (myArray) using an address that lays
within its data.

I was trying to find any example or guess by learning bfd.h (and even
elf32-arm.c) but unsuccessfully.

Could you please advice how to implement this? Can I do it using bfd.h
only as the API or should I use other APIs?

P.S. the only method I see now is to iterate over symbols, find the
nearest lower vma (since asymbol does not contain size info). At the
same time DWAR2 or ELF info contains the size info and some attributes
I would like to know. But do not know how to retrieve it.

WBR,
Dmitry



More information about the Binutils mailing list