public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* BFD interface for getting PE import section data
@ 2020-03-07 18:11 Simon Marchi
  2020-03-23 17:18 ` Nick Clifton
  0 siblings, 1 reply; 6+ messages in thread
From: Simon Marchi @ 2020-03-07 18:11 UTC (permalink / raw)
  To: Binutils

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-03-26 10:48 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-07 18:11 BFD interface for getting PE import section data Simon Marchi
2020-03-23 17:18 ` Nick Clifton
2020-03-23 17:33   ` Simon Marchi
2020-03-25 11:58     ` Nick Clifton
2020-03-25 13:48       ` Simon Marchi
2020-03-26 10:48         ` Nick Clifton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).