bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug ld/30437] New: aarch64: RELA relocations don't ignore section conte


From: matz at suse dot de
Subject: [Bug ld/30437] New: aarch64: RELA relocations don't ignore section content as they should
Date: Wed, 10 May 2023 13:51:25 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=30437

            Bug ID: 30437
           Summary: aarch64: RELA relocations don't ignore section content
                    as they should
           Product: binutils
           Version: 2.41 (HEAD)
            Status: NEW
          Severity: normal
          Priority: P2
         Component: ld
          Assignee: unassigned at sourceware dot org
          Reporter: matz at suse dot de
  Target Milestone: ---

The aarch64 psABI prescribes that all RELA relocs are to be idempotent. 
Amongst
other things that means they have to ignore pre-existing section content of the
to-be-relocated place.  The golang toolchain runs into this issue by failing
the
testGCData testcase as in https://github.com/golang/go/issues/39927 .  Parts of
this failing testcase were already fixed in the past, this is the remaining
piece
to be able to not force usage of gold in golang on aarch64 (see
https://github.com/golang/go/issues/22040#issuecomment-1430110400 ).

Creating a testcase by using only gas and ld.bfd requires the .reloc directives
as otherwise the relocated places are always left zeroed and hence don't
exhibit the problem.  But the a testcase is, for instance:

% cat rela.s
       .text
       .global _start
_start:
       ret

       .data
       .p2align 4
l:     .long   0x11111111, 0x22222222
q:     .quad   0x4444444433333333

       .reloc l, BFD_RELOC_64, q+42
       .reloc q, BFD_RELOC_64, l+84

% as rela.s -o rela.o
% ld -pie rela.o
% objdump -dRj .data a.out
a.out:     file format elf64-littleaarch64

DYNAMIC RELOCATION RECORDS
OFFSET           TYPE              VALUE
0000000000020000 R_AARCH64_RELATIVE  *ABS*+0x0000000000020032
0000000000020008 R_AARCH64_RELATIVE  *ABS*+0x0000000000020054


Contents of section .data:
 20000 43111311 22222222 87333533 44444444  C..."""".353DDDD

Here it's obvious that address and addend are merely added to the existing
section content.  That's the bug.

The problem is that since inceptions of the aarch64 backend the src_mask
of all relocation descriptors in BFD were non-zero.  That's always wrong
for RELA relocs.  I have a patch.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]