* [PATCH] ld: Fix ADDR32/64 incorrect outputs in pe-aarch64
@ 2023-01-18 5:11 Mark Harmstone
2023-01-24 13:43 ` Nick Clifton
0 siblings, 1 reply; 4+ messages in thread
From: Mark Harmstone @ 2023-01-18 5:11 UTC (permalink / raw)
To: binutils, amodra; +Cc: Mark Harmstone
This changes coff_pe_aarch64_relocate_section to also perform
IMAGE_REL_ARM64_ADDR32 and IMAGE_REL_ARM64_ADDR64 relocations, which
fixes the test failures shown by 52936661.
---
bfd/coff-aarch64.c | 45 +++++++++++++++++++++++++++++++++++++++++----
1 file changed, 41 insertions(+), 4 deletions(-)
diff --git a/bfd/coff-aarch64.c b/bfd/coff-aarch64.c
index 7f6511c82cb..a0cc4f01ae6 100644
--- a/bfd/coff-aarch64.c
+++ b/bfd/coff-aarch64.c
@@ -526,10 +526,7 @@ coff_pe_aarch64_relocate_section (bfd *output_bfd,
asection *sec = NULL;
uint64_t dest_vma;
- /* skip trivial relocations */
- if (rel->r_type == IMAGE_REL_ARM64_ADDR32
- || rel->r_type == IMAGE_REL_ARM64_ADDR64
- || rel->r_type == IMAGE_REL_ARM64_ABSOLUTE)
+ if (rel->r_type == IMAGE_REL_ARM64_ABSOLUTE)
continue;
symndx = rel->r_symndx;
@@ -564,6 +561,46 @@ coff_pe_aarch64_relocate_section (bfd *output_bfd,
switch (rel->r_type)
{
+ case IMAGE_REL_ARM64_ADDR32:
+ {
+ uint64_t val;
+ int32_t addend;
+
+ addend = bfd_getl32 (contents + rel->r_vaddr);
+
+ dest_vma += addend;
+
+ val = dest_vma;
+
+ if (val > 0xffffffff)
+ (*info->callbacks->reloc_overflow)
+ (info, h ? &h->root : NULL, syms[symndx]._n._n_name,
+ "IMAGE_REL_ARM64_ADDR32", addend, input_bfd,
+ input_section, rel->r_vaddr - input_section->vma);
+
+ bfd_putl32 (val, contents + rel->r_vaddr);
+ rel->r_type = IMAGE_REL_ARM64_ABSOLUTE;
+
+ break;
+ }
+
+ case IMAGE_REL_ARM64_ADDR64:
+ {
+ uint64_t val;
+ int64_t addend;
+
+ addend = bfd_getl64 (contents + rel->r_vaddr);
+
+ dest_vma += addend;
+
+ val = dest_vma;
+
+ bfd_putl64 (val, contents + rel->r_vaddr);
+ rel->r_type = IMAGE_REL_ARM64_ABSOLUTE;
+
+ break;
+ }
+
case IMAGE_REL_ARM64_ADDR32NB:
{
uint64_t val;
--
2.38.2
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ld: Fix ADDR32/64 incorrect outputs in pe-aarch64
2023-01-18 5:11 [PATCH] ld: Fix ADDR32/64 incorrect outputs in pe-aarch64 Mark Harmstone
@ 2023-01-24 13:43 ` Nick Clifton
2023-01-25 0:12 ` Mark Harmstone
0 siblings, 1 reply; 4+ messages in thread
From: Nick Clifton @ 2023-01-24 13:43 UTC (permalink / raw)
To: Mark Harmstone, binutils, amodra
Hi Mark,
> This changes coff_pe_aarch64_relocate_section to also perform
> IMAGE_REL_ARM64_ADDR32 and IMAGE_REL_ARM64_ADDR64 relocations, which
> fixes the test failures shown by 52936661.
Approved - please apply.
Cheers
Nick
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ld: Fix ADDR32/64 incorrect outputs in pe-aarch64
2023-01-24 13:43 ` Nick Clifton
@ 2023-01-25 0:12 ` Mark Harmstone
2023-01-25 2:29 ` Alan Modra
0 siblings, 1 reply; 4+ messages in thread
From: Mark Harmstone @ 2023-01-25 0:12 UTC (permalink / raw)
To: Nick Clifton, binutils, amodra
Thanks Nick, but I think the changes that Alan made have superseded this - I no longer get the test failures. Alan, please correct me if I'm wrong.
Mark
On 24/1/23 13:43, Nick Clifton wrote:
> Hi Mark,
>
>> This changes coff_pe_aarch64_relocate_section to also perform
>> IMAGE_REL_ARM64_ADDR32 and IMAGE_REL_ARM64_ADDR64 relocations, which
>> fixes the test failures shown by 52936661.
>
> Approved - please apply.
>
> Cheers
> Nick
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ld: Fix ADDR32/64 incorrect outputs in pe-aarch64
2023-01-25 0:12 ` Mark Harmstone
@ 2023-01-25 2:29 ` Alan Modra
0 siblings, 0 replies; 4+ messages in thread
From: Alan Modra @ 2023-01-25 2:29 UTC (permalink / raw)
To: Mark Harmstone; +Cc: Nick Clifton, binutils
On Wed, Jan 25, 2023 at 12:12:07AM +0000, Mark Harmstone wrote:
> Thanks Nick, but I think the changes that Alan made have superseded this
That's right. It would be a backward step to install this patch.
--
Alan Modra
Australia Development Lab, IBM
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-01-25 2:29 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-18 5:11 [PATCH] ld: Fix ADDR32/64 incorrect outputs in pe-aarch64 Mark Harmstone
2023-01-24 13:43 ` Nick Clifton
2023-01-25 0:12 ` Mark Harmstone
2023-01-25 2:29 ` Alan Modra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).