public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Mark Harmstone <mark@harmstone.com>
To: binutils@sourceware.org
Cc: Mark Harmstone <mark@harmstone.com>
Subject: [PATCH] Use subsystem to distinguish between pei-arm-little and pei-arm-wince-little
Date: Wed, 11 Jan 2023 18:32:04 +0000	[thread overview]
Message-ID: <20230111183204.11600-1-mark@harmstone.com> (raw)

Running objdump against a 32-bit ARM PE file currently needs
disambiguation, as it gets picked up by both pei-arm-little and
pei-arm-wince-little.

This adds a check in pe_bfd_object_p so that the subsystem in the PE
header is used to do the disambiguation for us, so that WinCE images get
assigned to pei-arm-wince-little, and everything else to pei-arm-little.

---
 bfd/pei-arm-wince.c |  2 ++
 bfd/peicode.h       | 15 +++++++++++++++
 2 files changed, 17 insertions(+)

diff --git a/bfd/pei-arm-wince.c b/bfd/pei-arm-wince.c
index 6391dd50c91..914ee0bb07f 100644
--- a/bfd/pei-arm-wince.c
+++ b/bfd/pei-arm-wince.c
@@ -28,4 +28,6 @@
 
 #define LOCAL_LABEL_PREFIX "."
 
+#define WINCE
+
 #include "pei-arm.c"
diff --git a/bfd/peicode.h b/bfd/peicode.h
index 68ec3a37c89..22ffec989f2 100644
--- a/bfd/peicode.h
+++ b/bfd/peicode.h
@@ -1528,6 +1528,21 @@ pe_bfd_object_p (bfd * abfd)
       bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a);
 
       struct internal_extra_pe_aouthdr *a = &internal_a.pe;
+
+#ifdef ARM
+      /* Use Subsystem to distinguish between pei-arm-little and
+	 pei-arm-wince-little.  */
+#ifdef WINCE
+      if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI)
+#else
+      if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI)
+#endif
+	{
+	  bfd_set_error (bfd_error_wrong_format);
+	  return NULL;
+	}
+#endif
+
       if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment
 	  || a->SectionAlignment >= 0x80000000)
 	{
-- 
2.38.2


             reply	other threads:[~2023-01-11 18:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-11 18:32 Mark Harmstone [this message]
2023-01-17 14:01 ` 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=20230111183204.11600-1-mark@harmstone.com \
    --to=mark@harmstone.com \
    --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).