From 73b15a87dc68dcb968df3478f3b129f3ca8cf5f2 Mon Sep 17 00:00:00 2001 From: Neale Ferguson Date: Wed, 29 May 2024 17:41:20 -0400 Subject: [PATCH] Fix SHMODULEFLAGS so that we link dynamically correctly * arch/risc-v/src/common/Toolchain.defs arch/xtensa/src/lx6/Toolchain.defs arch/xtensa/src/lx7/Toolchain.defs - Define SHMODULEFLAGS etc. for sotest/dynload - Add --entry=__start to SHMODULEFLAGS * boards/arm64/qemu/qemu-armv8a/scripts/Make.defs boards/sim/sim/sim/scripts/Make.defs - Define SHMODULEFLAGS etc. for sotest/dynload --- arch/risc-v/src/common/Toolchain.defs | 3 +++ arch/xtensa/src/lx6/Toolchain.defs | 2 ++ arch/xtensa/src/lx7/Toolchain.defs | 2 ++ boards/arm64/qemu/qemu-armv8a/scripts/Make.defs | 2 ++ boards/sim/sim/sim/scripts/Make.defs | 4 ++-- 5 files changed, 11 insertions(+), 2 deletions(-) diff --git a/arch/risc-v/src/common/Toolchain.defs b/arch/risc-v/src/common/Toolchain.defs index 41beb62335..4600f915fb 100644 --- a/arch/risc-v/src/common/Toolchain.defs +++ b/arch/risc-v/src/common/Toolchain.defs @@ -114,8 +114,11 @@ ifneq ($(CONFIG_CXX_RTTI),y) ARCHCXXFLAGS += -fno-rtti endif +SHMODULEFLAGS = -Bsymbolic -G -Bdynamic --entry=__start + ifeq ($(CONFIG_ARCH_RV32),y) LDFLAGS += -melf32lriscv +SHMODULEFLAGS += -melf32lriscv else LDFLAGS += -melf64lriscv endif diff --git a/arch/xtensa/src/lx6/Toolchain.defs b/arch/xtensa/src/lx6/Toolchain.defs index 0417bef85a..a02d98e147 100644 --- a/arch/xtensa/src/lx6/Toolchain.defs +++ b/arch/xtensa/src/lx6/Toolchain.defs @@ -134,6 +134,8 @@ endif LDFLAGS += -nostdlib +SHMODULEFLAGS = -Bsymbolic -G -Bdynamic --entry=__start + # Optimization of unused sections ifeq ($(CONFIG_DEBUG_OPT_UNUSED_SECTIONS),y) diff --git a/arch/xtensa/src/lx7/Toolchain.defs b/arch/xtensa/src/lx7/Toolchain.defs index c46fcca9d2..e4a2b10b28 100644 --- a/arch/xtensa/src/lx7/Toolchain.defs +++ b/arch/xtensa/src/lx7/Toolchain.defs @@ -138,6 +138,8 @@ endif LDFLAGS += -nostdlib +SHMODULEFLAGS = -Bsymbolic -G -Bdynamic --entry=__start + # Optimization of unused sections ifeq ($(CONFIG_DEBUG_OPT_UNUSED_SECTIONS),y) diff --git a/boards/arm64/qemu/qemu-armv8a/scripts/Make.defs b/boards/arm64/qemu/qemu-armv8a/scripts/Make.defs index fce2c86eea..2b76e1b08d 100644 --- a/boards/arm64/qemu/qemu-armv8a/scripts/Make.defs +++ b/boards/arm64/qemu/qemu-armv8a/scripts/Make.defs @@ -46,6 +46,8 @@ CMODULEFLAGS = $(CFLAGS) LDMODULEFLAGS = -r -e module_initialize LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld) +SHMODULEFLAGS = -Bsymbolic -G -Bdynamic + CELFFLAGS = $(CFLAGS) -mlong-calls # --target1-abs CXXELFFLAGS = $(CXXFLAGS) -mlong-calls # --target1-abs diff --git a/boards/sim/sim/sim/scripts/Make.defs b/boards/sim/sim/sim/scripts/Make.defs index c9530c01b8..c67fb73021 100644 --- a/boards/sim/sim/sim/scripts/Make.defs +++ b/boards/sim/sim/sim/scripts/Make.defs @@ -290,7 +290,7 @@ ifeq ($(CONFIG_DEBUG_LINK_MAP),y) endif SHCCFLAGS = -fPIC -fPIE -fvisibility=default -SHLDFLAGS = -shared -Bsymbolic -Bdynamic -G +SHMODULEFLAGS = -shared -Bsymbolic -Bdynamic -G ifeq ($(CONFIG_DEBUG_LINK_MAP),y) ifeq ($(CONFIG_HOST_MACOS),) @@ -302,6 +302,6 @@ ifeq ($(CONFIG_SIM_M32),y) LDLINKFLAGS += -melf_i386 LDFLAGS += -m32 LDMODULEFLAGS += -melf_i386 - SHLDFLAGS += -melf_i386 + SHMODULEFLAGS += -melf_i386 LDELFFLAGS += -melf_i386 endif