public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@polymtl.ca>
To: Binutils <binutils@sourceware.org>
Subject: BFD interface for getting PE import section data
Date: Sat, 7 Mar 2020 13:11:38 -0500	[thread overview]
Message-ID: <35bcce03-10f0-4e11-3d96-40a3d59cc27e@polymtl.ca> (raw)

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

             reply	other threads:[~2020-03-07 18:16 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-07 18:11 Simon Marchi [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=35bcce03-10f0-4e11-3d96-40a3d59cc27e@polymtl.ca \
    --to=simon.marchi@polymtl.ca \
    --cc=binutils@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).