BFD interface for getting PE import section data
Simon Marchi
simon.marchi@polymtl.ca
Sat Mar 7 18:11:38 GMT 2020
Hi,
In order for GDB to be able to differentiate Cygwin executables from non-Cygwin
Windows executables (in this context [1]), I'd like to access the data of the
import section of the PE executables, more specifically the DLL names. We would
check if the cygwin DLL is present in this list. I was able to look up and parse
enough of the .idata section to get the imported DLL names, using the official doc:
https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#the-idata-section
as well as this page:
https://blog.kowalczyk.info/articles/pefileformat.html#9ccef823-67e7-4372-9172-045d7b1fb006
However, this sounds like some facility BFD should provide. Is there a way to get
this information that I'm missing? I found this code, that's used by "objdump -p"
to print the content of the import tables:
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob;f=bfd/peXXigen.c;h=e42d646552a0ca1e856e082256cd3d943b54ddf0;hb=HEAD#l1261
However, that code is tightly coupled with the printed, so it's not practical to
use it from GDB. In order to avoid code duplication, I suppose that this code could
be refactored to provide this information through some programmatic interface, which
both GDB and this printing code would use. However, that's a bit too much for me to
chew, since I'm not familiar with BFD development.
Any pointers would be appreciated. Thanks!
Simon
[1] https://sourceware.org/ml/gdb-patches/2020-03/msg00195.html
More information about the Binutils
mailing list