[PATCH v3 2/2] LD/PE: Remove remains of MIPS target support
Maciej W. Rozycki
macro@orcam.me.uk
Thu Oct 9 00:58:13 GMT 2025
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.
---
Changes from v2:
- Update for PE_ARCH_mips being an enumeration constant.
- Update description.
- Add test cases.
Changes from v1:
- Retain code generating LOW relocs.
---
ld/pe-dll.c | 44 ------------------------------------
ld/testsuite/ld-pe/image-fixup-16.d | 16 +++++++++++++
ld/testsuite/ld-pe/image-fixup-16.s | 4 +++
ld/testsuite/ld-pe/image-fixup-32.d | 14 +++++++++++
ld/testsuite/ld-pe/image-fixup-32.s | 4 +++
ld/testsuite/ld-pe/image-fixup-64.d | 14 +++++++++++
ld/testsuite/ld-pe/image-fixup-64.s | 4 +++
ld/testsuite/ld-pe/pe.exp | 4 +++
8 files changed, 60 insertions(+), 44 deletions(-)
binutils-ld-mips-pe-remove.diff
Index: binutils-gdb/ld/pe-dll.c
===================================================================
--- binutils-gdb.orig/ld/pe-dll.c
+++ binutils-gdb/ld/pe-dll.c
@@ -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,
@@ -322,16 +321,6 @@ static pe_details_type pe_detail_list[]
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",
11 /* ARM_RVA32 */,
@@ -1707,15 +1696,6 @@ generate_reloc (bfd *abfd, struct bfd_li
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;
@@ -1769,9 +1749,6 @@ generate_reloc (bfd *abfd, struct bfd_li
}
reloc_sz += 2;
-
- if (reloc_data[i].type == IMAGE_REL_BASED_HIGHADJ)
- reloc_sz += 2;
}
reloc_sz = (reloc_sz + 3) & ~3; /* 4-byte align. */
@@ -2318,18 +2295,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] */
@@ -2392,10 +2357,6 @@ make_one (def_file_export *exp, bfd *par
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;
@@ -2482,11 +2443,6 @@ make_one (def_file_export *exp, bfd *par
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);
Index: binutils-gdb/ld/testsuite/ld-pe/image-fixup-16.d
===================================================================
--- /dev/null
+++ binutils-gdb/ld/testsuite/ld-pe/image-fixup-16.d
@@ -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
Index: binutils-gdb/ld/testsuite/ld-pe/image-fixup-16.s
===================================================================
--- /dev/null
+++ binutils-gdb/ld/testsuite/ld-pe/image-fixup-16.s
@@ -0,0 +1,4 @@
+ .data
+foo:
+ .2byte 0
+ .2byte foo
Index: binutils-gdb/ld/testsuite/ld-pe/image-fixup-32.d
===================================================================
--- /dev/null
+++ binutils-gdb/ld/testsuite/ld-pe/image-fixup-32.d
@@ -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
Index: binutils-gdb/ld/testsuite/ld-pe/image-fixup-32.s
===================================================================
--- /dev/null
+++ binutils-gdb/ld/testsuite/ld-pe/image-fixup-32.s
@@ -0,0 +1,4 @@
+ .data
+foo:
+ .4byte 0
+ .4byte foo
Index: binutils-gdb/ld/testsuite/ld-pe/image-fixup-64.d
===================================================================
--- /dev/null
+++ binutils-gdb/ld/testsuite/ld-pe/image-fixup-64.d
@@ -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
Index: binutils-gdb/ld/testsuite/ld-pe/image-fixup-64.s
===================================================================
--- /dev/null
+++ binutils-gdb/ld/testsuite/ld-pe/image-fixup-64.s
@@ -0,0 +1,4 @@
+ .data
+foo:
+ .8byte 0
+ .8byte foo
Index: binutils-gdb/ld/testsuite/ld-pe/pe.exp
===================================================================
--- binutils-gdb.orig/ld/testsuite/ld-pe/pe.exp
+++ binutils-gdb/ld/testsuite/ld-pe/pe.exp
@@ -189,3 +189,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"
More information about the Binutils
mailing list