This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Trying to use libbfd to lookup symbol offset in PE/COFF (Windows) library.
- From: Dave Korn <dave dot korn dot cygwin at gmail dot com>
- To: Zac Salwasser <zsalwasser at gmail dot com>
- Cc: binutils at sourceware dot org
- Date: Fri, 23 Jul 2010 15:59:49 +0100
- Subject: Re: Trying to use libbfd to lookup symbol offset in PE/COFF (Windows) library.
- References: <AANLkTilHk9wVug2wDsYrLpwkmz8vhgMlzHdd2S_MfNxB@mail.gmail.com>
On 22/07/2010 16:56, Zac Salwasser wrote:
> Hi, I apologize if this should have been obvious to me, but I'd like
> to use libbfd to take a library symbol and get the symbol offset in
> return, specifically using Windows PE/COFF libraries. I've had a hard
> time finding any function that promises to do this or something
> similar, but I know that the capability is there, because I'm not
> asking for any information you can't get from objdump -x.
>
> So my first question is, is there a function or function(s) in the
> libbfd front-end that will get me this information?
See "2.7.1 Reading symbols" in the bfd manual / info page for an example of
using the bfd_canonicalize_symtab call. This reads the whole symbol table and
you have to scan it manually for the one you're looking for; there isn't AFAIK
a BFD interface to look up a single symbol. If you're proposing adding such
an API to BFD, that sounds like a pretty reasonable idea to me.
cheers,
DaveK
--
(*) -
http://sourceware.org/binutils/docs-2.20/bfd/Reading-Symbols.html
(**) -
http://sourceware.org/binutils/docs-2.20/bfd/symbol-handling-functions.html#index-bfd_005fcanonicalize_005fsymtab-64