diff options
author | Masahiro Yamada <yamada.masahiro@socionext.com> | 2020-01-17 13:44:37 +0900 |
---|---|---|
committer | Masahiro Yamada <yamada.masahiro@socionext.com> | 2020-01-24 22:34:25 +0900 |
commit | 320920c15f7b828e34f874c4afb8fa78a3dccb71 (patch) | |
tree | a902798b0e3ad1978c405620e4acdf20e59dceaf | |
parent | d986bae4e2a8bf0f4e31009d6b4a37809e9a4809 (diff) | |
download | platform_external_arm-trusted-firmware-320920c15f7b828e34f874c4afb8fa78a3dccb71.tar.gz platform_external_arm-trusted-firmware-320920c15f7b828e34f874c4afb8fa78a3dccb71.tar.bz2 platform_external_arm-trusted-firmware-320920c15f7b828e34f874c4afb8fa78a3dccb71.zip |
PIE: pass PIE options only to BL31
docs/getting_started/build-options.rst clearly says ENABLE_PIE is
currently only supported in BL31, but in fact, it has a stronger
limitation:
Defining ENABLE_PIE may corrupt BL1 and BL2. So, ENABLE_PIE is
supported only for platforms where BL31 is the only image built
in the TF-A tree.
Currently, ENABLE_PIE is enabled by two platforms,
plat/arm/common/arm_common.mk and ti/k3/common/plat_common.mk,
both of which enable ENABLE_PIE together with RESET_TO_BL31.
For platforms with the full boot sequence, ENABLE_PIE may break earlier
BL stages. For example, if I build PLAT=qemu with ENABLE_PIE=1, it
fails in BL1.
When ENABLE_PIE is enabled, PIE options are added to TF_CFLAGS and
TF_LDFLAGS, so all BL images are affected. It is problematic because
currently only the BL31 linker script handles it. Even if BL1/BL2
works, the image size would increase needlessly, at least.
Pass the PIE options only to BL images that support it.
Change-Id: I550e95148aa3c63571c8ad2081082c554a848f57
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
-rw-r--r-- | Makefile | 24 |
1 files changed, 13 insertions, 11 deletions
@@ -452,18 +452,20 @@ ifeq (${ARM_ARCH_MAJOR},7) include make_helpers/armv7-a-cpus.mk endif -ifeq ($(ENABLE_PIE),1) - TF_CFLAGS += -fpie - ifneq ($(findstring gcc,$(notdir $(LD))),) - TF_LDFLAGS += -Wl,-pie -Wl,--no-dynamic-linker - else - TF_LDFLAGS += -pie --no-dynamic-linker - endif +PIE_FOUND := $(findstring --enable-default-pie,${GCC_V_OUTPUT}) +ifneq ($(PIE_FOUND),) + TF_CFLAGS += -fno-PIE +endif + +ifneq ($(findstring gcc,$(notdir $(LD))),) + PIE_LDFLAGS += -Wl,-pie -Wl,--no-dynamic-linker else - PIE_FOUND := $(findstring --enable-default-pie,${GCC_V_OUTPUT}) - ifneq ($(PIE_FOUND),) - TF_CFLAGS += -fno-PIE - endif + PIE_LDFLAGS += -pie --no-dynamic-linker +endif + +ifeq ($(ENABLE_PIE),1) + BL31_CFLAGS += -fpie + BL31_LDFLAGS += $(PIE_LDFLAGS) endif # Include the CPU specific operations makefile, which provides default |