Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,20 @@ if(EXISTS ${NUTTX_DIR}/arch/${CONFIG_ARCH}/src/cmake/elf.cmake)
include(${NUTTX_DIR}/arch/${CONFIG_ARCH}/src/cmake/elf.cmake)
endif()

# The default registers each static object's destructor with __cxa_atexit(dtor,
# obj, &__dso_handle), and __dso_handle comes from crtbegin, which a module does
# not link. Turning it off also puts the destructors in .fini_array, which is
# where the loader looks for them when the module is unloaded.
#
# GCC and Clang alone take the option, which is why the architectures built by
# another compiler do not carry it in their Toolchain.defs either. ARMClang
# reports ARMClang, so it keeps it. The generator expression keeps the option
# off the C compiles, which it is not valid for.

if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
nuttx_elf_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fno-use-cxa-atexit>)
endif()

include(platform)

if(CONFIG_ARCH_TOOLCHAIN_TASKING)
Expand Down
4 changes: 4 additions & 0 deletions arch/arm/src/common/Toolchain.defs
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,10 @@ CELFFLAGS = $(filter-out --fixed-r9,$(CFLAGS)) -fvisibility=hidden \
CXXELFFLAGS = $(filter-out --fixed-r9,$(CXXFLAGS)) -fvisibility=hidden \
-mlong-calls

# __dso_handle comes from crtbegin, which a module does not link

CXXELFFLAGS += -fno-use-cxa-atexit

ifeq ($(CONFIG_PIC),y)
# ARCHCFLAGS, not CFLAGS: board Make.defs reassign CFLAGS with ':='
# after including this file, which would discard the flag.
Expand Down
4 changes: 4 additions & 0 deletions arch/arm64/src/Toolchain.defs
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,10 @@ LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
CELFFLAGS = $(CFLAGS) -fvisibility=hidden # --target1-abs
CXXELFFLAGS = $(CXXFLAGS) -fvisibility=hidden # --target1-abs

# __dso_handle comes from crtbegin, which a module does not link

CXXELFFLAGS += -fno-use-cxa-atexit

LDELFFLAGS = -r -e _start
ifneq ($(CONFIG_BUILD_KERNEL),y)
# Flat build and protected elf entry point use crt0,
Expand Down
4 changes: 4 additions & 0 deletions arch/avr/src/avr/Toolchain.defs
Original file line number Diff line number Diff line change
Expand Up @@ -219,5 +219,9 @@ LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
CELFFLAGS = $(CFLAGS) -fvisibility=hidden
CXXELFFLAGS = $(CXXFLAGS) -fvisibility=hidden

# __dso_handle comes from crtbegin, which a module does not link

CXXELFFLAGS += -fno-use-cxa-atexit

LDELFFLAGS = -r -e _start
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)elf$(DELIM)gnu-elf.ld)
4 changes: 4 additions & 0 deletions arch/avr/src/avr32/Toolchain.defs
Original file line number Diff line number Diff line change
Expand Up @@ -115,5 +115,9 @@ LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
CELFFLAGS = $(CFLAGS) -fvisibility=hidden
CXXELFFLAGS = $(CXXFLAGS) -fvisibility=hidden

# __dso_handle comes from crtbegin, which a module does not link

CXXELFFLAGS += -fno-use-cxa-atexit

LDELFFLAGS = -r -e _start
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)elf$(DELIM)gnu-elf.ld)
4 changes: 4 additions & 0 deletions arch/mips/src/mips32/Toolchain.defs
Original file line number Diff line number Diff line change
Expand Up @@ -332,5 +332,9 @@ LDMODULEFLAGS = -EL -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld
CELFFLAGS = $(CFLAGS) -fvisibility=hidden
CXXELFFLAGS = $(CXXFLAGS) -fvisibility=hidden

# __dso_handle comes from crtbegin, which a module does not link

CXXELFFLAGS += -fno-use-cxa-atexit

LDELFFLAGS = -r -e _start
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)elf$(DELIM)gnu-elf.ld)
4 changes: 4 additions & 0 deletions arch/misoc/src/lm32/Toolchain.defs
Original file line number Diff line number Diff line change
Expand Up @@ -146,5 +146,9 @@ LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
CELFFLAGS = $(CFLAGS) -fvisibility=hidden
CXXELFFLAGS = $(CXXFLAGS) -fvisibility=hidden

