From: Maciej W. Rozycki Date: Mon, 13 Oct 2025 21:02:30 +0000 (+0100) Subject: LD/PE: Remove remains of MIPS target support X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3c33c8c7c70351a743b0b8c1ff6afe97579350de;p=thirdparty%2Fbinutils-gdb.git LD/PE: Remove remains of MIPS target support 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"), . 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. --- diff --git a/ld/pe-dll.c b/ld/pe-dll.c index d10838293a0..853425dc287 100644 --- a/ld/pe-dll.c +++ b/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, @@ -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, - lw $t0, - 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 index 00000000000..b874294d2fa --- /dev/null +++ b/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 diff --git a/ld/testsuite/ld-pe/image-fixup-16.s b/ld/testsuite/ld-pe/image-fixup-16.s new file mode 100644 index 00000000000..ab94447770a --- /dev/null +++ b/ld/testsuite/ld-pe/image-fixup-16.s @@ -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 index 00000000000..f6a66d23680 --- /dev/null +++ b/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 diff --git a/ld/testsuite/ld-pe/image-fixup-32.s b/ld/testsuite/ld-pe/image-fixup-32.s new file mode 100644 index 00000000000..11ae4311026 --- /dev/null +++ b/ld/testsuite/ld-pe/image-fixup-32.s @@ -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 index 00000000000..9ee5cc5febb --- /dev/null +++ b/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 diff --git a/ld/testsuite/ld-pe/image-fixup-64.s b/ld/testsuite/ld-pe/image-fixup-64.s new file mode 100644 index 00000000000..0bc51f3dfe5 --- /dev/null +++ b/ld/testsuite/ld-pe/image-fixup-64.s @@ -0,0 +1,4 @@ + .data +foo: + .8byte 0 + .8byte foo diff --git a/ld/testsuite/ld-pe/pe.exp b/ld/testsuite/ld-pe/pe.exp index d30a5627183..41b7330d46d 100644 --- a/ld/testsuite/ld-pe/pe.exp +++ b/ld/testsuite/ld-pe/pe.exp @@ -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"