From 966660ecd0c8a3d6e4d18a5352bb431e71a9a793 Mon Sep 17 00:00:00 2001 From: Chris Kay Date: Thu, 2 Feb 2023 14:39:03 +0000 Subject: [PATCH] fix(pie): pass `-fpie` to the preprocessor as well When PIE is enabled, the `-fpie` flag is passed to the compiler but not to the preprocessor. This change ensures that both tools are aware of when the image is position-independent when preprocessing, which impacts some pre-defined preprocessor definitions. Change-Id: I5208a591d60ee01312f6bf3dd7343abe6535ee61 Signed-off-by: Chris Kay --- Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index e2922a290..0360851b2 100644 --- a/Makefile +++ b/Makefile @@ -654,12 +654,16 @@ endif ifeq ($(ENABLE_PIE),1) ifeq ($(BL2_AT_EL3),1) ifneq ($(BL2_IN_XIP_MEM),1) + BL2_CPPFLAGS += -fpie BL2_CFLAGS += -fpie BL2_LDFLAGS += $(PIE_LDFLAGS) endif endif - BL31_CFLAGS += -fpie + BL31_CPPFLAGS += -fpie + BL31_CFLAGS += -fpie BL31_LDFLAGS += $(PIE_LDFLAGS) + + BL32_CPPFLAGS += -fpie BL32_CFLAGS += -fpie BL32_LDFLAGS += $(PIE_LDFLAGS) endif