# __dso_handle comes from crtbegin, which a module does not link

CXXELFFLAGS += -fno-use-cxa-atexit

LDELFFLAGS = -r -e _start
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)elf$(DELIM)gnu-elf.ld)
4 changes: 4 additions & 0 deletions arch/misoc/src/minerva/Toolchain.defs
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,9 @@ LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
CELFFLAGS = $(CFLAGS) -fvisibility=hidden
CXXELFFLAGS = $(CXXFLAGS) -fvisibility=hidden

# __dso_handle comes from crtbegin, which a module does not link

CXXELFFLAGS += -fno-use-cxa-atexit

LDELFFLAGS = -r -e _start
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)elf$(DELIM)gnu-elf.ld)
4 changes: 4 additions & 0 deletions arch/or1k/src/mor1kx/Toolchain.defs
Original file line number Diff line number Diff line change
Expand Up @@ -132,5 +132,9 @@ LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
CELFFLAGS = $(CFLAGS) -fvisibility=hidden
CXXELFFLAGS = $(CXXFLAGS) -fvisibility=hidden

# __dso_handle comes from crtbegin, which a module does not link

CXXELFFLAGS += -fno-use-cxa-atexit

LDELFFLAGS = -r -e _start
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)elf$(DELIM)gnu-elf.ld)
4 changes: 4 additions & 0 deletions arch/risc-v/src/common/Toolchain.defs
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,10 @@ LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
CELFFLAGS = $(CFLAGS) -fvisibility=hidden
CXXELFFLAGS = $(CXXFLAGS) -fvisibility=hidden

# __dso_handle comes from crtbegin, which a module does not link

CXXELFFLAGS += -fno-use-cxa-atexit

LDELFFLAGS = -e _start

ifeq ($(CONFIG_BINFMT_ELF_RELOCATABLE),y)
Expand Down
4 changes: 4 additions & 0 deletions arch/sparc/src/sparc_v8/Toolchain.defs
Original file line number Diff line number Diff line change
Expand Up @@ -137,5 +137,9 @@ LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
CELFFLAGS = $(CFLAGS) -fvisibility=hidden
CXXELFFLAGS = $(CXXFLAGS) -fvisibility=hidden

# __dso_handle comes from crtbegin, which a module does not link

CXXELFFLAGS += -fno-use-cxa-atexit

LDELFFLAGS = -r -e _start
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)elf$(DELIM)gnu-elf.ld)
4 changes: 4 additions & 0 deletions arch/x86/src/common/Toolchain.defs
Original file line number Diff line number Diff line change
Expand Up @@ -106,5 +106,9 @@ LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
CELFFLAGS = $(CFLAGS) -fvisibility=hidden
CXXELFFLAGS = $(CXXFLAGS) -fvisibility=hidden

# __dso_handle comes from crtbegin, which a module does not link

CXXELFFLAGS += -fno-use-cxa-atexit

LDELFFLAGS = -r -e _start
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)elf$(DELIM)gnu-elf.ld)
4 changes: 4 additions & 0 deletions arch/x86_64/src/common/Toolchain.defs
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,10 @@ endif
CELFFLAGS = $(CFLAGS) -fvisibility=hidden
CXXELFFLAGS = $(CXXFLAGS) -fvisibility=hidden

# __dso_handle comes from crtbegin, which a module does not link

CXXELFFLAGS += -fno-use-cxa-atexit

LDELFFLAGS = -r -e _start
ifneq ($(CONFIG_BUILD_KERNEL),y)
# Flat build and protected elf entry point use crt0,
Expand Down
4 changes: 4 additions & 0 deletions arch/xtensa/src/lx6/Toolchain.defs
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,10 @@ LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
CELFFLAGS = $(CFLAGS) -fvisibility=hidden -mtext-section-literals
CXXELFFLAGS = $(CXXFLAGS) -fvisibility=hidden -mtext-section-literals

# __dso_handle comes from crtbegin, which a module does not link

