]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
ld/PE: special-case relocation types only for COFF inputs
authorJan Beulich <jbeulich@suse.com>
Wed, 11 Jun 2025 12:32:34 +0000 (14:32 +0200)
committerJan Beulich <jbeulich@suse.com>
Wed, 11 Jun 2025 12:32:34 +0000 (14:32 +0200)
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.

ld/pe-dll.c

index 4a2ea036518597743ad7116a5ce7f6e41c24fe70..210b77ea37445834c69d8043f1f1a14fe9287186 100644 (file)
@@ -1620,10 +1620,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