BFD interface for getting PE import section data

Simon Marchi simon.marchi@polymtl.ca
Mon Mar 23 17:33:09 GMT 2020


On 2020-03-23 1:18 p.m., Nick Clifton wrote:
> Hi Simon,
> 
>   [Sorry for the long delay in replying to your email].
> 
>> However, this sounds like some facility BFD should provide.  Is there a way to get
>> this information that I'm missing?
> 
> Hmm - only if you have access to the BFD library's internal headers.  (Which
> I assume you do not want to have to do).

Hi Nick,

In fact, since this is in GDB, we do have access to BFD's internal header.  It's
not ideal, but it works.  Even before my work on this, there was an instance of
accessing this internal structure:

  https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=gdb/amd64-windows-tdep.c;h=6d5076d1c4371becf4b122a5393ede780cd0f37a;hb=HEAD#l954

I got inspiration from that code and I also implemented what I wanted by accessing
that internal structure, this is what I ended up doing:

  https://sourceware.org/git/?p=binutils-gdb.git;a=blobdiff;f=gdb/windows-tdep.c;h=31b7b57005df67f5b02e98e92b568a0cfaea97d0;hp=e02b1ceed3873e3d4906a8df62964258a777f2a4;hb=8db52437243e251c01e352cdb325bc9ace578e7c;hpb=5982a56ab9d161923e75712fcb358824748ea4ba

> Would a new BFD library function help ?  One that took a BFD and returned a
> pointer to its internal_extra_pe_aouthdr structure (as defined in include/coff/internal.h)
> or NULL if the BFD does not have one ?  Providing a function like that should
> be fairly simple to implement.

I think it would help a bit, in that GDB wouldn't have to import a BFD internal header
just for this.

Simon



More information about the Binutils mailing list