[binutils-gdb/binutils-2_44-branch] ld/PE: special-case relocation types only for COFF inputs
Jan Beulich
jbeulich@sourceware.org
Wed Jun 11 12:34:28 GMT 2025
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=b09cf42d51ee0e07794b3b05d750e279586edf4c
commit b09cf42d51ee0e07794b3b05d750e279586edf4c
Author: Jan Beulich <jbeulich@suse.com>
Date: Wed Jun 11 14:32:34 2025 +0200
ld/PE: special-case relocation types only for COFF inputs
In 72cd2c709779 ("ld/PE: no base relocs for section (relative) ones") I
made a pre-existing problem quite a bit worse: When looking at a
relocation's (numerical) howto->type, that value is meaningful only if
the object was of corresponding COFF type. ELF objects in particular
have their own enumeration. As it stands, specifically the not entirely
unusual R_X86_64_32 and R_X86_64_32S did no longer have relocations
emitted for them, due to matching R_AMD64_SECTION and R_AMD64_SECREL in
value respectively.
Diff:
---
ld/pe-dll.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/ld/pe-dll.c b/ld/pe-dll.c
index 1b1ab9f64bb..8024f41dd5b 100644
--- a/ld/pe-dll.c
+++ b/ld/pe-dll.c
@@ -1617,10 +1617,11 @@ generate_reloc (bfd *abfd, struct bfd_link_info *info)
printf ("rel: %s\n", sym->name);
}
if (!relocs[i]->howto->pc_relative
- && relocs[i]->howto->type != pe_details->imagebase_reloc
- && (relocs[i]->howto->type < pe_details->secrel_reloc_lo
- || relocs[i]->howto->type > pe_details->secrel_reloc_hi)
- && relocs[i]->howto->type != pe_details->section_reloc)
+ && (bfd_get_flavour (b) != bfd_target_coff_flavour
+ || (relocs[i]->howto->type != pe_details->imagebase_reloc
+ && (relocs[i]->howto->type < pe_details->secrel_reloc_lo
+ || relocs[i]->howto->type > pe_details->secrel_reloc_hi)
+ && relocs[i]->howto->type != pe_details->section_reloc)))
{
struct bfd_symbol *sym = *relocs[i]->sym_ptr_ptr;
const struct bfd_link_hash_entry *blhe
More information about the Binutils-cvs
mailing list