loader: Fix EFI self relocation code for rela architectures
Update from FreeBSD:
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
Other linkers, and possibly other versions of GNU ld, won't have this
behaviour, so interpret the relocations correctly.
Updated by Electric Monk over 5 years ago
- Status changed from In Progress to Closed
- % Done changed from 90 to 100
commit 066242363458fbf87291daff9454b6f2ac9ebd8b Author: Toomas Soome <firstname.lastname@example.org> Date: 2017-01-03T21:59:04.000Z 7704 loader: Fix EFI self relocation code for rela architectures Reviewed by: Andrew Stormont <email@example.com> Reviewed by: Robert Mustacchi <firstname.lastname@example.org> Approved by: Dan McDonald <email@example.com>