CXXELFFLAGS += -fno-use-cxa-atexit

LDELFFLAGS = -r -e _start
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)elf$(DELIM)gnu-elf.ld)
ifneq ($(CONFIG_BUILD_KERNEL),y)
Expand Down
4 changes: 4 additions & 0 deletions arch/xtensa/src/lx7/Toolchain.defs
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,10 @@ LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
CELFFLAGS = $(CFLAGS) -fvisibility=hidden -mtext-section-literals
CXXELFFLAGS = $(CXXFLAGS) -fvisibility=hidden -mtext-section-literals

# __dso_handle comes from crtbegin, which a module does not link

CXXELFFLAGS += -fno-use-cxa-atexit

LDELFFLAGS = -r -e _start
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)elf$(DELIM)gnu-elf.ld)
ifneq ($(CONFIG_BUILD_KERNEL),y)
Expand Down
4 changes: 4 additions & 0 deletions boards/arm/sama5/sama5d3-xplained/scripts/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,9 @@ LDNXFLATFLAGS = -e main -s 2048
CELFFLAGS = $(CFLAGS) -mlong-calls # --target1-abs
CXXELFFLAGS = $(CXXFLAGS) -mlong-calls # --target1-abs

# __dso_handle comes from crtbegin, which a module does not link

CXXELFFLAGS += -fno-use-cxa-atexit

LDELFFLAGS = -r -e main
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
4 changes: 4 additions & 0 deletions boards/arm/stm32h7/devebox-stm32h743/scripts/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,9 @@ LDNXFLATFLAGS = -e main -s 2048
CELFFLAGS = $(CFLAGS) -mlong-calls # --target1-abs
CXXELFFLAGS = $(CXXFLAGS) -mlong-calls # --target1-abs

# __dso_handle comes from crtbegin, which a module does not link

CXXELFFLAGS += -fno-use-cxa-atexit

LDELFFLAGS = -r -e main
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/binfmt/elf/gnu-elf.ld)
4 changes: 4 additions & 0 deletions boards/arm/stm32h7/linum-stm32h753bi/scripts/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,9 @@ LDNXFLATFLAGS = -e main -s 2048
CELFFLAGS = $(CFLAGS) -mlong-calls # --target1-abs
CXXELFFLAGS = $(CXXFLAGS) -mlong-calls # --target1-abs

# __dso_handle comes from crtbegin, which a module does not link

CXXELFFLAGS += -fno-use-cxa-atexit

LDELFFLAGS = -r -e main
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/binfmt/elf/gnu-elf.ld)
4 changes: 4 additions & 0 deletions boards/arm/stm32h7/openh743i/scripts/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,9 @@ LDNXFLATFLAGS = -e main -s 2048
CELFFLAGS = $(CFLAGS) -mlong-calls # --target1-abs
CXXELFFLAGS = $(CXXFLAGS) -mlong-calls # --target1-abs

# __dso_handle comes from crtbegin, which a module does not link

CXXELFFLAGS += -fno-use-cxa-atexit

LDELFFLAGS = -r -e main
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/binfmt/elf/gnu-elf.ld)
4 changes: 4 additions & 0 deletions boards/arm/stm32h7/weact-stm32h743/scripts/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,9 @@ LDNXFLATFLAGS = -e main -s 2048
CELFFLAGS = $(CFLAGS) -mlong-calls # --target1-abs
CXXELFFLAGS = $(CXXFLAGS) -mlong-calls # --target1-abs

# __dso_handle comes from crtbegin, which a module does not link

CXXELFFLAGS += -fno-use-cxa-atexit

LDELFFLAGS = -r -e main
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/binfmt/elf/gnu-elf.ld)
4 changes: 4 additions & 0 deletions boards/arm/stm32h7/weact-stm32h750/scripts/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,9 @@ LDNXFLATFLAGS = -e main -s 2048
CELFFLAGS = $(CFLAGS) -mlong-calls # --target1-abs
CXXELFFLAGS = $(CXXFLAGS) -mlong-calls # --target1-abs

# __dso_handle comes from crtbegin, which a module does not link

CXXELFFLAGS += -fno-use-cxa-atexit

