HomeFreeBSD

Fix EFI self relocation code for rela architectures

Description

Fix EFI self relocation code for rela architectures

MFC r306812 (andrew):

The bootloader self relocation code was slightly wrong for the
R_AARCH64_RELATIVE relocation found on arm64. It would try to add the
contents of the memory location being relocated to the base address and
the relocation addend. This worked when the contents was zero, however
this now seems to be set to the value of the addend so we add this twice.
Fix this by just setting the memory to the computed value.

MFC r309360: EFI loaders: parse rela relocations on amd64

Prior to this change the loader self relocation code interpreted amd64's
rela relocations as if they were rel relocations, discarding the addend.
This "works" because GNU ld 2.17.50 stores the addend value in both the
r_addend field of the relocation (as expected) and at the target of the
relocation.

Other linkers, and possibly other versions of GNU ld, won't have this
behaviour, so interpret the relocations correctly.

Details

Provenance
emasteAuthored on
Parents
rS310724: Follow DW_AT_specification when looking up DW_AT_type attributes.
Branches
Unknown
Tags
Unknown