diff options
author | Mark Harmstone <mark@harmstone.com> | 2023-01-23 00:26:07 +0000 |
---|---|---|
committer | Mark Harmstone <mark@harmstone.com> | 2023-01-23 20:07:30 +0000 |
commit | 6f4a117fe1ea8f5722ff9fd4db9a1ecc8bd26b84 (patch) | |
tree | 78fcfec080ae889c1550dc039b372c2ae568b7b7 /bfd/coff-aarch64.c | |
parent | 29e09a42f1d1af3d97652e54b6b3cac68cf61d15 (diff) | |
download | binutils-gdb-6f4a117fe1ea8f5722ff9fd4db9a1ecc8bd26b84.tar.gz |
Add support for secidx relocations to aarch64-w64-mingw32
This patch adds support for the .secidx directive and its corresponding
relocation to aarch64-w64-mingw32. As with x86, this is a two-byte LE
integer which gets filled in with the 1-based index of the output
section that a symbol ends up in.
This is needed for PDBs, which represent addresses as a .secrel32,
.secidx pair.
The test is substantially the same as for amd64, but with changes made
for padding and alignment.
Diffstat (limited to 'bfd/coff-aarch64.c')
-rw-r--r-- | bfd/coff-aarch64.c | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/bfd/coff-aarch64.c b/bfd/coff-aarch64.c index 73fa2442dfe..12e242e18d0 100644 --- a/bfd/coff-aarch64.c +++ b/bfd/coff-aarch64.c @@ -305,6 +305,10 @@ static const reloc_howto_type arm64_reloc_howto_secrel = HOW (IMAGE_REL_ARM64_SECREL, 0, 4, 32, false, 0, dont, secrel_reloc, 0xffffffff); +static const reloc_howto_type arm64_reloc_howto_secidx += HOW (IMAGE_REL_ARM64_SECTION, + 0, 2, 16, false, 0, dont, NULL, 0xffff); + static const reloc_howto_type* const arm64_howto_table[] = { &arm64_reloc_howto_abs, &arm64_reloc_howto_64, @@ -318,7 +322,8 @@ static const reloc_howto_type* const arm64_howto_table[] = { &arm64_reloc_howto_branch14, &arm64_reloc_howto_pgoff12a, &arm64_reloc_howto_32nb, - &arm64_reloc_howto_secrel + &arm64_reloc_howto_secrel, + &arm64_reloc_howto_secidx }; /* No adjustment to addends should be needed. The actual relocation @@ -372,6 +377,8 @@ coff_aarch64_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED, bfd_reloc_code_real return &arm64_reloc_howto_32nb; case BFD_RELOC_32_SECREL: return &arm64_reloc_howto_secrel; + case BFD_RELOC_16_SECIDX: + return &arm64_reloc_howto_secidx; default: BFD_FAIL (); return NULL; @@ -428,6 +435,8 @@ coff_aarch64_rtype_lookup (unsigned int code) return &arm64_reloc_howto_32nb; case IMAGE_REL_ARM64_SECREL: return &arm64_reloc_howto_secrel; + case IMAGE_REL_ARM64_SECTION: + return &arm64_reloc_howto_secidx; default: return NULL; } @@ -847,6 +856,31 @@ coff_pe_aarch64_relocate_section (bfd *output_bfd, break; } + case IMAGE_REL_ARM64_SECTION: + { + uint16_t idx = 0, i = 1; + asection *s; + + s = output_bfd->sections; + while (s) + { + if (s == sec->output_section) + { + idx = i; + break; + } + + i++; + s = s->next; + } + + + bfd_putl16 (idx, contents + rel->r_vaddr); + rel->r_type = IMAGE_REL_ARM64_ABSOLUTE; + + break; + } + default: info->callbacks->einfo (_("%F%P: Unhandled relocation type %u\n"), rel->r_type); |