Skip to content

Commit

Permalink
apps/examples/module: When built in the PROTECTED or KERNEL modes, th…
Browse files Browse the repository at this point in the history
…e 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.
  • Loading branch information
gregory-nutt committed Aug 7, 2018
1 parent 303629d commit 057eb80
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
6 changes: 5 additions & 1 deletion examples/module/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
10 changes: 9 additions & 1 deletion examples/module/drivers/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

Expand Down Expand Up @@ -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)
Expand Down
10 changes: 9 additions & 1 deletion examples/module/module_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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)
Expand Down

0 comments on commit 057eb80

Please sign in to comment.