sim: Sync Linux CMODULEFLAGS with macOS
Namely, always use -mcmodel=large. NuttX modules are loaded into the NuttX heap, which can be out of range for 32-bit relocations generated with -mcmodel=small. A possible alternative would be to use MAP_32BIT to allocate sim heap. But I prefer this approach because it's very convenient for me to be able to share modules between Linux and macOS sim.
This commit is contained in:
parent
e7f2dc8173
commit
b8b2ac4f2c
|
@ -82,6 +82,12 @@ AFLAGS = $(CFLAGS) -D__ASSEMBLY__
|
|||
CMODULEFLAGS = $(CFLAGS)
|
||||
# -fno-pic to avoid GOT relocations
|
||||
CMODULEFLAGS += -fno-pic
|
||||
# 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.
|
||||
# Even on Linux, NuttX modules are loaded into the NuttX heap, which
|
||||
# can be out of range with -mcmodel=small.
|
||||
CMODULEFLAGS += -mcmodel=large
|
||||
|
||||
LDMODULEFLAGS = -r -e module_initialize
|
||||
ifeq ($(CONFIG_CYGWIN_WINTOOL),y)
|
||||
|
@ -97,10 +103,6 @@ ifeq ($(CONFIG_HOST_MACOS),y)
|
|||
MODULECC = x86_64-elf-gcc
|
||||
MODULELD = x86_64-elf-ld
|
||||
MODULESTRIP = x86_64-elf-strip --strip-unneeded
|
||||
# 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
|
||||
|
|
|
@ -77,6 +77,12 @@ AFLAGS = $(CFLAGS) -D__ASSEMBLY__
|
|||
CMODULEFLAGS = $(CFLAGS)
|
||||
# -fno-pic to avoid GOT relocations
|
||||
CMODULEFLAGS += -fno-pic
|
||||
# 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.
|
||||
# Even on Linux, NuttX modules are loaded into the NuttX heap, which
|
||||
# can be out of range with -mcmodel=small.
|
||||
CMODULEFLAGS += -mcmodel=large
|
||||
|
||||
LDMODULEFLAGS = -r -e module_initialize
|
||||
ifeq ($(CONFIG_CYGWIN_WINTOOL),y)
|
||||
|
@ -92,10 +98,6 @@ ifeq ($(CONFIG_HOST_MACOS),y)
|
|||
MODULECC = x86_64-elf-gcc
|
||||
MODULELD = x86_64-elf-ld
|
||||
MODULESTRIP = x86_64-elf-strip --strip-unneeded
|
||||
# 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
|
||||
|
|
Loading…
Reference in New Issue