]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
Account for LSB in more relocations
authorMatthew Malcomson <matthew.malcomson@arm.com>
Mon, 7 Mar 2022 18:10:52 +0000 (18:10 +0000)
committerMatthew Malcomson <matthew.malcomson@arm.com>
Mon, 7 Mar 2022 18:10:52 +0000 (18:10 +0000)
commit7470bce3993ef4d4fc441be5b888e06e82c62f3a
tree9bd92bcad846c4f0acb6c28901bb6d0cbb4581c1
parentbf3eaebd3420930c6454cfafe6a636d57599c318
Account for LSB in more relocations

The LSB on STT_FUNC symbols was missed in a few different places.

1) Absolute relocations coming from .xword, .word, and .hword
   directives and the lowest bit MOVW relocations did not account for
   the LSB at all.
2) Relocations for the ADR instruction only added the LSB on local
   symbols.

Here we account for these by adding the LSB in each clause in
elfNN_aarch64_final_link_relocate.
The change under the BFD_RELOC_AARCH64_NN clause handles absolute 64 bit
relocations, the change for BFD_RELOC_AARCH64_ADR_LO21_PCREL handles the
relocation on ADR instructions, and the extra relocations checked
against in the clause including BFD_RELOC_AARCH64_ADD_LO12 ore the
remaining items.

N.b. we noticed the MOVW relocation problem because glibc's start.S was
using these direct MOV relocations to access the value of `main`.  Since
`main` is a function we need to include the LSB in the resulting
relocation value.  These relocations did not include the LSB from
STT_FUNC symbols.

Others were found from inspection of each relocation in turn.
bfd/elfnn-aarch64.c
ld/testsuite/ld-aarch64/aarch64-elf.exp
ld/testsuite/ld-aarch64/emit-relocs-morello-9.d [new file with mode: 0644]
ld/testsuite/ld-aarch64/emit-relocs-morello-9.s [new file with mode: 0644]