summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeon M. Busch-George <[email protected]>2024-01-26 16:21:24 +0100
committerAnup Patel <[email protected]>2024-02-05 16:34:44 +0530
commitd1dad07cb88fbf601556b4df8ef2bac70fed7143 (patch)
treec1af30d8cd070f511e978a17ab444cc194b7dfb3
parent4a76f79ff5e01bb72eedcf636a11f4c701d1568d (diff)
Makefile: check for --exclude-libs
While writing to the dynsym is futile, the --exclude-libs options is not recognized by all linkers (e.g. riscv64-elf-ld.bfd). Signed-off-by: Leon M. Busch-George <[email protected]> Reviewed-by: Anup Patel <[email protected]>
-rw-r--r--Makefile5
1 files changed, 5 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index 66048c38..680c19a4 100644
--- a/Makefile
+++ b/Makefile
@@ -167,6 +167,9 @@ endif
# Check whether the linker supports creating PIEs
OPENSBI_LD_PIE := $(shell $(CC) $(CLANG_TARGET) $(RELAX_FLAG) $(USE_LD_FLAG) -fPIE -nostdlib -Wl,-pie -x c /dev/null -o /dev/null >/dev/null 2>&1 && echo y || echo n)
+# Check whether the linker supports --exclude-libs
+OPENSBI_LD_EXCLUDE_LIBS := $(shell $(CC) $(CLANG_TARGET) $(RELAX_FLAG) $(USE_LD_FLAG) "-Wl,--exclude-libs,ALL" -x c /dev/null -o /dev/null >/dev/null 2>&1 && echo y || echo n)
+
# Check whether the compiler supports -m(no-)save-restore
CC_SUPPORT_SAVE_RESTORE := $(shell $(CC) $(CLANG_TARGET) $(RELAX_FLAG) -nostdlib -mno-save-restore -x c /dev/null -o /dev/null 2>&1 | grep -e "-save-restore" >/dev/null && echo n || echo y)
@@ -384,7 +387,9 @@ ASFLAGS += $(firmware-asflags-y)
ARFLAGS = rcs
ELFFLAGS += $(USE_LD_FLAG)
+ifeq ($(OPENSBI_LD_EXCLUDE_LIBS),y)
ELFFLAGS += -Wl,--exclude-libs,ALL
+endif
ELFFLAGS += -Wl,--build-id=none
ELFFLAGS += $(platform-ldflags-y)
ELFFLAGS += $(firmware-ldflags-y)