From 5033966d8ce3f51f441562b5b458f687cf7a13ed Mon Sep 17 00:00:00 2001 From: Neale Ferguson Date: Mon, 9 Oct 2023 16:36:02 -0400 Subject: [PATCH] Add flags for building shared objects for architectures supporting dynamic loading * arch/arm/src/common/Toolchain.defs arch/risc-v/src/common/Toolchain.defs boards/sim/sim/sim/scripts/Make.defs - Add SHCCFLAGS and SSHLDFLAGS --- arch/arm/src/common/Toolchain.defs | 11 ++++++++++- arch/risc-v/src/common/Toolchain.defs | 11 ++++++++++- boards/sim/sim/sim/scripts/Make.defs | 5 ++++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/arch/arm/src/common/Toolchain.defs b/arch/arm/src/common/Toolchain.defs index c78a14a01b..e64f23f95a 100644 --- a/arch/arm/src/common/Toolchain.defs +++ b/arch/arm/src/common/Toolchain.defs @@ -408,4 +408,13 @@ include $(TOPDIR)/tools/Rust.defs # LDC (LLVM D Compiler) toolchain -include $(TOPDIR)/tools/D.defs \ No newline at end of file +include $(TOPDIR)/tools/D.defs + +# Shared library build flags + +SHCCFLAGS = -fPIC -fPIE -fvisibility=default +SHLDFLAGS = -shared -Bsymbolic -Bdynamic -G + +ifeq ($(CONFIG_SIM_M32),y) + SHLDFLAGS += -melf_i386 +endif diff --git a/arch/risc-v/src/common/Toolchain.defs b/arch/risc-v/src/common/Toolchain.defs index 0d1f279f4a..41beb62335 100644 --- a/arch/risc-v/src/common/Toolchain.defs +++ b/arch/risc-v/src/common/Toolchain.defs @@ -402,4 +402,13 @@ include $(TOPDIR)/tools/Rust.defs # LDC (LLVM D Compiler) toolchain -include $(TOPDIR)/tools/D.defs \ No newline at end of file +include $(TOPDIR)/tools/D.defs + +# Shared library build flags + +SHCCFLAGS = -fPIC -fPIE -fvisibility=default +SHLDFLAGS = -shared -Bsymbolic -Bdynamic -G + +ifeq ($(CONFIG_SIM_M32),y) + SHLDFLAGS += -melf_i386 +endif diff --git a/boards/sim/sim/sim/scripts/Make.defs b/boards/sim/sim/sim/scripts/Make.defs index 651600867c..387e13814f 100644 --- a/boards/sim/sim/sim/scripts/Make.defs +++ b/boards/sim/sim/sim/scripts/Make.defs @@ -289,10 +289,13 @@ ifeq ($(CONFIG_DEBUG_LINK_MAP),y) endif endif +SHCCFLAGS = -fPIC -fPIE -fvisibility=default +SHLDFLAGS = -shared -Bsymbolic -Bdynamic -G + ifeq ($(CONFIG_SIM_M32),y) LDLINKFLAGS += -melf_i386 LDFLAGS += -m32 LDMODULEFLAGS += -melf_i386 - SHMODULEFLAGS += -melf_i386 + SHLDFLAGS += -melf_i386 LDELFFLAGS += -melf_i386 endif