apps/examples/module: When built in the PROTECTED or KERNEL modes, the symbol table is not built by the application. That is because the build will fail since the kernel module depends on internal OS symbols thar are not available to the appliatino build. With this change the examples does not attempt to build the kernel symbol table in these modes. Instead it just copies the kernel module symbol table into the nuttx/pass1 directory where it can be build directly into the OS during pass2 of the build.
This commit is contained in:
parent
303629dbe4
commit
057eb80564
@ -50,9 +50,13 @@ STACKSIZE = 2048
|
||||
# Module Example
|
||||
|
||||
ASRCS =
|
||||
CSRCS = mod_symtab.c
|
||||
CSRCS =
|
||||
MAINSRC = module_main.c
|
||||
|
||||
ifeq ($(CONFIG_BUILD_FLAT),y)
|
||||
CSRCS += mod_symtab.c
|
||||
endif
|
||||
|
||||
AOBJS = $(ASRCS:.S=$(OBJEXT))
|
||||
COBJS = $(CSRCS:.c=$(OBJEXT))
|
||||
MAINOBJ = $(MAINSRC:.c=$(OBJEXT))
|
||||
|
@ -45,6 +45,7 @@ MODULE_DIR = $(APPDIR)/examples/module
|
||||
DRIVER_DIR = $(MODULE_DIR)/drivers
|
||||
FSROOT_DIR = $(DRIVER_DIR)/fsroot
|
||||
SYMTAB_SRC = $(DRIVER_DIR)/mod_symtab.c
|
||||
PASS1_SYMTAB = $(TOPDIR)/pass1/mod_symtab.c
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_MODULE_ROMFS),y)
|
||||
ROMFS_IMG = $(DRIVER_DIR)/romfs.img
|
||||
@ -62,7 +63,7 @@ $(1)_$(2):
|
||||
$(Q) $(MAKE) -C $(1) $(3) TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" FSROOT_DIR="$(FSROOT_DIR)" CROSSDEV=$(CROSSDEV)
|
||||
endef
|
||||
|
||||
all: $(FSIMG_HDR) $(DIRLIST_HDR) $(SYMTAB_SRC)
|
||||
all: $(FSIMG_HDR) $(DIRLIST_HDR) $(SYMTAB_SRC) $(PASS1_SYMTAB)
|
||||
.PHONY: all build clean install populate
|
||||
.PRECIOUS: ../../../libapps$(LIBEXT)
|
||||
|
||||
@ -135,6 +136,13 @@ $(SYMTAB_SRC): build populate
|
||||
|
||||
endif
|
||||
|
||||
# Copy the symbol table into the kernel pass1/ build directory
|
||||
|
||||
$(PASS1_SYMTAB): $(SYMTAB_SRC)
|
||||
ifneq ($(CONFIG_BUILD_FLAT),y)
|
||||
$(Q) install -m 0644 $(SYMTAB_SRC) $(PASS1_SYMTAB)
|
||||
endif
|
||||
|
||||
# Clean each subdirectory
|
||||
|
||||
clean: $(foreach DIR, $(ALL_SUBDIRS), $(DIR)_clean)
|
||||
|
@ -134,8 +134,10 @@ static const char g_write_string[] = "Hi there, installed driver\n";
|
||||
* Symbols from Auto-Generated Code
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_BUILD_FLAT
|
||||
extern const struct symtab_s g_mod_exports[];
|
||||
extern const int g_mod_nexports;
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
@ -151,8 +153,12 @@ int main(int argc, FAR char *argv[])
|
||||
int module_main(int argc, char *argv[])
|
||||
#endif
|
||||
{
|
||||
#ifdef CONFIG_BUILD_FLAT
|
||||
struct boardioc_symtab_s symdesc;
|
||||
#ifdef CONFIG_EXAMPLES_MODULE_FSREMOVEABLE
|
||||
#endif
|
||||
#if defined(CONFIG_EXAMPLES_MODULE_EXTERN) && \
|
||||
defined(CONFIG_EXAMPLES_MODULE_FSMOUNT) && \
|
||||
defined(CONFIG_EXAMPLES_MODULE_FSREMOVEABLE)
|
||||
struct stat buf;
|
||||
#endif
|
||||
FAR void *handle;
|
||||
@ -161,6 +167,7 @@ int module_main(int argc, char *argv[])
|
||||
int ret;
|
||||
int fd;
|
||||
|
||||
#ifdef CONFIG_BUILD_FLAT
|
||||
/* Set the OS symbol table indirectly through the boardctl() */
|
||||
|
||||
symdesc.symtab = (FAR struct symtab_s *)g_mod_exports;
|
||||
@ -171,6 +178,7 @@ int module_main(int argc, char *argv[])
|
||||
fprintf(stderr, "ERROR: boardctl(BOARDIOC_OS_SYMTAB) failed: %d\n", ret);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_MODULE_BUILTINFS
|
||||
#if defined(CONFIG_EXAMPLES_MODULE_ROMFS)
|
||||
|
Loading…
Reference in New Issue
Block a user