ArmVirtPkg/PrePi: use standard PeCoff routines for self-relocation

Instead of having a GCC specific routine to perform self-relocation
based on ELF metadata, use the PE/COFF metadata and the existing
PeCoff library routines. This reduces the amount of bespoke assembler
code that is a burden to maintain, and is not portable across the set
of toolchains we support.

This does require some special care, as we have no control over how
the C code references global symbols, so we need to emit these
references from the calling assembler code. Otherwise, they may be
emitted as absolute references, in which case they need to be fixed
up themselves, leading to a circular dependency.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
Acked-by: Jiewen Yao <Jiewen.yao@intel.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
Acked-by: Sami Mujawar <Sami.Mujawar@arm.com>
This commit is contained in:
Ard Biesheuvel
2020-06-08 13:07:54 +02:00
committed by mergify[bot]
parent fd708fe0e1
commit b16fd231f6
6 changed files with 68 additions and 87 deletions

View File

@@ -46,6 +46,7 @@
SerialPortLib
ExtractGuidedSectionLib
LzmaDecompressLib
PeCoffLib
PrePiLib
MemoryAllocationLib
HobLib
@@ -95,6 +96,3 @@
gArmVirtTokenSpaceGuid.PcdDeviceTreeInitialBaseAddress
gArmTokenSpaceGuid.PcdFdBaseAddress
gArmTokenSpaceGuid.PcdFvBaseAddress
[BuildOptions]
GCC:*_*_*_DLINK_FLAGS = -Wl,-Bsymbolic,-pie,-T,$(MODULE_DIR)/Scripts/PrePi-PIE.lds