summaryrefslogtreecommitdiffstats
path: root/StandaloneMmPkg
diff options
context:
space:
mode:
authorArd Biesheuvel <ard.biesheuvel@arm.com>2020-06-09 10:24:06 +0200
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2020-06-16 16:15:00 +0000
commitcdc686223a2d9b8c64831ffbc4b68ca16245aae0 (patch)
treeb0dd7eae01b0616937fa0838a4e516214a41961a /StandaloneMmPkg
parent102da0255bab6610f24f212b295e63d6d8032ab7 (diff)
downloadedk2-cdc686223a2d9b8c64831ffbc4b68ca16245aae0.tar.gz
edk2-cdc686223a2d9b8c64831ffbc4b68ca16245aae0.tar.bz2
edk2-cdc686223a2d9b8c64831ffbc4b68ca16245aae0.zip
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>
Diffstat (limited to 'StandaloneMmPkg')
-rw-r--r--StandaloneMmPkg/Core/StandaloneMmCore.inf4
-rw-r--r--StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf3
2 files changed, 7 insertions, 0 deletions
diff --git a/StandaloneMmPkg/Core/StandaloneMmCore.inf b/StandaloneMmPkg/Core/StandaloneMmCore.inf
index d17ff9965b..87bf6e9440 100644
--- a/StandaloneMmPkg/Core/StandaloneMmCore.inf
+++ b/StandaloneMmPkg/Core/StandaloneMmCore.inf
@@ -75,3 +75,7 @@
gEfiEventLegacyBootGuid
gEfiEventExitBootServicesGuid
gEfiEventReadyToBootGuid
+
+[BuildOptions]
+ GCC:*_*_*_CC_FLAGS = -fpie
+ GCC:*_*_*_DLINK_FLAGS = -Wl,-z,text,-Bsymbolic,-pie
diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf
index 891c292e92..7d6ee4e08e 100644
--- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf
+++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf
@@ -48,3 +48,6 @@
gEfiMmPeiMmramMemoryReserveGuid
gEfiStandaloneMmNonSecureBufferGuid
gEfiArmTfCpuDriverEpDescriptorGuid
+
+[BuildOptions]
+ GCC:*_*_*_CC_FLAGS = -fpie