]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
LD/PE: Remove remains of MIPS target support
authorMaciej W. Rozycki <macro@orcam.me.uk>
Mon, 13 Oct 2025 21:02:30 +0000 (22:02 +0100)
committerMaciej W. Rozycki <macro@orcam.me.uk>
Mon, 13 Oct 2025 21:02:30 +0000 (22:02 +0100)
Support for ECOFF MIPS targets, including `mips*-*-pe*' among others,
has been removed from GAS and LD with commit e8044f355dc9 ("Remove gas
and ld support for MIPS ECOFF"),
<https://inbox.sourceware.org/binutils/8761x65bzx.fsf@talisman.default/>.
However bits in PEI-format DLL support code have been left behind.

Remove the relevant pieces then, originally from commit 344a211f9995
("Add support for WinCE based toolchains."), including MIPS architecture
parts and HIGHADJ relocation support in particular.  Retain code for LOW
relocation however, even though included with said commit, as it remains
usable by ARM, i386 and x86-64 targets.

Add test cases for LOW, HIGHLOW, and DIR64 relocations handled by code
being modified.  The MCore target currently fails to produce a .reloc
image section owing to missing support, so XFAIL the HIGHLOW test.

ld/pe-dll.c
ld/testsuite/ld-pe/image-fixup-16.d [new file with mode: 0644]
ld/testsuite/ld-pe/image-fixup-16.s [new file with mode: 0644]
ld/testsuite/ld-pe/image-fixup-32.d [new file with mode: 0644]
ld/testsuite/ld-pe/image-fixup-32.s [new file with mode: 0644]
ld/testsuite/ld-pe/image-fixup-64.d [new file with mode: 0644]
ld/testsuite/ld-pe/image-fixup-64.s [new file with mode: 0644]
ld/testsuite/ld-pe/pe.exp

index d10838293a090e7a45a020294ff539684b3974b5..853425dc287b86669fda65526ed5d09b9c15d598 100644 (file)
@@ -251,7 +251,6 @@ enum
   PE_ARCH_none,
   PE_ARCH_i386,
   PE_ARCH_sh,
-  PE_ARCH_mips,
   PE_ARCH_arm,
   PE_ARCH_arm_wince,
   PE_ARCH_aarch64,
@@ -341,16 +340,6 @@ static pe_details_type pe_detail_list[] =
     false,
     autofilter_symbollist_generic
   },
-  {
-    "pei-mips",
-    "pe-mips",
-    34 /* MIPS_R_RVA */,
-    ~0, 0, ~0, /* none */
-    PE_ARCH_mips,
-    bfd_arch_mips,
-    false,
-    autofilter_symbollist_generic
-  },
   {
     "pei-arm-little",
     "pe-arm-little",
@@ -1729,15 +1718,6 @@ generate_reloc (bfd *abfd, struct bfd_link_info *info)
                      reloc_data[total_relocs].type = IMAGE_REL_BASED_LOW;
                      total_relocs++;
                      break;
-                   case BITS_AND_SHIFT (16, 16):
-                     reloc_data[total_relocs].type = IMAGE_REL_BASED_HIGHADJ;
-                     /* FIXME: we can't know the symbol's right value
-                        yet, but we probably can safely assume that
-                        CE will relocate us in 64k blocks, so leaving
-                        it zero is safe.  */
-                     reloc_data[total_relocs].extra = 0;
-                     total_relocs++;
-                     break;
                    case BITS_AND_SHIFT (26, 2):
                      reloc_data[total_relocs].type =
                         IMAGE_REL_BASED_ARM_MOV32;
@@ -1791,9 +1771,6 @@ generate_reloc (bfd *abfd, struct bfd_link_info *info)
        }
 
       reloc_sz += 2;
-
-      if (reloc_data[i].type == IMAGE_REL_BASED_HIGHADJ)
-       reloc_sz += 2;
     }
 
   reloc_sz = (reloc_sz + 3) & ~3;      /* 4-byte align.  */
@@ -2340,18 +2317,6 @@ static const unsigned char jmp_sh_bytes[] =
   0x01, 0xd0, 0x02, 0x60, 0x2b, 0x40, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00
 };
 
-/* _function:
-       lui     $t0,<high:__imp_function>
-       lw      $t0,<low:__imp_function>
-       jr      $t0
-       nop                              */
-
-static const unsigned char jmp_mips_bytes[] =
-{
-  0x00, 0x00, 0x08, 0x3c,  0x00, 0x00, 0x08, 0x8d,
-  0x08, 0x00, 0x00, 0x01,  0x00, 0x00, 0x00, 0x00
-};
-
 static const unsigned char jmp_arm_bytes[] =
 {
   0x00, 0xc0, 0x9f, 0xe5,      /* ldr  ip, [pc] */
@@ -2414,10 +2379,6 @@ make_one (def_file_export *exp, bfd *parent, bool include_jmp_stub)
          jmp_bytes = jmp_sh_bytes;
          jmp_byte_count = sizeof (jmp_sh_bytes);
          break;
-       case PE_ARCH_mips:
-         jmp_bytes = jmp_mips_bytes;
-         jmp_byte_count = sizeof (jmp_mips_bytes);
-         break;
        case PE_ARCH_arm:
        case PE_ARCH_arm_wince:
          jmp_bytes = jmp_arm_bytes;
@@ -2504,11 +2465,6 @@ make_one (def_file_export *exp, bfd *parent, bool include_jmp_stub)
        case PE_ARCH_sh:
          quick_reloc (abfd, 8, BFD_RELOC_32, 2);
          break;
-       case PE_ARCH_mips:
-         quick_reloc (abfd, 0, BFD_RELOC_HI16_S, 2);
-         quick_reloc (abfd, 0, BFD_RELOC_LO16, 0); /* MIPS_R_PAIR */
-         quick_reloc (abfd, 4, BFD_RELOC_LO16, 2);
-         break;
        case PE_ARCH_arm:
        case PE_ARCH_arm_wince:
          quick_reloc (abfd, 8, BFD_RELOC_32, 2);
diff --git a/ld/testsuite/ld-pe/image-fixup-16.d b/ld/testsuite/ld-pe/image-fixup-16.d
new file mode 100644 (file)
index 0000000..b874294
--- /dev/null
@@ -0,0 +1,16 @@
+#name: PE-COFF 16-bit image fixup
+#source: image-fixup-16.s
+#ld: -image-base=0x1000 -Tdata=0x2000
+#objdump: -p
+#notarget: aarch64-*-* arm-wince-pe arm-*-wince arm*-*-mingw32ce*
+#notarget: arm*-*-cegcc* mcore-*-* sh-*-*
+
+.*: +file format pei-.*
+
+#...
+PE File Base Relocations \(interpreted \.reloc section contents\)
+
+Virtual Address: 00001000 Chunk size 12 \(0xc\) Number of fixups 2
+       reloc    0 offset    2 \[1002\] LOW
+       reloc    1 offset    0 \[1000\] ABSOLUTE
+#pass
diff --git a/ld/testsuite/ld-pe/image-fixup-16.s b/ld/testsuite/ld-pe/image-fixup-16.s
new file mode 100644 (file)
index 0000000..ab94447
--- /dev/null
@@ -0,0 +1,4 @@
+       .data
+foo:
+       .2byte  0
+       .2byte  foo
diff --git a/ld/testsuite/ld-pe/image-fixup-32.d b/ld/testsuite/ld-pe/image-fixup-32.d
new file mode 100644 (file)
index 0000000..f6a66d2
--- /dev/null
@@ -0,0 +1,14 @@
+#name: PE-COFF 32-bit image fixup
+#ld: -e 0 -image-base=0x10000000 -Tdata=0x20000000
+#objdump: -p
+#xfail: mcore-*-*
+
+.*: +file format pei-.*
+
+#...
+PE File Base Relocations \(interpreted \.reloc section contents\)
+
+Virtual Address: 10000000 Chunk size 12 \(0xc\) Number of fixups 2
+       reloc    0 offset    4 \[10000004\] HIGHLOW
+       reloc    1 offset    0 \[10000000\] ABSOLUTE
+#pass
diff --git a/ld/testsuite/ld-pe/image-fixup-32.s b/ld/testsuite/ld-pe/image-fixup-32.s
new file mode 100644 (file)
index 0000000..11ae431
--- /dev/null
@@ -0,0 +1,4 @@
+       .data
+foo:
+       .4byte  0
+       .4byte  foo
diff --git a/ld/testsuite/ld-pe/image-fixup-64.d b/ld/testsuite/ld-pe/image-fixup-64.d
new file mode 100644 (file)
index 0000000..9ee5cc5
--- /dev/null
@@ -0,0 +1,14 @@
+#name: PE-COFF 64-bit image fixup
+#ld: -e 0 -image-base=0x10000000 -Tdata=0x20000000
+#objdump: -p
+#notarget: arm-*-* i\[3-7\]86-*-* mcore-*-* sh-*-*
+
+.*: +file format pei-.*
+
+#...
+PE File Base Relocations \(interpreted \.reloc section contents\)
+
+Virtual Address: 10000000 Chunk size 12 \(0xc\) Number of fixups 2
+       reloc    0 offset    8 \[10000008\] DIR64
+       reloc    1 offset    0 \[10000000\] ABSOLUTE
+#pass
diff --git a/ld/testsuite/ld-pe/image-fixup-64.s b/ld/testsuite/ld-pe/image-fixup-64.s
new file mode 100644 (file)
index 0000000..0bc51f3
--- /dev/null
@@ -0,0 +1,4 @@
+       .data
+foo:
+       .8byte  0
+       .8byte  foo
index d30a5627183d8e0bd4ba5b7f53fdabec3371a638..41b7330d46df2c4f3f792a5285ad4a7fad4e3aa6 100644 (file)
@@ -192,3 +192,7 @@ if [check_shared_lib_support] {
     run_dump_test "symbols-ordinals-hints-imports-dlltool"
     set ASFLAGS $old_ASFLAGS
 }
+
+run_dump_test "image-fixup-16"
+run_dump_test "image-fixup-32"
+run_dump_test "image-fixup-64"