cactus: update build options and memory map to make it PIE
Signed-off-by: Olivier Deprez <olivier.deprez@arm.com>
Change-Id: I9287361d2a4c81954fae715fef6ba5cc57cc10e0
diff --git a/Makefile b/Makefile
index 010496d..dc6092f 100644
--- a/Makefile
+++ b/Makefile
@@ -223,6 +223,14 @@
NS_BL2U_CFLAGS += -mbranch-protection=pac-ret
endif
+#####################################################################################
+ifneq ($(findstring gcc,$(notdir $(LD))),)
+ PIE_LDFLAGS += -Wl,-pie -Wl,--no-dynamic-linker
+else
+ PIE_LDFLAGS += -pie --no-dynamic-linker
+endif
+
+#####################################################################################
NS_BL1U_SOURCES += ${PLAT_SOURCES} ${LIBC_SRCS}
NS_BL1U_INCLUDES += ${PLAT_INCLUDES}
NS_BL1U_CFLAGS += ${COMMON_CFLAGS}
@@ -243,9 +251,9 @@
CACTUS_SOURCES += ${LIBC_SRCS}
CACTUS_INCLUDES += ${PLAT_INCLUDES}
-CACTUS_CFLAGS += ${COMMON_CFLAGS}
+CACTUS_CFLAGS += ${COMMON_CFLAGS} -fpie
CACTUS_ASFLAGS += ${COMMON_ASFLAGS}
-CACTUS_LDFLAGS += ${COMMON_LDFLAGS}
+CACTUS_LDFLAGS += ${COMMON_LDFLAGS} $(PIE_LDFLAGS)
IVY_SOURCES += ${LIBC_SRCS}
IVY_INCLUDES += ${PLAT_INCLUDES}
diff --git a/spm/cactus/cactus_def.h b/spm/cactus/cactus_def.h
index 13b5dac..e865036 100644
--- a/spm/cactus/cactus_def.h
+++ b/spm/cactus/cactus_def.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2020, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -14,7 +14,7 @@
*/
/* Up to 2 MiB at an arbitrary address that doesn't overlap the devices. */
-#define CACTUS_IMAGE_BASE ULL(0x80000000)
+#define CACTUS_IMAGE_BASE ULL(0x1000)
#define CACTUS_IMAGE_SIZE ULL(0x200000)
/* Memory reserved for stacks */