[binutils-gdb] Make use of coff internal_reloc r_ignore
Alan Modra via Binutils-cvs <[email protected]> Sat, 25 Jul 2026 12:07:46 +0000 (GMT)
| Newsgroups | gmane.comp.gnu.binutils.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Dbc2ea90d5d53= d2f95f5d50979945b3ef9eee39a3 commit bc2ea90d5d53d2f95f5d50979945b3ef9eee39a3 Author: Alan Modra <[email protected]> Date: Sat Jul 25 10:34:09 2026 +0930 Make use of coff internal_reloc r_ignore =20 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. =20 * coff-aarch64.c (coff_pe_aarch64_relocate_section): Leave r_ty= pe 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. Diff: --- bfd/coff-aarch64.c | 22 +++++++++++----------- bfd/coff-i386.c | 2 +- bfd/coff-x86_64.c | 8 +++++--- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/bfd/coff-aarch64.c b/bfd/coff-aarch64.c index c00448efc82..d889359a6fc 100644 --- a/bfd/coff-aarch64.c +++ b/bfd/coff-aarch64.c @@ -578,7 +578,7 @@ coff_pe_aarch64_relocate_section (bfd *output_bfd, input_section, rel->r_vaddr - input_section->vma); =20 bfd_putl32 (val, contents + rel->r_vaddr); - rel->r_type =3D IMAGE_REL_ARM64_ABSOLUTE; + rel->r_ignore =3D 1; =20 break; } @@ -613,7 +613,7 @@ coff_pe_aarch64_relocate_section (bfd *output_bfd, opcode |=3D val & 0x3ffffff; =20 bfd_putl32 (opcode, contents + rel->r_vaddr); - rel->r_type =3D IMAGE_REL_ARM64_ABSOLUTE; + rel->r_ignore =3D 1; =20 break; } @@ -648,7 +648,7 @@ coff_pe_aarch64_relocate_section (bfd *output_bfd, opcode |=3D (val & 0x7ffff) << 5; =20 bfd_putl32 (opcode, contents + rel->r_vaddr); - rel->r_type =3D IMAGE_REL_ARM64_ABSOLUTE; + rel->r_ignore =3D 1; =20 break; } @@ -683,7 +683,7 @@ coff_pe_aarch64_relocate_section (bfd *output_bfd, opcode |=3D (val & 0x3fff) << 5; =20 bfd_putl32 (opcode, contents + rel->r_vaddr); - rel->r_type =3D IMAGE_REL_ARM64_ABSOLUTE; + rel->r_ignore =3D 1; =20 break; } @@ -720,7 +720,7 @@ coff_pe_aarch64_relocate_section (bfd *output_bfd, opcode |=3D (val & 0x1ffffc) << 3; =20 bfd_putl32 (opcode, contents + rel->r_vaddr); - rel->r_type =3D IMAGE_REL_ARM64_ABSOLUTE; + rel->r_ignore =3D 1; =20 break; } @@ -757,7 +757,7 @@ coff_pe_aarch64_relocate_section (bfd *output_bfd, opcode |=3D (val & 0x1ffffc) << 3; =20 bfd_putl32 (opcode, contents + rel->r_vaddr); - rel->r_type =3D IMAGE_REL_ARM64_ABSOLUTE; + rel->r_ignore =3D 1; =20 break; } @@ -786,7 +786,7 @@ coff_pe_aarch64_relocate_section (bfd *output_bfd, input_section, rel->r_vaddr - input_section->vma); =20 bfd_putl32 (val, contents + rel->r_vaddr); - rel->r_type =3D IMAGE_REL_ARM64_ABSOLUTE; + rel->r_ignore =3D 1; =20 break; } @@ -831,7 +831,7 @@ coff_pe_aarch64_relocate_section (bfd *output_bfd, opcode |=3D val << 10; =20 bfd_putl32 (opcode, contents + rel->r_vaddr); - rel->r_type =3D IMAGE_REL_ARM64_ABSOLUTE; + rel->r_ignore =3D 1; =20 break; } @@ -854,7 +854,7 @@ coff_pe_aarch64_relocate_section (bfd *output_bfd, opcode |=3D val << 10; =20 bfd_putl32 (opcode, contents + rel->r_vaddr); - rel->r_type =3D IMAGE_REL_ARM64_ABSOLUTE; + rel->r_ignore =3D 1; =20 break; } @@ -875,7 +875,7 @@ coff_pe_aarch64_relocate_section (bfd *output_bfd, input_section, rel->r_vaddr - input_section->vma); =20 bfd_putl32 (val, contents + rel->r_vaddr); - rel->r_type =3D IMAGE_REL_ARM64_ABSOLUTE; + rel->r_ignore =3D 1; =20 break; } @@ -900,7 +900,7 @@ coff_pe_aarch64_relocate_section (bfd *output_bfd, =20 =20 bfd_putl16 (idx, contents + rel->r_vaddr); - rel->r_type =3D IMAGE_REL_ARM64_ABSOLUTE; + rel->r_ignore =3D 1; =20 break; } diff --git a/bfd/coff-i386.c b/bfd/coff-i386.c index d9177c51c79..0e296a3400b 100644 --- a/bfd/coff-i386.c +++ b/bfd/coff-i386.c @@ -459,7 +459,7 @@ coff_pe_i386_relocate_section (bfd *output_bfd, =20 /* Make sure that _bfd_coff_generic_relocate_section won't parse this reloc after us. */ - rel->r_type =3D 0; + rel->r_ignore =3D 1; =20 symndx =3D rel->r_symndx; =20 diff --git a/bfd/coff-x86_64.c b/bfd/coff-x86_64.c index 78836a5c267..2c434624052 100644 --- a/bfd/coff-x86_64.c +++ b/bfd/coff-x86_64.c @@ -591,12 +591,12 @@ coff_pe_amd64_relocate_section (bfd *output_bfd, asection *sec, *s; uint16_t idx =3D 0, i =3D 1; =20 - if (rel->r_type !=3D R_SECTION) + if (rel->r_type !=3D R_AMD64_SECTION) continue; =20 /* Make sure that _bfd_coff_generic_relocate_section won't parse this reloc after us. */ - rel->r_type =3D 0; + rel->r_ignore =3D 1; =20 symndx =3D rel->r_symndx; =20 @@ -647,7 +647,9 @@ coff_pe_amd64_relocate_section (bfd *output_bfd, bfd_putl16 (idx, contents + rel->r_vaddr - input_section->vma); } =20 - return _bfd_coff_generic_relocate_section (output_bfd, info, input_bfd,i= nput_section, contents,relocs, syms, sections); + return _bfd_coff_generic_relocate_section (output_bfd, info, input_bfd, + input_section, contents, + relocs, syms, sections); } =20 #define coff_relocate_section coff_pe_amd64_relocate_section