]> git.proxmox.com Git - mirror_edk2.git/commit
StandaloneMmPkg: generate position independent code for StMM core
authorArd Biesheuvel <ard.biesheuvel@arm.com>
Tue, 9 Jun 2020 08:24:06 +0000 (10:24 +0200)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Tue, 16 Jun 2020 16:15:00 +0000 (16:15 +0000)
commitcdc686223a2d9b8c64831ffbc4b68ca16245aae0
treeb0dd7eae01b0616937fa0838a4e516214a41961a
parent102da0255bab6610f24f212b295e63d6d8032ab7
StandaloneMmPkg: generate position independent code for StMM core

The standalone MM core runs in a restricted environment that is set
up by a higher privilege level, and which may not allow memory regions
to be writable and executable at the same time.

This means that making the StMM core self-relocatable requires that
all the targets of the relocation fixups are outside of the executable
region of the image, given that we cannot remap the executable code
writable from the executable code itself without losing those execute
permissions.

So instead, use the existing toolchain support to ensure that position
independent code is used where possible, and that all the remaining
relocated quantities are emitted into the data section. (Note that
staticallly initialized const pointers will be emitted into the
.data.rel.ro section, which gets pulled into the .data section by
our linker script)

To ensure that we don't pick up any absolute references in executable
code inadvertently (e.g., in assembler code), add the '-z text' linker
option which will force the build to fail in this case.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
Acked-by: Jiewen Yao <Jiewen.yao@intel.com>
Tested-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
StandaloneMmPkg/Core/StandaloneMmCore.inf
StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf