examples/module. Module should not link with libc because it has out-of-range function calls

This commit is contained in:
Gregory Nutt 2015-12-12 14:00:34 -06:00
parent ad4bcac7a0
commit 052392f36c
3 changed files with 18 additions and 2 deletions

View File

@ -14,7 +14,7 @@ if EXAMPLES_MODULE
config EXAMPLES_MODULE_LIBC config EXAMPLES_MODULE_LIBC
bool "Link with LIBC" bool "Link with LIBC"
default n default n
depends on !BUILD_KERNEL depends on !BUILD_KERNEL && EXPERIMENTAL
---help--- ---help---
Link with the C library (and also math library if it was built). Link with the C library (and also math library if it was built).
By default, all undefined symbols must be provided via a symbol By default, all undefined symbols must be provided via a symbol
@ -26,6 +26,15 @@ config EXAMPLES_MODULE_LIBC
program greatly increasing the total code size. This option is program greatly increasing the total code size. This option is
primarily intended only for testing. primarily intended only for testing.
WARNING: Libc will not be built with -mlong-calls and this may
result in runtime linking failures due to out-of-range functions
calls.
config EXAMPLES_MODULE_LIBGCC
bool "Link with LIBGCC"
default n
depends on !BUILD_KERNEL && EXPERIMENTAL
config EXAMPLES_MODULE_DEVMINOR config EXAMPLES_MODULE_DEVMINOR
int "ROMFS Minor Device Number" int "ROMFS Minor Device Number"
default 0 default 0

View File

@ -2,5 +2,4 @@
/romfs.h /romfs.h
/romfs.img /romfs.img
/symtab.c /symtab.c
/varlist.tmp

View File

@ -44,6 +44,14 @@ endif
KDEFINE = ${shell $(TOPDIR)/tools/define.sh "$(CC)" __KERNEL__} KDEFINE = ${shell $(TOPDIR)/tools/define.sh "$(CC)" __KERNEL__}
CFLAGS += $(KDEFINE) CFLAGS += $(KDEFINE)
ifeq ($(CONFIG_EXAMPLES_MODULE_LIBGCC),y)
LIBGCC = "${shell $(CC) $(ARCHCPUFLAGS) -print-libgcc-file-name 2>/dev/null}"
ifneq ($(LIBGCC),)
LDLIBPATH += -L "${shell dirname $(LIBGCC)}"
LDLIBS += -lgcc
endif
endif
ifeq ($(CONFIG_EXAMPLES_MODULE_LIBC),y) ifeq ($(CONFIG_EXAMPLES_MODULE_LIBC),y)
LDMODULEFLAGS += -Bstatic LDMODULEFLAGS += -Bstatic
LDLIBPATH += -L $(NUTTXLIB) LDLIBPATH += -L $(NUTTXLIB)