From 3ead7795b2d303c45cfc1cda66063e14b271d443 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Fri, 14 Feb 2020 02:11:57 +0900 Subject: [PATCH] sim: Add loadable module definitions Also, add -fno-pic to avoid generating GOT relocations. --- boards/sim/sim/sim/configs/cxxtest/Make.defs | 17 +++++++++++++++++ boards/sim/sim/sim/configs/nsh2/Make.defs | 17 +++++++++++++++++ boards/sim/sim/sim/scripts/Make.defs | 17 +++++++++++++++++ 3 files changed, 51 insertions(+) diff --git a/boards/sim/sim/sim/configs/cxxtest/Make.defs b/boards/sim/sim/sim/configs/cxxtest/Make.defs index 7a21d73d25..8c9bc28ee8 100644 --- a/boards/sim/sim/sim/configs/cxxtest/Make.defs +++ b/boards/sim/sim/sim/configs/cxxtest/Make.defs @@ -88,11 +88,26 @@ CXXFLAGS = $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) \ CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) AFLAGS = $(CFLAGS) -D__ASSEMBLY__ +# Loadable module definitions + +CMODULEFLAGS = $(CFLAGS) +# -fno-pic to avoid GOT relocations +CMODULEFLAGS += -fno-pic + +LDMODULEFLAGS = -r -e module_initialize +ifeq ($(WINTOOL),y) + LDMODULEFLAGS += -T "${shell cygpath -w $(TOPDIR)/libs/libc/modlib/gnu-elf.ld}" +else + LDMODULEFLAGS += -T $(TOPDIR)/libs/libc/modlib/gnu-elf.ld +endif # ELF module definitions CELFFLAGS = $(CFLAGS) CXXELFFLAGS = $(CXXFLAGS) +# -fno-pic to avoid GOT relocations +CELFFLAGS += -fno-pic +CXXELFFLAGS += -fno-pic LDELFFLAGS = -r -e main ifeq ($(WINTOOL),y) @@ -128,6 +143,8 @@ ifeq ($(CONFIG_SIM_M32),y) LDLINKFLAGS += -melf_i386 CCLINKFLAGS += -m32 LDFLAGS += -m32 + LDMODULEFLAGS += -melf_i386 + LDELFFLAGS += -melf_i386 HOSTLDFLAGS += -m32 endif diff --git a/boards/sim/sim/sim/configs/nsh2/Make.defs b/boards/sim/sim/sim/configs/nsh2/Make.defs index 778280b1dd..a0cee95d45 100644 --- a/boards/sim/sim/sim/configs/nsh2/Make.defs +++ b/boards/sim/sim/sim/configs/nsh2/Make.defs @@ -84,11 +84,26 @@ CXXFLAGS = $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) \ CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) AFLAGS = $(CFLAGS) -D__ASSEMBLY__ +# Loadable module definitions + +CMODULEFLAGS = $(CFLAGS) +# -fno-pic to avoid GOT relocations +CMODULEFLAGS += -fno-pic + +LDMODULEFLAGS = -r -e module_initialize +ifeq ($(WINTOOL),y) + LDMODULEFLAGS += -T "${shell cygpath -w $(TOPDIR)/libs/libc/modlib/gnu-elf.ld}" +else + LDMODULEFLAGS += -T $(TOPDIR)/libs/libc/modlib/gnu-elf.ld +endif # ELF module definitions CELFFLAGS = $(CFLAGS) CXXELFFLAGS = $(CXXFLAGS) +# -fno-pic to avoid GOT relocations +CELFFLAGS += -fno-pic +CXXELFFLAGS += -fno-pic LDELFFLAGS = -r -e main ifeq ($(WINTOOL),y) @@ -120,6 +135,8 @@ ifeq ($(CONFIG_SIM_M32),y) LDLINKFLAGS += -melf_i386 CCLINKFLAGS += -m32 LDFLAGS += -m32 + LDMODULEFLAGS += -melf_i386 + LDELFFLAGS += -melf_i386 HOSTLDFLAGS += -m32 endif diff --git a/boards/sim/sim/sim/scripts/Make.defs b/boards/sim/sim/sim/scripts/Make.defs index b2164c6e71..d577d3691d 100644 --- a/boards/sim/sim/sim/scripts/Make.defs +++ b/boards/sim/sim/sim/scripts/Make.defs @@ -91,11 +91,26 @@ CXXFLAGS = $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) \ CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) AFLAGS = $(CFLAGS) -D__ASSEMBLY__ +# Loadable module definitions + +CMODULEFLAGS = $(CFLAGS) +# -fno-pic to avoid GOT relocations +CMODULEFLAGS += -fno-pic + +LDMODULEFLAGS = -r -e module_initialize +ifeq ($(WINTOOL),y) + LDMODULEFLAGS += -T "${shell cygpath -w $(TOPDIR)/libs/libc/modlib/gnu-elf.ld}" +else + LDMODULEFLAGS += -T $(TOPDIR)/libs/libc/modlib/gnu-elf.ld +endif # ELF module definitions CELFFLAGS = $(CFLAGS) CXXELFFLAGS = $(CXXFLAGS) +# -fno-pic to avoid GOT relocations +CELFFLAGS += -fno-pic +CXXELFFLAGS += -fno-pic LDELFFLAGS = -r -e main ifeq ($(WINTOOL),y) @@ -127,6 +142,8 @@ ifeq ($(CONFIG_SIM_M32),y) LDLINKFLAGS += -melf_i386 CCLINKFLAGS += -m32 LDFLAGS += -m32 + LDMODULEFLAGS += -melf_i386 + LDELFFLAGS += -melf_i386 HOSTLDFLAGS += -m32 endif