]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Make use of coff internal_reloc r_ignore
authorAlan Modra <amodra@gmail.com>
Sat, 25 Jul 2026 01:04:09 +0000 (10:34 +0930)
committerAlan Modra <amodra@gmail.com>
Sat, 25 Jul 2026 11:57:37 +0000 (21:27 +0930)
Set r_ignore on relocs already handled by a backend relocate_section,
rather than choosing a "do nothing" r_type.  This avoids bugs in all
three targets with in_reloc_p, which resulted in addresses being
emitted for dynamic relocs at all of these "do nothing" relocs.

* coff-aarch64.c (coff_pe_aarch64_relocate_section): Leave r_type
unchanged on relocs handled here.  Set r_ignore instead.
* coff-i386.c (coff_pe_i386_relocate_section): Likewise.
* coff-x86_64.c (coff_pe_amd64_relocate_section): Likewise.
Cosmetic fix in r_type handled here.  Formatting.

bfd/coff-aarch64.c
bfd/coff-i386.c
bfd/coff-x86_64.c

index c00448efc8296c70e8aefffebec49ec85a8a094e..d889359a6fc1dd1495360a9a6205f01c2b9764fc 100644 (file)
@@ -578,7 +578,7 @@ coff_pe_aarch64_relocate_section (bfd *output_bfd,
                input_section, rel->r_vaddr - input_section->vma);
 
            bfd_putl32 (val, contents + rel->r_vaddr);
-           rel->r_type = IMAGE_REL_ARM64_ABSOLUTE;
+           rel->r_ignore = 1;
 
            break;
          }
@@ -613,7 +613,7 @@ coff_pe_aarch64_relocate_section (bfd *output_bfd,
            opcode |= val & 0x3ffffff;
 
            bfd_putl32 (opcode, contents + rel->r_vaddr);
-           rel->r_type = IMAGE_REL_ARM64_ABSOLUTE;
+           rel->r_ignore = 1;
 
            break;
          }
@@ -648,7 +648,7 @@ coff_pe_aarch64_relocate_section (bfd *output_bfd,
            opcode |= (val & 0x7ffff) << 5;
 
            bfd_putl32 (opcode, contents + rel->r_vaddr);
-           rel->r_type = IMAGE_REL_ARM64_ABSOLUTE;
+           rel->r_ignore = 1;
 
            break;
          }
@@ -683,7 +683,7 @@ coff_pe_aarch64_relocate_section (bfd *output_bfd,
            opcode |= (val & 0x3fff) << 5;
 
            bfd_putl32 (opcode, contents + rel->r_vaddr);
-           rel->r_type = IMAGE_REL_ARM64_ABSOLUTE;
+           rel->r_ignore = 1;
 
            break;
          }
@@ -720,7 +720,7 @@ coff_pe_aarch64_relocate_section (bfd *output_bfd,
            opcode |= (val & 0x1ffffc) << 3;
 
            bfd_putl32 (opcode, contents + rel->r_vaddr);
-           rel->r_type = IMAGE_REL_ARM64_ABSOLUTE;
+           rel->r_ignore = 1;
 
            break;
          }
@@ -757,7 +757,7 @@ coff_pe_aarch64_relocate_section (bfd *output_bfd,
            opcode |= (val & 0x1ffffc) << 3;
 
            bfd_putl32 (opcode, contents + rel->r_vaddr);
-           rel->r_type = IMAGE_REL_ARM64_ABSOLUTE;
+           rel->r_ignore = 1;
 
            break;
          }
@@ -786,7 +786,7 @@ coff_pe_aarch64_relocate_section (bfd *output_bfd,
                input_section, rel->r_vaddr - input_section->vma);
 
            bfd_putl32 (val, contents + rel->r_vaddr);
-           rel->r_type = IMAGE_REL_ARM64_ABSOLUTE;
+           rel->r_ignore = 1;
 
            break;
          }
@@ -831,7 +831,7 @@ coff_pe_aarch64_relocate_section (bfd *output_bfd,
            opcode |= val << 10;
 
            bfd_putl32 (opcode, contents + rel->r_vaddr);
-           rel->r_type = IMAGE_REL_ARM64_ABSOLUTE;
+           rel->r_ignore = 1;
 
            break;
          }
@@ -854,7 +854,7 @@ coff_pe_aarch64_relocate_section (bfd *output_bfd,
            opcode |= val << 10;
 
            bfd_putl32 (opcode, contents + rel->r_vaddr);
-           rel->r_type = IMAGE_REL_ARM64_ABSOLUTE;
+           rel->r_ignore = 1;
 
            break;
          }
@@ -875,7 +875,7 @@ coff_pe_aarch64_relocate_section (bfd *output_bfd,
                input_section, rel->r_vaddr - input_section->vma);
 
            bfd_putl32 (val, contents + rel->r_vaddr);
-           rel->r_type = IMAGE_REL_ARM64_ABSOLUTE;
+           rel->r_ignore = 1;
 
            break;
          }
@@ -900,7 +900,7 @@ coff_pe_aarch64_relocate_section (bfd *output_bfd,
 
 
            bfd_putl16 (idx, contents + rel->r_vaddr);
-           rel->r_type = IMAGE_REL_ARM64_ABSOLUTE;
+           rel->r_ignore = 1;
 
            break;
          }
index d9177c51c79784a29fcb070c07b77ac2d49ae70e..0e296a3400b1d6de1e97a30a17387a6cdf303240 100644 (file)
@@ -459,7 +459,7 @@ coff_pe_i386_relocate_section (bfd *output_bfd,
 
       /* Make sure that _bfd_coff_generic_relocate_section won't parse
          this reloc after us.  */
-      rel->r_type = 0;
+      rel->r_ignore = 1;
 
       symndx = rel->r_symndx;
 
index 78836a5c2675d1375986b091dbf182d50b34d429..2c43462405232b36728f725415908736b89f1eba 100644 (file)
@@ -591,12 +591,12 @@ coff_pe_amd64_relocate_section (bfd *output_bfd,
       asection *sec, *s;
       uint16_t idx = 0, i = 1;
 
-      if (rel->r_type != R_SECTION)
+      if (rel->r_type != R_AMD64_SECTION)
        continue;
 
       /* Make sure that _bfd_coff_generic_relocate_section won't parse
          this reloc after us.  */
-      rel->r_type = 0;
+      rel->r_ignore = 1;
 
       symndx = rel->r_symndx;
 
@@ -647,7 +647,9 @@ coff_pe_amd64_relocate_section (bfd *output_bfd,
       bfd_putl16 (idx, contents + rel->r_vaddr - input_section->vma);
     }
 
-  return _bfd_coff_generic_relocate_section (output_bfd, info, input_bfd,input_section, contents,relocs, syms, sections);
+  return _bfd_coff_generic_relocate_section (output_bfd, info, input_bfd,
+                                            input_section, contents,
+                                            relocs, syms, sections);
 }
 
 #define coff_relocate_section coff_pe_amd64_relocate_section