diff --git a/boards/sim/sim/sim/configs/cxxtest/Make.defs b/boards/sim/sim/sim/configs/cxxtest/Make.defs index 633eed8e9e..dfab86026c 100644 --- a/boards/sim/sim/sim/configs/cxxtest/Make.defs +++ b/boards/sim/sim/sim/configs/cxxtest/Make.defs @@ -86,6 +86,18 @@ else LDMODULEFLAGS += -T $(TOPDIR)/libs/libc/modlib/gnu-elf.ld endif +# NuttX modules are ELF binaries. +# Non-ELF platforms like macOS need to use a separate ELF toolchain. +ifeq ($(CONFIG_HOST_MACOS),y) + # eg. brew install x86_64-elf-gcc + MODULECC = x86_64-elf-gcc + MODULELD = x86_64-elf-ld + # It seems macOS/x86_64 loads the program text around 00000001_xxxxxxxx. + # The gcc default (-mcmodel=small) would produce out-of-range 32-bit + # relocations. + CMODULEFLAGS += -mcmodel=large +endif + # ELF module definitions CELFFLAGS = $(CFLAGS) diff --git a/boards/sim/sim/sim/configs/nsh2/Make.defs b/boards/sim/sim/sim/configs/nsh2/Make.defs index 21e67fc703..4b187580f3 100644 --- a/boards/sim/sim/sim/configs/nsh2/Make.defs +++ b/boards/sim/sim/sim/configs/nsh2/Make.defs @@ -82,6 +82,18 @@ else LDMODULEFLAGS += -T $(TOPDIR)/libs/libc/modlib/gnu-elf.ld endif +# NuttX modules are ELF binaries. +# Non-ELF platforms like macOS need to use a separate ELF toolchain. +ifeq ($(CONFIG_HOST_MACOS),y) + # eg. brew install x86_64-elf-gcc + MODULECC = x86_64-elf-gcc + MODULELD = x86_64-elf-ld + # It seems macOS/x86_64 loads the program text around 00000001_xxxxxxxx. + # The gcc default (-mcmodel=small) would produce out-of-range 32-bit + # relocations. + CMODULEFLAGS += -mcmodel=large +endif + # ELF module definitions CELFFLAGS = $(CFLAGS) diff --git a/boards/sim/sim/sim/scripts/Make.defs b/boards/sim/sim/sim/scripts/Make.defs index c49735ee86..c338812976 100644 --- a/boards/sim/sim/sim/scripts/Make.defs +++ b/boards/sim/sim/sim/scripts/Make.defs @@ -88,6 +88,18 @@ else LDMODULEFLAGS += -T $(TOPDIR)/libs/libc/modlib/gnu-elf.ld endif +# NuttX modules are ELF binaries. +# Non-ELF platforms like macOS need to use a separate ELF toolchain. +ifeq ($(CONFIG_HOST_MACOS),y) + # eg. brew install x86_64-elf-gcc + MODULECC = x86_64-elf-gcc + MODULELD = x86_64-elf-ld + # It seems macOS/x86_64 loads the program text around 00000001_xxxxxxxx. + # The gcc default (-mcmodel=small) would produce out-of-range 32-bit + # relocations. + CMODULEFLAGS += -mcmodel=large +endif + # ELF module definitions CELFFLAGS = $(CFLAGS)