LDELFFLAGS = -r -e main
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/binfmt/elf/gnu-elf.ld)
4 changes: 4 additions & 0 deletions boards/risc-v/esp32c6/esp32c6-devkitc/scripts/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,9 @@ LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
CELFFLAGS = $(CFLAGS)
CXXELFFLAGS = $(CXXFLAGS)

# __dso_handle comes from crtbegin, which a module does not link

CXXELFFLAGS += -fno-use-cxa-atexit

LDELFFLAGS = -melf32lriscv -r -e main
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/binfmt/elf/gnu-elf.ld)
4 changes: 4 additions & 0 deletions boards/risc-v/esp32c6/esp32c6-xiao/scripts/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,9 @@ LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
CELFFLAGS = $(CFLAGS)
CXXELFFLAGS = $(CXXFLAGS)

# __dso_handle comes from crtbegin, which a module does not link

CXXELFFLAGS += -fno-use-cxa-atexit

LDELFFLAGS = -melf32lriscv -r -e main
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/binfmt/elf/gnu-elf.ld)
5 changes: 5 additions & 0 deletions boards/sim/sim/sim/scripts/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,11 @@ endif

CELFFLAGS = $(CFLAGS) -fvisibility=hidden
CXXELFFLAGS = $(CXXFLAGS) -fvisibility=hidden

# __dso_handle comes from crtbegin, which a module does not link

CXXELFFLAGS += -fno-use-cxa-atexit

# -fno-pic to avoid GOT relocations
CELFFLAGS += -fno-pic
CXXELFFLAGS += -fno-pic
Expand Down
4 changes: 4 additions & 0 deletions boards/xtensa/esp32/esp32-2432S028/scripts/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,9 @@ LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
CELFFLAGS = $(CFLAGS) -mtext-section-literals
CXXELFFLAGS = $(CXXFLAGS) -mtext-section-literals

# __dso_handle comes from crtbegin, which a module does not link

CXXELFFLAGS += -fno-use-cxa-atexit

LDELFFLAGS = -r -e main
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)binfmt$(DELIM)elf$(DELIM)gnu-elf.ld)
4 changes: 4 additions & 0 deletions boards/xtensa/esp32s3/esp32s3-korvo-2/scripts/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,9 @@ LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
CELFFLAGS = $(CFLAGS) -mtext-section-literals
CXXELFFLAGS = $(CXXFLAGS) -mtext-section-literals

# __dso_handle comes from crtbegin, which a module does not link

CXXELFFLAGS += -fno-use-cxa-atexit

LDELFFLAGS = -r -e main
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/binfmt/elf/gnu-elf.ld)
4 changes: 4 additions & 0 deletions boards/xtensa/esp32s3/esp32s3-lhcbit/scripts/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,9 @@ LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
CELFFLAGS = $(CFLAGS) -mtext-section-literals
CXXELFFLAGS = $(CXXFLAGS) -mtext-section-literals

# __dso_handle comes from crtbegin, which a module does not link

CXXELFFLAGS += -fno-use-cxa-atexit

LDELFFLAGS = -r -e main
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/binfmt/elf/gnu-elf.ld)
4 changes: 4 additions & 0 deletions boards/xtensa/esp32s3/esp32s3-touch-lcd7/scripts/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,9 @@ LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
CELFFLAGS = $(CFLAGS) -mtext-section-literals
CXXELFFLAGS = $(CXXFLAGS) -mtext-section-literals

# __dso_handle comes from crtbegin, which a module does not link

CXXELFFLAGS += -fno-use-cxa-atexit

LDELFFLAGS = -r -e main
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/binfmt/elf/gnu-elf.ld)
4 changes: 4 additions & 0 deletions boards/xtensa/esp32s3/esp32s3-xiao/scripts/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,9 @@ LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
CELFFLAGS = $(CFLAGS) -mtext-section-literals
CXXELFFLAGS = $(CXXFLAGS) -mtext-section-literals

# __dso_handle comes from crtbegin, which a module does not link

CXXELFFLAGS += -fno-use-cxa-atexit

LDELFFLAGS = -r -e main
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/binfmt/libelf/gnu-elf.ld)
Loading