From 7f3665aa4b69cd3743ceb731685448df05bb9bf6 Mon Sep 17 00:00:00 2001 From: Jan Beulich Date: Mon, 15 Dec 2025 10:48:10 +0100 Subject: [PATCH] Arm: use BFD_RELOC_32_PLT_PCREL in favor of custom type No reason to have a separate type when the generic one has no (other) meaning for this target. Doing the adjustments makes obvious that elf32_arm_reloc_map[] had two identical entries; that duplicate is being removed. --- bfd/bfd-in2.h | 1 - bfd/elf32-arm.c | 3 +-- bfd/libbfd.h | 1 - bfd/reloc.c | 2 -- gas/config/tc-arm.c | 22 +++++++++++----------- 5 files changed, 12 insertions(+), 17 deletions(-) diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index ff0c5f88cdc..35f8c1ee096 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -4209,7 +4209,6 @@ enum bfd_reloc_code_real BFD_RELOC_ARM_JUMP_SLOT, BFD_RELOC_ARM_GLOB_DAT, BFD_RELOC_ARM_GOT32, - BFD_RELOC_ARM_PLT32, BFD_RELOC_ARM_RELATIVE, BFD_RELOC_ARM_GOTOFF, BFD_RELOC_ARM_GOTPC, diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c index 24dde624d55..ba477dc6e47 100644 --- a/bfd/elf32-arm.c +++ b/bfd/elf32-arm.c @@ -2023,13 +2023,12 @@ static const struct elf32_arm_reloc_map elf32_arm_reloc_map[] = {BFD_RELOC_ARM_GOTPC, R_ARM_GOTPC}, {BFD_RELOC_ARM_GOT_PREL, R_ARM_GOT_PREL}, {BFD_RELOC_ARM_GOT32, R_ARM_GOT32}, - {BFD_RELOC_ARM_PLT32, R_ARM_PLT32}, + {BFD_RELOC_32_PLT_PCREL, R_ARM_PLT32}, {BFD_RELOC_ARM_TARGET1, R_ARM_TARGET1}, {BFD_RELOC_ARM_ROSEGREL32, R_ARM_ROSEGREL32}, {BFD_RELOC_ARM_SBREL32, R_ARM_SBREL32}, {BFD_RELOC_ARM_PREL31, R_ARM_PREL31}, {BFD_RELOC_ARM_TARGET2, R_ARM_TARGET2}, - {BFD_RELOC_ARM_PLT32, R_ARM_PLT32}, {BFD_RELOC_ARM_TLS_GOTDESC, R_ARM_TLS_GOTDESC}, {BFD_RELOC_ARM_TLS_CALL, R_ARM_TLS_CALL}, {BFD_RELOC_ARM_THM_TLS_CALL, R_ARM_THM_TLS_CALL}, diff --git a/bfd/libbfd.h b/bfd/libbfd.h index c8249710dff..1196041c47b 100644 --- a/bfd/libbfd.h +++ b/bfd/libbfd.h @@ -1712,7 +1712,6 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@", "BFD_RELOC_ARM_JUMP_SLOT", "BFD_RELOC_ARM_GLOB_DAT", "BFD_RELOC_ARM_GOT32", - "BFD_RELOC_ARM_PLT32", "BFD_RELOC_ARM_RELATIVE", "BFD_RELOC_ARM_GOTOFF", "BFD_RELOC_ARM_GOTPC", diff --git a/bfd/reloc.c b/bfd/reloc.c index 699c042cece..af21596aba4 100644 --- a/bfd/reloc.c +++ b/bfd/reloc.c @@ -3039,8 +3039,6 @@ ENUMX BFD_RELOC_ARM_GLOB_DAT ENUMX BFD_RELOC_ARM_GOT32 -ENUMX - BFD_RELOC_ARM_PLT32 ENUMX BFD_RELOC_ARM_RELATIVE ENUMX diff --git a/gas/config/tc-arm.c b/gas/config/tc-arm.c index 2eed286448e..abad78a742f 100644 --- a/gas/config/tc-arm.c +++ b/gas/config/tc-arm.c @@ -3849,7 +3849,7 @@ s_arm_elf_cons (int nbytes) reloc); int size = bfd_get_reloc_size (howto); - if (reloc == BFD_RELOC_ARM_PLT32) + if (reloc == BFD_RELOC_32_PLT_PCREL) { as_bad (_("(plt) is only valid on branch targets")); reloc = BFD_RELOC_UNUSED; @@ -9304,11 +9304,11 @@ encode_branch (int default_reloc) { if (inst.operands[0].hasreloc) { - constraint (inst.operands[0].imm != BFD_RELOC_ARM_PLT32 + constraint (inst.operands[0].imm != BFD_RELOC_32_PLT_PCREL && inst.operands[0].imm != BFD_RELOC_ARM_TLS_CALL, _("the only valid suffixes here are '(plt)' and '(tlscall)'")); - inst.relocs[0].type = inst.operands[0].imm == BFD_RELOC_ARM_PLT32 - ? BFD_RELOC_ARM_PLT32 + inst.relocs[0].type = inst.operands[0].imm == BFD_RELOC_32_PLT_PCREL + ? BFD_RELOC_32_PLT_PCREL : thumb_mode ? BFD_RELOC_ARM_THM_TLS_CALL : BFD_RELOC_ARM_TLS_CALL; } else @@ -12019,7 +12019,7 @@ do_t_branch23 (void) the branch encoding is now needed to deal with TLSCALL relocs. So if we see a PLT reloc now, put it back to how it used to be to keep the preexisting behaviour. */ - if (inst.relocs[0].type == BFD_RELOC_ARM_PLT32) + if (inst.relocs[0].type == BFD_RELOC_32_PLT_PCREL) inst.relocs[0].type = BFD_RELOC_THUMB_PCREL_BRANCH23; #if defined(OBJ_COFF) @@ -23899,7 +23899,7 @@ static struct reloc_entry reloc_names[] = { { "got", BFD_RELOC_ARM_GOT32 }, { "GOT", BFD_RELOC_ARM_GOT32 }, { "gotoff", BFD_RELOC_ARM_GOTOFF }, { "GOTOFF", BFD_RELOC_ARM_GOTOFF }, - { "plt", BFD_RELOC_ARM_PLT32 }, { "PLT", BFD_RELOC_ARM_PLT32 }, + { "plt", BFD_RELOC_32_PLT_PCREL}, { "PLT", BFD_RELOC_32_PLT_PCREL}, { "target1", BFD_RELOC_ARM_TARGET1 }, { "TARGET1", BFD_RELOC_ARM_TARGET1 }, { "target2", BFD_RELOC_ARM_TARGET2 }, { "TARGET2", BFD_RELOC_ARM_TARGET2 }, { "sbrel", BFD_RELOC_ARM_SBREL32 }, { "SBREL", BFD_RELOC_ARM_SBREL32 }, @@ -27245,7 +27245,7 @@ md_pcrel_from_section (fixS * fixP, segT seg) case BFD_RELOC_ARM_PCREL_BRANCH: case BFD_RELOC_ARM_PCREL_JUMP: - case BFD_RELOC_ARM_PLT32: + case BFD_RELOC_32_PLT_PCREL: #ifdef TE_WINCE /* When handling fixups immediately, because we have already discovered the value of a symbol, or the address of the frag involved @@ -28197,7 +28197,7 @@ md_apply_fix (fixS * fixP, } /* Fall through. */ - case BFD_RELOC_ARM_PLT32: + case BFD_RELOC_32_PLT_PCREL: #endif case BFD_RELOC_ARM_PCREL_BRANCH: temp = 3; @@ -29419,7 +29419,7 @@ tc_gen_reloc (asection *section, fixS *fixp) case BFD_RELOC_ARM_GOT32: case BFD_RELOC_ARM_GOTOFF: case BFD_RELOC_ARM_GOT_PREL: - case BFD_RELOC_ARM_PLT32: + case BFD_RELOC_32_PLT_PCREL: case BFD_RELOC_ARM_TARGET1: case BFD_RELOC_ARM_ROSEGREL32: case BFD_RELOC_ARM_SBREL32: @@ -29748,7 +29748,7 @@ arm_fix_adjustable (fixS * fixP) return false; /* Don't allow symbols to be discarded on GOT related relocs. */ - if (fixP->fx_r_type == BFD_RELOC_ARM_PLT32 + if (fixP->fx_r_type == BFD_RELOC_32_PLT_PCREL || fixP->fx_r_type == BFD_RELOC_ARM_GOT32 || fixP->fx_r_type == BFD_RELOC_ARM_GOTOFF || fixP->fx_r_type == BFD_RELOC_ARM_TLS_GD32 @@ -30062,7 +30062,7 @@ md_begin (void) { struct reloc_entry * entry = reloc_names + i; - if (arm_is_eabi() && entry->reloc == BFD_RELOC_ARM_PLT32) + if (arm_is_eabi() && entry->reloc == BFD_RELOC_32_PLT_PCREL) /* This makes encode_branch() use the EABI versions of this relocation. */ entry->reloc = BFD_RELOC_UNUSED; -- 2.47.3