From f7ec31db2db3c69a7bd970f4e7fd829e7cc0c53a Mon Sep 17 00:00:00 2001 From: david cunado Date: Thu, 30 Nov 2017 21:58:01 +0000 Subject: [PATCH] Disable PIE compilation option ARM TF does not work correctly if built with a version of gcc that is configured to use PIE by default (e.g. Debian Stretch). This patch identifies when such a version of gcc is being used (by searching for --enable-default-pie) and adds -fno-PIE option to TF_CFLAGS. fixes arm-software/tf-issues#519 Change-Id: I2322122c49841746d35d152694e14f6f73beb0fd Signed-off-by: David Cunado Co-Authored-by: Evan Lloyd Tested-by: Steve Capper Tested-by: Alexei Fedorov --- Makefile | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Makefile b/Makefile index 51e622efe..1058b396f 100644 --- a/Makefile +++ b/Makefile @@ -160,6 +160,13 @@ TF_CFLAGS += $(CPPFLAGS) $(TF_CFLAGS_$(ARCH)) \ -ffreestanding -fno-builtin -Wall -std=gnu99 \ -Os -ffunction-sections -fdata-sections +GCC_V_OUTPUT := $(shell $(CC) -v 2>&1) +PIE_FOUND := $(findstring --enable-default-pie,${GCC_V_OUTPUT}) + +ifeq ($(PIE_FOUND),1) +TF_CFLAGS += -fno-PIE +endif + TF_LDFLAGS += --fatal-warnings -O1 TF_LDFLAGS += --gc-sections TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH))