aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile3
-rw-r--r--firmware/objects.mk2
2 files changed, 4 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 6b64205..ba06313 100644
--- a/Makefile
+++ b/Makefile
@@ -106,6 +106,9 @@ ifndef PLATFORM_RISCV_XLEN
endif
endif
+# Check whether the linker supports creating PIEs
+OPENSBI_LD_PIE := $(shell $(CC) -fPIE -nostdlib -Wl,-pie -x c /dev/null -o /dev/null >/dev/null 2>&1 && echo y || echo n)
+
# Setup list of objects.mk files
ifdef PLATFORM
platform-object-mks=$(shell if [ -d $(platform_src_dir)/ ]; then find $(platform_src_dir) -iname "objects.mk" | sort -r; fi)
diff --git a/firmware/objects.mk b/firmware/objects.mk
index 83f98ad..a1704c4 100644
--- a/firmware/objects.mk
+++ b/firmware/objects.mk
@@ -14,7 +14,7 @@ firmware-asflags-y +=
firmware-ldflags-y +=
ifndef FW_PIC
-FW_PIC := y
+FW_PIC := $(OPENSBI_LD_PIE)
endif
ifeq ($(FW_PIC),y)