Use subsystem to distinguish between pei-arm-little and pei-arm-wince-little
authorMark Harmstone <mark@harmstone.com>
Wed, 11 Jan 2023 18:32:04 +0000 (18:32 +0000)
committerMark Harmstone <mark@harmstone.com>
Wed, 18 Jan 2023 03:56:35 +0000 (03:56 +0000)
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
bfd/peicode.h

index 6391dd50c918c52169625d6f02609a25e1a65511..914ee0bb07f24c005d756a3fbccaa15bac102863 100644 (file)
@@ -28,4 +28,6 @@
 
 #define LOCAL_LABEL_PREFIX "."
 
+#define WINCE
+
 #include "pei-arm.c"
index 68ec3a37c89ded2302cedd2852c6e7f1b9e819e6..22ffec989f294a81bfd6a206e5793dcf07b44387 100644 (file)
@@ -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)
        {