From 3ee97561586102398d9226c7a3b30049488ba58e Mon Sep 17 00:00:00 2001 From: anjiahao Date: Wed, 18 Jun 2025 14:26:57 +0800 Subject: [PATCH 1/4] apps:modify examples elf compile method rearrange the elf test directory, make the sub-testcase in separate directory Signed-off-by: anjiahao --- examples/elf/.gitignore | 1 + examples/elf/CMakeLists.txt | 8 +- examples/elf/Make.defs | 4 +- examples/elf/Makefile | 45 +------- examples/elf/main/.gitignore | 4 + examples/elf/main/CMakeLists.txt | 26 +++++ examples/elf/{ => main}/Kconfig | 0 examples/elf/main/Make.defs | 23 ++++ examples/elf/main/Makefile | 100 ++++++++++++++++++ examples/elf/{ => main}/elf_main.c | 33 +++++- examples/elf/tests/.gitignore | 1 + examples/elf/tests/Make.defs | 39 +++++++ examples/elf/tests/Makefile | 132 +---------------------- examples/elf/tests/errno/Kconfig | 4 + examples/elf/tests/errno/Makefile | 51 ++------- examples/elf/tests/hello/Kconfig | 4 + examples/elf/tests/hello/Makefile | 51 ++------- examples/elf/tests/helloxx/Kconfig | 4 + examples/elf/tests/helloxx/Makefile | 157 ++-------------------------- examples/elf/tests/longjmp/Kconfig | 4 + examples/elf/tests/longjmp/Makefile | 51 ++------- examples/elf/tests/mutex/Kconfig | 4 + examples/elf/tests/mutex/Makefile | 51 ++------- examples/elf/tests/pthread/Kconfig | 4 + examples/elf/tests/pthread/Makefile | 51 ++------- examples/elf/tests/signal/Kconfig | 4 + examples/elf/tests/signal/Makefile | 51 ++------- examples/elf/tests/struct/Kconfig | 4 + examples/elf/tests/struct/Makefile | 53 ++-------- examples/elf/tests/task/Kconfig | 4 + examples/elf/tests/task/Makefile | 51 ++------- 31 files changed, 327 insertions(+), 692 deletions(-) create mode 100644 examples/elf/.gitignore create mode 100644 examples/elf/main/.gitignore create mode 100644 examples/elf/main/CMakeLists.txt rename examples/elf/{ => main}/Kconfig (100%) create mode 100644 examples/elf/main/Make.defs create mode 100644 examples/elf/main/Makefile rename examples/elf/{ => main}/elf_main.c (96%) create mode 100644 examples/elf/tests/Make.defs create mode 100644 examples/elf/tests/errno/Kconfig create mode 100644 examples/elf/tests/hello/Kconfig create mode 100644 examples/elf/tests/helloxx/Kconfig create mode 100644 examples/elf/tests/longjmp/Kconfig create mode 100644 examples/elf/tests/mutex/Kconfig create mode 100644 examples/elf/tests/pthread/Kconfig create mode 100644 examples/elf/tests/signal/Kconfig create mode 100644 examples/elf/tests/struct/Kconfig create mode 100644 examples/elf/tests/task/Kconfig diff --git a/examples/elf/.gitignore b/examples/elf/.gitignore new file mode 100644 index 00000000000..9e1d2593ee8 --- /dev/null +++ b/examples/elf/.gitignore @@ -0,0 +1 @@ +/Kconfig diff --git a/examples/elf/CMakeLists.txt b/examples/elf/CMakeLists.txt index 3ca9eeb4b47..f5b2b0ee67e 100644 --- a/examples/elf/CMakeLists.txt +++ b/examples/elf/CMakeLists.txt @@ -20,9 +20,5 @@ # # ############################################################################## -if(CONFIG_EXAMPLES_ELF) - nuttx_add_application(NAME elf SRCS elf_main.c) - - # TODO: tests - -endif() +nuttx_add_subdirectory() +nuttx_generate_kconfig(MENUDESC "Elf") diff --git a/examples/elf/Make.defs b/examples/elf/Make.defs index e01a9d0ddb1..fe9092e3b3c 100644 --- a/examples/elf/Make.defs +++ b/examples/elf/Make.defs @@ -20,6 +20,4 @@ # ############################################################################ -ifneq ($(CONFIG_EXAMPLES_ELF),) -CONFIGURED_APPS += $(APPDIR)/examples/elf -endif +include $(wildcard $(APPDIR)/examples/elf/*/Make.defs) diff --git a/examples/elf/Makefile b/examples/elf/Makefile index 8d1e32f139f..cde6ca47de5 100644 --- a/examples/elf/Makefile +++ b/examples/elf/Makefile @@ -20,47 +20,6 @@ # ############################################################################ -include $(APPDIR)/Make.defs +MENUDESC = "Elf example" -# ELF Example - -ifeq ($(CONFIG_EXAMPLES_ELF_ROMFS),y) -CSRCS = romfs.c -endif -ifeq ($(CONFIG_EXAMPLES_ELF_CROMFS),y) -CSRCS = cromfs.c -endif -CSRCS += dirlist.c -CSRCS += symtab.c -tests$(DELIM)symtab.c_CFLAGS = -fno-builtin -tests$(DELIM)symtab.c_CELFFLAGS = -fno-builtin -MAINSRC = elf_main.c - -PROGNAME = elf -PRIORITY = SCHED_PRIORITY_DEFAULT -STACKSIZE = $(CONFIG_DEFAULT_TASK_STACKSIZE) -MODULE = $(CONFIG_EXAMPLES_ELF) - -DEPPATH := --dep-path tests - -# Build targets - -VPATH += :tests - -ifeq ($(CONFIG_EXAMPLES_ELF_ROMFS),y) -tests/romfs.c: build -endif -ifeq ($(CONFIG_EXAMPLES_ELF_CROMFS),y) -tests/cromfs.c: build -endif -tests/dirlist.c: build -tests/symtab.c: build - -.PHONY: build -build: - +$(Q) $(MAKE) -C tests TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" CROSSDEV=$(CROSSDEV) - -clean:: - +$(Q) $(MAKE) -C tests TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" CROSSDEV=$(CROSSDEV) clean - -include $(APPDIR)/Application.mk +include $(APPDIR)/Directory.mk diff --git a/examples/elf/main/.gitignore b/examples/elf/main/.gitignore new file mode 100644 index 00000000000..17739289c11 --- /dev/null +++ b/examples/elf/main/.gitignore @@ -0,0 +1,4 @@ +/elf_romfs.c +/elf_romfs.img +/cromfs.c +/test_symtab.c diff --git a/examples/elf/main/CMakeLists.txt b/examples/elf/main/CMakeLists.txt new file mode 100644 index 00000000000..3ae5a347e50 --- /dev/null +++ b/examples/elf/main/CMakeLists.txt @@ -0,0 +1,26 @@ +# ############################################################################## +# apps/examples/elf/main/CMakeLists.txt +# +# Licensed to the Apache Software Foundation (ASF) under one or more contributor +# license agreements. See the NOTICE file distributed with this work for +# additional information regarding copyright ownership. The ASF licenses this +# file to you under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +# +# ############################################################################## + +if(CONFIG_EXAMPLES_ELF) + nuttx_add_application(NAME elf SRCS elf_main.c) + + # TODO: tests + +endif() diff --git a/examples/elf/Kconfig b/examples/elf/main/Kconfig similarity index 100% rename from examples/elf/Kconfig rename to examples/elf/main/Kconfig diff --git a/examples/elf/main/Make.defs b/examples/elf/main/Make.defs new file mode 100644 index 00000000000..bc5af530015 --- /dev/null +++ b/examples/elf/main/Make.defs @@ -0,0 +1,23 @@ +############################################################################ +# apps/examples/elf/main/Make.defs +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +############################################################################ + +ifneq ($(CONFIG_EXAMPLES_ELF),) +CONFIGURED_APPS += $(APPDIR)/examples/elf/main +endif diff --git a/examples/elf/main/Makefile b/examples/elf/main/Makefile new file mode 100644 index 00000000000..0cb59156bbf --- /dev/null +++ b/examples/elf/main/Makefile @@ -0,0 +1,100 @@ +############################################################################ +# apps/examples/elf/main/Makefile +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +############################################################################ + +include $(APPDIR)/Make.defs + +# Module example built-in application info + +PROGNAME = elf +PRIORITY = SCHED_PRIORITY_DEFAULT +STACKSIZE = $(CONFIG_DEFAULT_TASK_STACKSIZE) +MODULE = $(CONFIG_EXAMPLES_ELF) + +MAINSRC = elf_main.c + +SYMTABSRC = test_symtab.c +SYMTABOBJ = $(SYMTABSRC:.c=$(OBJEXT)) + + +ifneq ($(CONFIG_BUILD_FLAT),y) + PASS1_SYMTAB = $(TOPDIR)/pass1/mod_symtab.c + MODLUE_NAME = tests +endif + +$(SYMTABSRC): + $(Q) $(APPDIR)$(DELIM)tools$(DELIM)mksymtab.sh $(BINDIR) g_elf >$@.tmp + $(Q) $(call TESTANDREPLACEFILE, $@.tmp, $@) + + +$(SYMTABOBJ): %$(OBJEXT): %.c + $(call COMPILE, $<, $@, -fno-lto -fno-builtin) + +ifeq ($(CONFIG_EXAMPLES_ELF_ROMFS),y) + +ROMFSIMG = elf_romfs.img +ROMFSSRC = elf_romfs.c +ROMFSOBJ = $(ROMFSSRC:.c=$(OBJEXT)) + +$(ROMFSIMG): + $(Q) genromfs -d $(BINDIR) -f $@ + +$(ROMFSSRC): $(ROMFSIMG) + $(Q) (echo "#include " >$@ && \ + xxd -i $(ROMFSIMG) | sed -e "s/^unsigned char/const unsigned char aligned_data(4)/g" >>$@) + +$(ROMFSOBJ): %$(OBJEXT): %.c + $(call COMPILE, $<, $@, -fno-lto -fno-builtin) + +else ifeq ($(CONFIG_EXAMPLES_ELF_CROMFS),y) + NXTOOLDIR = $(TOPDIR)/tools + GENCROMFSSRC = gencromfs.c + GENCROMFSEXE = gencromfs$(HOSTEXEEXT) + + FSIMG_SRC = cromfs.c + FSIMG_OBJ = $(FSIMG_SRC:.c=$(OBJEXT)) + +$(NXTOOLDIR)/$(GENCROMFSEXE): $(NXTOOLDIR)/$(GENCROMFSSRC) + $(Q) $(MAKE) -C $(NXTOOLDIR) -f Makefile.host $(GENCROMFSEXE) + +# Create the cromfs.c file from the populated cromfs directory + +$(FSIMG_SRC):$(NXTOOLDIR)/$(GENCROMFSEXE) + $(Q) $(NXTOOLDIR)/$(GENCROMFSEXE) $(BINDIR) $@.tmp + $(Q) $(call TESTANDREPLACEFILE, $@.tmp, $@) + +$(FSIMG_OBJ): %$(OBJEXT): %.c + $(call COMPILE, $<, $@, -fno-lto -fno-builtin) + +endif + +# Copy the symbol table into the kernel pass1/ build directory + +ifneq ($(CONFIG_BUILD_FLAT),y) +$(PASS1_SYMTAB): $(SYMTABSRC) + $(Q) install -m 0644 $(SYMTABSRC) $(PASS1_SYMTAB) + $(Q) mv $(BINDIR)$(DELIM)$(MODLUE_NAME) . +endif + +postinstall:: $(ROMFSOBJ) $(SYMTABOBJ) $(FSIMG_OBJ) $(PASS1_SYMTAB) + $(call ARLOCK, $(call CONVERT_PATH,$(BIN)), $^) + +distclean:: + $(Q) $(call DELFILE, $(SYMTABSRC) $(SYMTABOBJ) $(ROMFSSRC) $(ROMFSIMG) $(ROMFSOBJ) $(MODLUE_NAME)) + + +include $(APPDIR)/Application.mk diff --git a/examples/elf/elf_main.c b/examples/elf/main/elf_main.c similarity index 96% rename from examples/elf/elf_main.c rename to examples/elf/main/elf_main.c index d6950c1c890..23930e1f90e 100644 --- a/examples/elf/elf_main.c +++ b/examples/elf/main/elf_main.c @@ -1,5 +1,5 @@ /**************************************************************************** - * apps/examples/elf/elf_main.c + * apps/examples/elf/main/elf_main.c * * SPDX-License-Identifier: Apache-2.0 * @@ -132,8 +132,35 @@ extern const unsigned int elf_romfs_img_len; # error "No file system selected" #endif -extern const char *dirlist[]; - +const char *dirlist[] = +{ + "errno", + "hello", + "signal", + "struct", +#ifdef CONFIG_HAVE_CXX + "hello++1", + "hello++2", +# ifdef CONFIG_HAVE_CXXINITIALIZE + "hello++3", +# endif +# ifdef CONFIG_EXAMPLES_ELF_CXX + "hello++4", + "hello++5", +# endif +#endif +#ifdef CONFIG_EXAMPLES_ELF_LONGJMP + "longjmp" +#endif +#ifndef CONFIG_DISABLE_PTHREAD + "mutex", + "pthread", +#endif +#ifndef CONFIG_ARCH_ADDRENV + "task", +#endif + NULL +}; extern const struct symtab_s g_elf_exports[]; extern const int g_elf_nexports; diff --git a/examples/elf/tests/.gitignore b/examples/elf/tests/.gitignore index 416f7e66e78..78af96a0dee 100644 --- a/examples/elf/tests/.gitignore +++ b/examples/elf/tests/.gitignore @@ -6,3 +6,4 @@ /dirlist.c /extfs /symtab.c +/Kconfig diff --git a/examples/elf/tests/Make.defs b/examples/elf/tests/Make.defs new file mode 100644 index 00000000000..b8f77f37cff --- /dev/null +++ b/examples/elf/tests/Make.defs @@ -0,0 +1,39 @@ +############################################################################ +# apps/examples/elf/tests/Make.defs +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +############################################################################ + +ifeq ($(CONFIG_EXAMPLES_ELF),y) + CONFIGURED_APPS += $(APPDIR)/examples/elf/tests/errno + CONFIGURED_APPS += $(APPDIR)/examples/elf/tests/hello + CONFIGURED_APPS += $(APPDIR)/examples/elf/tests/signal + CONFIGURED_APPS += $(APPDIR)/examples/elf/tests/struct + ifeq ($(CONFIG_HAVE_CXX),y) + CONFIGURED_APPS += $(APPDIR)/examples/elf/tests/helloxx + endif + ifeq ($(CONFIG_EXAMPLES_ELF_LONGJMP),y) + CONFIGURED_APPS += $(APPDIR)/examples/elf/tests/longjmp + endif + ifneq ($(CONFIG_DISABLE_PTHREAD),y) + CONFIGURED_APPS += $(APPDIR)/examples/elf/tests/mutex + CONFIGURED_APPS += $(APPDIR)/examples/elf/tests/pthread + endif + ifneq ($(CONFIG_ARCH_ADDRENV),y) + CONFIGURED_APPS += $(APPDIR)/examples/elf/tests/task + endif +endif diff --git a/examples/elf/tests/Makefile b/examples/elf/tests/Makefile index f73d31fc9e7..741d9d7a97c 100644 --- a/examples/elf/tests/Makefile +++ b/examples/elf/tests/Makefile @@ -20,134 +20,6 @@ # ############################################################################ -include $(APPDIR)/Make.defs +MENUDESC = "Elf tests example" -ALL_SUBDIRS = errno hello helloxx longjmp mutex pthread signal task struct -BUILD_SUBDIRS = errno hello struct signal - -ifeq ($(CONFIG_HAVE_CXX),y) -BUILD_SUBDIRS += helloxx -endif - -ifeq ($(CONFIG_EXAMPLES_ELF_LONGJMP),y) -BUILD_SUBDIRS += longjmp -endif - -ifneq ($(CONFIG_DISABLE_PTHREAD),y) -BUILD_SUBDIRS += mutex pthread -endif - -ifneq ($(CONFIG_ARCH_ADDRENV),y) -BUILD_SUBDIRS += task -endif - -ELF_DIR = $(APPDIR)/examples/elf -TESTS_DIR = $(ELF_DIR)/tests -DIRLIST_SRC = $(TESTS_DIR)/dirlist.c -SYMTAB_SRC = $(TESTS_DIR)/symtab.c - -ifeq ($(CONFIG_EXAMPLES_ELF_ROMFS),y) - FSIMG_SUBDIR = romfs - FSIMG_DIR = $(TESTS_DIR)/$(FSIMG_SUBDIR) - ROMFS_IMG = $(TESTS_DIR)/romfs.img - FSIMG_SRC = $(TESTS_DIR)/romfs.c -endif - -ifeq ($(CONFIG_EXAMPLES_ELF_CROMFS),y) - NXTOOLDIR = $(TOPDIR)/tools - GENCROMFSSRC = gencromfs.c - GENCROMFSEXE = gencromfs$(HOSTEXEEXT) - - FSIMG_SUBDIR = cromfs - FSIMG_DIR = $(TESTS_DIR)/$(FSIMG_SUBDIR) - FSIMG_SRC = $(TESTS_DIR)/cromfs.c -endif - -ifeq ($(CONFIG_EXAMPLES_ELF_EXTERN),y) - FSIMG_SUBDIR = extfs - FSIMG_DIR = $(TESTS_DIR)/$(FSIMG_SUBDIR) -endif - -# generate the romfs image in case the fs type is romfs -# the FSIMG_SRC is not actually generated. - -ifeq ($(CONFIG_EXAMPLES_ELF_FSTYPE), "romfs") - ROMFS_IMG = $(TESTS_DIR)/romfs.img - FSIMG_SRC = $(TESTS_DIR)/romfs.c -endif - -define DIR_template -$(1)_$(2): - +$(Q) $(MAKE) -C $(1) $(2) TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" FSIMG_DIR="$(FSIMG_DIR)" CROSSDEV=$(CROSSDEV) -endef - -all: $(FSIMG_SRC) $(DIRLIST_SRC) $(SYMTAB_SRC) -.PHONY: all clean install - -$(foreach DIR, $(ALL_SUBDIRS), $(eval $(call DIR_template,$(DIR),clean))) -$(foreach DIR, $(BUILD_SUBDIRS), $(eval $(call DIR_template,$(DIR),install))) - -# Install each program in the file system image directory - -install: $(foreach DIR, $(BUILD_SUBDIRS), $(DIR)_install) - -ifeq ($(CONFIG_EXAMPLES_ELF_ROMFS),y) -# Create the romfs.img file from the populated romfs directory - -$(ROMFS_IMG): install - $(Q) genromfs -f $@.tmp -d $(FSIMG_DIR) -V "ELFTEST" - $(Q) $(call TESTANDREPLACEFILE, $@.tmp, $@) - -# Create the romfs.c file from the romfs.img file - -$(FSIMG_SRC): $(ROMFS_IMG) - $(Q) (cd $(TESTS_DIR) && echo "#include " >$@ && \ - xxd -i romfs.img | sed -e "s/^unsigned char/const unsigned char aligned_data(4)/g" | \ - sed -e "s/romfs_img/elf_romfs_img/g" >>$@) - -endif - -ifeq ($(CONFIG_EXAMPLES_ELF_CROMFS),y) -# Make sure that the NuttX gencromfs tool has been built - -$(NXTOOLDIR)/$(GENCROMFSEXE): $(NXTOOLDIR)/$(GENCROMFSSRC) - $(Q) $(MAKE) -C $(NXTOOLDIR) -f Makefile.host $(GENCROMFSEXE) - -# Create the cromfs.h header file from the populated cromfs directory - -$(FSIMG_SRC): install $(NXTOOLDIR)/$(GENCROMFSEXE) - $(Q) $(NXTOOLDIR)/$(GENCROMFSEXE) $(FSIMG_DIR) $@.tmp - $(Q) $(call TESTANDREPLACEFILE, $@.tmp, $@) - -endif - -ifeq ($(CONFIG_EXAMPLES_ELF_FSTYPE),"romfs") -# Create the romfs.img file from the populated romfs directory - -$(ROMFS_IMG): install - $(Q) genromfs -f $@.tmp -d $(FSIMG_DIR) -V "ELFTEST" - $(Q) $(call TESTANDREPLACEFILE, $@.tmp, $@) - -# Create the romfs.c file from the romfs.img file - -$(FSIMG_SRC): $(ROMFS_IMG) - -endif - -# Create the dirlist.h header file from the file system image directory - -$(DIRLIST_SRC): install - $(Q) $(TESTS_DIR)/mkdirlist.sh $(FSIMG_DIR) >$@.tmp - $(Q) $(call TESTANDREPLACEFILE, $@.tmp, $@) - -# Create the exported symbol table - -$(SYMTAB_SRC): install - $(Q) $(APPDIR)$(DELIM)tools$(DELIM)mksymtab.sh $(FSIMG_DIR) g_elf >$@.tmp - $(Q) $(call TESTANDREPLACEFILE, $@.tmp, $@) - -# Clean each subdirectory - -clean: $(foreach DIR, $(ALL_SUBDIRS), $(DIR)_clean) - $(Q) rm -f $(FSIMG_SRC) $(DIRLIST_SRC) $(ROMFS_IMG) $(SYMTAB_SRC) - $(Q) rm -rf $(FSIMG_DIR) +include $(APPDIR)/Directory.mk diff --git a/examples/elf/tests/errno/Kconfig b/examples/elf/tests/errno/Kconfig new file mode 100644 index 00000000000..f72f3c094ce --- /dev/null +++ b/examples/elf/tests/errno/Kconfig @@ -0,0 +1,4 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# diff --git a/examples/elf/tests/errno/Makefile b/examples/elf/tests/errno/Makefile index 2f9d2a13ab0..ee383144d94 100644 --- a/examples/elf/tests/errno/Makefile +++ b/examples/elf/tests/errno/Makefile @@ -22,49 +22,10 @@ include $(APPDIR)/Make.defs -ifeq ($(CONFIG_EXAMPLES_ELF_SYSCALL),y) -LDELFFLAGS += -Bstatic -LDLIBPATH += -L $(NUTTXLIB) -else -ifeq ($(CONFIG_EXAMPLES_ELF_LIBC),y) -LDELFFLAGS += -Bstatic -LDLIBPATH += -L $(NUTTXLIB) -endif -endif +PROGNAME = errno +PRIORITY = 100 +STACKSIZE = $(CONFIG_ELF_STACKSIZE) +MODULE = m +MAINSRC = errno.c -ifeq ($(CONFIG_EXAMPLES_ELF_LIBC),y) -LDLIBS += -lc -endif - -ifeq ($(CONFIG_EXAMPLES_ELF_SYSCALL),y) -LDLIBS += -lproxies -endif - -BIN = errno - -SRCS = $(BIN).c -OBJS = $(SRCS:.c=$(OBJEXT)) - -all: $(BIN) -.PHONY: all clean install - -$(OBJS): %$(OBJEXT): %.c - @echo "CC: $<" - $(Q) $(CC) -c $(CELFFLAGS) $< -o $@ - -$(BIN): $(OBJS) - @echo "LD: $<" - $(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) -o $@ $(ARCHCRT0OBJ) $^ $(LDLIBS) - -$(FSIMG_DIR)/$(BIN): $(BIN) - $(Q) mkdir -p $(FSIMG_DIR) - $(Q) install $(BIN) $(FSIMG_DIR)/$(BIN) -ifneq ($(CONFIG_DEBUG_SYMBOLS),y) - $(Q) $(STRIP) $(FSIMG_DIR)/$(BIN) -endif - -install: $(FSIMG_DIR)/$(BIN) - -clean: - $(call DELFILE, $(BIN)) - $(call CLEAN) +include $(APPDIR)/Application.mk diff --git a/examples/elf/tests/hello/Kconfig b/examples/elf/tests/hello/Kconfig new file mode 100644 index 00000000000..f72f3c094ce --- /dev/null +++ b/examples/elf/tests/hello/Kconfig @@ -0,0 +1,4 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# diff --git a/examples/elf/tests/hello/Makefile b/examples/elf/tests/hello/Makefile index 88ec0f0a807..6920b152244 100644 --- a/examples/elf/tests/hello/Makefile +++ b/examples/elf/tests/hello/Makefile @@ -22,49 +22,10 @@ include $(APPDIR)/Make.defs -ifeq ($(CONFIG_EXAMPLES_ELF_SYSCALL),y) -LDELFFLAGS += -Bstatic -LDLIBPATH += -L $(NUTTXLIB) -else -ifeq ($(CONFIG_EXAMPLES_ELF_LIBC),y) -LDELFFLAGS += -Bstatic -LDLIBPATH += -L $(NUTTXLIB) -endif -endif +PROGNAME = hello +PRIORITY = 100 +STACKSIZE = $(CONFIG_ELF_STACKSIZE) +MODULE = m +MAINSRC = hello.c -ifeq ($(CONFIG_EXAMPLES_ELF_LIBC),y) -LDLIBS += -lc -endif - -ifeq ($(CONFIG_EXAMPLES_ELF_SYSCALL),y) -LDLIBS += -lproxies -endif - -BIN = hello - -SRCS = $(BIN).c -OBJS = $(SRCS:.c=$(OBJEXT)) - -all: $(BIN) -.PHONY: all clean install - -$(OBJS): %$(OBJEXT): %.c - @echo "CC: $<" - $(Q) $(CC) -c $(CELFFLAGS) $< -o $@ - -$(BIN): $(OBJS) - @echo "LD: $<" - $(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) -o $@ $(ARCHCRT0OBJ) $^ $(LDLIBS) - -$(FSIMG_DIR)/$(BIN): $(BIN) - $(Q) mkdir -p $(FSIMG_DIR) - $(Q) install $(BIN) $(FSIMG_DIR)/$(BIN) -ifneq ($(CONFIG_DEBUG_SYMBOLS),y) - $(Q) $(STRIP) $(FSIMG_DIR)/$(BIN) -endif - -install: $(FSIMG_DIR)/$(BIN) - -clean: - $(call DELFILE, $(BIN)) - $(call CLEAN) +include $(APPDIR)/Application.mk diff --git a/examples/elf/tests/helloxx/Kconfig b/examples/elf/tests/helloxx/Kconfig new file mode 100644 index 00000000000..f72f3c094ce --- /dev/null +++ b/examples/elf/tests/helloxx/Kconfig @@ -0,0 +1,4 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# diff --git a/examples/elf/tests/helloxx/Makefile b/examples/elf/tests/helloxx/Makefile index b2f2768342d..667bf453d9a 100644 --- a/examples/elf/tests/helloxx/Makefile +++ b/examples/elf/tests/helloxx/Makefile @@ -22,156 +22,19 @@ include $(APPDIR)/Make.defs -ifeq ($(CONFIG_EXAMPLES_ELF_SYSCALL),y) -LDELFFLAGS += -Bstatic -LDLIBPATH += -L $(NUTTXLIB) -else -ifeq ($(CONFIG_EXAMPLES_ELF_LIBC),y) -LDELFFLAGS += -Bstatic -LDLIBPATH += -L $(NUTTXLIB) -endif -endif - -ifeq ($(CONFIG_EXAMPLES_ELF_LIBC),y) -LDLIBS += -lc -endif - -ifeq ($(CONFIG_EXAMPLES_ELF_SYSCALL),y) -LDLIBS += -lproxies -endif - -BIN1 = hello++1 -ALL_BIN = $(FSIMG_DIR)/$(BIN1) -BIN2 = hello++2 -ALL_BIN += $(FSIMG_DIR)/$(BIN2) -ifeq ($(CONFIG_HAVE_CXXINITIALIZE),y) -BIN3 = hello++3 -ALL_BIN += $(FSIMG_DIR)/$(BIN3) -ifeq ($(CONFIG_EXAMPLES_ELF_CXX),y) -BIN4 = hello++4 -ALL_BIN += $(FSIMG_DIR)/$(BIN4) -BIN5 = hello++5 -ALL_BIN += $(FSIMG_DIR)/$(BIN5) -endif -endif - -SRCS1 = $(BIN1).c -OBJS1 = $(SRCS1:.c=$(OBJEXT)) - -SRCS2 = $(BIN2).c -OBJS2 = $(SRCS2:.c=$(OBJEXT)) - -ifeq ($(CONFIG_HAVE_CXXINITIALIZE),y) -SRCS3 = $(BIN3).c -OBJS3 = $(SRCS3:.c=$(OBJEXT)) -ifeq ($(CONFIG_EXAMPLES_ELF_CXX),y) -SRCS4 = $(BIN4).c -OBJS4 = $(SRCS4:.c=$(OBJEXT)) -SRCS5 = $(BIN5).c -OBJS5 = $(SRCS5:.c=$(OBJEXT)) -endif -endif - -SRCS = $(SRCS1) $(SRCS2) $(SRCS3) $(SRCS4) $(SRCS5) -OBJS = $(OBJS1) $(OBJS2) $(OBJS3) $(OBJS4) $(OBJS5) - -LDLIBSTDC_STUBS_DIR = $(TOPDIR)/libxx -LDLIBSTDC_STUBS_LIB = $(LDLIBSTDC_STUBS_DIR)/liblibxx.a - -all: $(BIN1) $(BIN2) $(BIN3) $(BIN4) $(BIN5) -.PHONY: all clean install - -$(OBJS): %$(OBJEXT): %.cxx - @echo "CC: $<" - $(Q) $(CXX) -c $(CXXELFFLAGS) $< -o $@ - -# This contains libstdc++ stubs to that you can build C++ code -# without actually having libstdc++ - -$(LDLIBSTDC_STUBS_LIB): - $(Q) $(MAKE) -C $(LDLIBSTDC_STUBS_DIR) TOPDIR=$(TOPDIR) - -# BIN1 and BIN2 link just like C code because they contain no -# static constructors. BIN1 is equivalent to a C hello world; -# BIN2 contains a class that implements hello world, but it is -# not statically initialized. - -$(BIN1): $(OBJS1) - @echo "LD: $<" - $(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) -o $@ $(ARCHCRT0OBJ) $^ $(LDLIBS) - -$(BIN2): $(OBJS2) - @echo "LD: $<" - $(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) -o $@ $(ARCHCRT0OBJ) $^ $(LDLIBS) - -# BIN3 is equivalent to BIN2 except that is uses static initializers - +PROGNAME = hello++1 hello++2 +PRIORITY = 100 +STACKSIZE = $(CONFIG_ELF_STACKSIZE) +MODULE = m +MAINSRC = hello++1.cxx hello++2.cxx ifeq ($(CONFIG_HAVE_CXXINITIALIZE),y) -$(BIN3): $(OBJS3) - @echo "LD: $<" - $(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) -o $@ $(ARCHCRT0OBJ) $^ $(LDLIBS) - -# BIN4 is similar to BIN3 except that it uses the streams code from libstdc++ -# Both BIN4 and BIN5 use exceptions -# NOTE: libstdc++ is not available for NuttX as of this writing -# -ifeq ($(CONFIG_EXAMPLES_ELF_CXX),y) -ifeq ($(CONFIG_CXX_EXCEPTION),y) -$(BIN4): $(OBJS4) - @echo "LD: $<" - $(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) -o $@ $(ARCHCRT0OBJ) $^ $(LDLIBS) -$(BIN5): $(OBJS5) - @echo "LD: $<" - $(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) -o $@ $(ARCHCRT0OBJ) $^ $(LDLIBS) -endif -endif -endif - -$(FSIMG_DIR)/$(BIN1): $(BIN1) - $(Q) mkdir -p $(FSIMG_DIR) - $(Q) install $(BIN1) $(FSIMG_DIR)/$(BIN1) -ifneq ($(CONFIG_DEBUG_SYMBOLS),y) - $(Q) $(STRIP) $(FSIMG_DIR)/$(BIN1) -endif - -$(FSIMG_DIR)/$(BIN2): $(BIN2) - $(Q) mkdir -p $(FSIMG_DIR) - $(Q) install $(BIN2) $(FSIMG_DIR)/$(BIN2) -ifneq ($(CONFIG_DEBUG_SYMBOLS),y) - $(Q) $(STRIP) $(FSIMG_DIR)/$(BIN2) -endif - -ifeq ($(CONFIG_HAVE_CXXINITIALIZE),y) -$(FSIMG_DIR)/$(BIN3): $(BIN3) - $(Q) mkdir -p $(FSIMG_DIR) - $(Q) install $(BIN3) $(FSIMG_DIR)/$(BIN3) -ifneq ($(CONFIG_DEBUG_SYMBOLS),y) - $(Q) $(STRIP) $(FSIMG_DIR)/$(BIN3) + PROGNAME += hello++3 + MAINSRC += hello++3.cxx endif ifeq ($(CONFIG_EXAMPLES_ELF_CXX),y) -$(FSIMG_DIR)/$(BIN4): $(BIN4) - $(Q) mkdir -p $(FSIMG_DIR) - $(Q) install $(BIN4) $(FSIMG_DIR)/$(BIN4) -ifneq ($(CONFIG_DEBUG_SYMBOLS),y) - $(Q) $(STRIP) $(FSIMG_DIR)/$(BIN4) + PROGNAME += hello++4 hello++5 + MAINSRC += hello++4.cxx hello++5.cxx endif -$(FSIMG_DIR)/$(BIN5): $(BIN5) - $(Q) mkdir -p $(FSIMG_DIR) - $(Q) install $(BIN5) $(FSIMG_DIR)/$(BIN5) -ifneq ($(CONFIG_DEBUG_SYMBOLS),y) - $(Q) $(STRIP) $(FSIMG_DIR)/$(BIN5) -endif -endif -endif - -install: $(ALL_BIN) - -clean: - $(call DELFILE, $(BIN1)) - $(call DELFILE, $(BIN2)) - $(call DELFILE, $(BIN3)) - $(call DELFILE, $(BIN4)) - $(call DELFILE, $(BIN5)) - $(call CLEAN) +include $(APPDIR)/Application.mk diff --git a/examples/elf/tests/longjmp/Kconfig b/examples/elf/tests/longjmp/Kconfig new file mode 100644 index 00000000000..f72f3c094ce --- /dev/null +++ b/examples/elf/tests/longjmp/Kconfig @@ -0,0 +1,4 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# diff --git a/examples/elf/tests/longjmp/Makefile b/examples/elf/tests/longjmp/Makefile index fa792e6ff0d..a5e482f288e 100644 --- a/examples/elf/tests/longjmp/Makefile +++ b/examples/elf/tests/longjmp/Makefile @@ -22,49 +22,10 @@ include $(APPDIR)/Make.defs -ifeq ($(CONFIG_EXAMPLES_ELF_SYSCALL),y) -LDELFFLAGS += -Bstatic -LDLIBPATH += -L $(NUTTXLIB) -else -ifeq ($(CONFIG_EXAMPLES_ELF_LIBC),y) -LDELFFLAGS += -Bstatic -LDLIBPATH += -L $(NUTTXLIB) -endif -endif +PROGNAME = longjmp +PRIORITY = 100 +STACKSIZE = $(CONFIG_ELF_STACKSIZE) +MODULE = m +MAINSRC = longjmp.c -ifeq ($(CONFIG_EXAMPLES_ELF_LIBC),y) -LDLIBS += -lc -endif - -ifeq ($(CONFIG_EXAMPLES_ELF_SYSCALL),y) -LDLIBS += -lproxies -endif - -BIN = longjmp - -SRCS = $(BIN).c -OBJS = $(SRCS:.c=$(OBJEXT)) - -all: $(BIN) -.PHONY: all clean install - -$(OBJS): %$(OBJEXT): %.c - @echo "CC: $<" - $(Q) $(CC) -c $(CELFFLAGS) $< -o $@ - -$(BIN): $(OBJS) - @echo "LD: $<" - $(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) -o $@ $(ARCHCRT0OBJ) $^ $(LDLIBS) - -$(FSIMG_DIR)/$(BIN): $(BIN) - $(Q) mkdir -p $(FSIMG_DIR) - $(Q) install $(BIN) $(FSIMG_DIR)/$(BIN) -ifneq ($(CONFIG_DEBUG_SYMBOLS),y) - $(Q) $(STRIP) $(FSIMG_DIR)/$(BIN) -endif - -install: $(FSIMG_DIR)/$(BIN) - -clean: - $(call DELFILE, $(BIN)) - $(call CLEAN) +include $(APPDIR)/Application.mk diff --git a/examples/elf/tests/mutex/Kconfig b/examples/elf/tests/mutex/Kconfig new file mode 100644 index 00000000000..f72f3c094ce --- /dev/null +++ b/examples/elf/tests/mutex/Kconfig @@ -0,0 +1,4 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# diff --git a/examples/elf/tests/mutex/Makefile b/examples/elf/tests/mutex/Makefile index 5fec89d3c0c..fe3619513e7 100644 --- a/examples/elf/tests/mutex/Makefile +++ b/examples/elf/tests/mutex/Makefile @@ -22,49 +22,10 @@ include $(APPDIR)/Make.defs -ifeq ($(CONFIG_EXAMPLES_ELF_SYSCALL),y) -LDELFFLAGS += -Bstatic -LDLIBPATH += -L $(NUTTXLIB) -else -ifeq ($(CONFIG_EXAMPLES_ELF_LIBC),y) -LDELFFLAGS += -Bstatic -LDLIBPATH += -L $(NUTTXLIB) -endif -endif +PROGNAME = mutex +PRIORITY = 100 +STACKSIZE = $(CONFIG_ELF_STACKSIZE) +MODULE = m +MAINSRC = mutex.c -ifeq ($(CONFIG_EXAMPLES_ELF_LIBC),y) -LDLIBS += -lc -endif - -ifeq ($(CONFIG_EXAMPLES_ELF_SYSCALL),y) -LDLIBS += -lproxies -endif - -BIN = mutex - -SRCS = $(BIN).c -OBJS = $(SRCS:.c=$(OBJEXT)) - -all: $(BIN) -.PHONY: all clean install - -$(OBJS): %$(OBJEXT): %.c - @echo "CC: $<" - $(Q) $(CC) -c $(CELFFLAGS) $< -o $@ - -$(BIN): $(OBJS) - @echo "LD: $<" - $(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) -o $@ $(ARCHCRT0OBJ) $^ $(LDLIBS) - -$(FSIMG_DIR)/$(BIN): $(BIN) - $(Q) mkdir -p $(FSIMG_DIR) - $(Q) install $(BIN) $(FSIMG_DIR)/$(BIN) -ifneq ($(CONFIG_DEBUG_SYMBOLS),y) - $(Q) $(STRIP) $(FSIMG_DIR)/$(BIN) -endif - -install: $(FSIMG_DIR)/$(BIN) - -clean: - $(call DELFILE, $(BIN)) - $(call CLEAN) +include $(APPDIR)/Application.mk diff --git a/examples/elf/tests/pthread/Kconfig b/examples/elf/tests/pthread/Kconfig new file mode 100644 index 00000000000..f72f3c094ce --- /dev/null +++ b/examples/elf/tests/pthread/Kconfig @@ -0,0 +1,4 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# diff --git a/examples/elf/tests/pthread/Makefile b/examples/elf/tests/pthread/Makefile index 61108bc5f0d..b1ca8c70df5 100644 --- a/examples/elf/tests/pthread/Makefile +++ b/examples/elf/tests/pthread/Makefile @@ -22,49 +22,10 @@ include $(APPDIR)/Make.defs -ifeq ($(CONFIG_EXAMPLES_ELF_SYSCALL),y) -LDELFFLAGS += -Bstatic -LDLIBPATH += -L $(NUTTXLIB) -else -ifeq ($(CONFIG_EXAMPLES_ELF_LIBC),y) -LDELFFLAGS += -Bstatic -LDLIBPATH += -L $(NUTTXLIB) -endif -endif +PROGNAME = pthread +PRIORITY = 100 +STACKSIZE = $(CONFIG_ELF_STACKSIZE) +MODULE = m +MAINSRC = pthread.c -ifeq ($(CONFIG_EXAMPLES_ELF_LIBC),y) -LDLIBS += -lc -endif - -ifeq ($(CONFIG_EXAMPLES_ELF_SYSCALL),y) -LDLIBS += -lproxies -endif - -BIN = pthread - -SRCS = $(BIN).c -OBJS = $(SRCS:.c=$(OBJEXT)) - -all: $(BIN) -.PHONY: all clean install - -$(OBJS): %$(OBJEXT): %.c - @echo "CC: $<" - $(Q) $(CC) -c $(CELFFLAGS) $< -o $@ - -$(BIN): $(OBJS) - @echo "LD: $<" - $(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) -o $@ $(ARCHCRT0OBJ) $^ $(LDLIBS) - -$(FSIMG_DIR)/$(BIN): $(BIN) - $(Q) mkdir -p $(FSIMG_DIR) - $(Q) install $(BIN) $(FSIMG_DIR)/$(BIN) -ifneq ($(CONFIG_DEBUG_SYMBOLS),y) - $(Q) $(STRIP) $(FSIMG_DIR)/$(BIN) -endif - -install: $(FSIMG_DIR)/$(BIN) - -clean: - $(call DELFILE, $(BIN)) - $(call CLEAN) +include $(APPDIR)/Application.mk diff --git a/examples/elf/tests/signal/Kconfig b/examples/elf/tests/signal/Kconfig new file mode 100644 index 00000000000..f72f3c094ce --- /dev/null +++ b/examples/elf/tests/signal/Kconfig @@ -0,0 +1,4 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# diff --git a/examples/elf/tests/signal/Makefile b/examples/elf/tests/signal/Makefile index 21df11dd0d0..64d674033e0 100644 --- a/examples/elf/tests/signal/Makefile +++ b/examples/elf/tests/signal/Makefile @@ -22,49 +22,10 @@ include $(APPDIR)/Make.defs -ifeq ($(CONFIG_EXAMPLES_ELF_SYSCALL),y) -LDELFFLAGS += -Bstatic -LDLIBPATH += -L $(NUTTXLIB) -else -ifeq ($(CONFIG_EXAMPLES_ELF_LIBC),y) -LDELFFLAGS += -Bstatic -LDLIBPATH += -L $(NUTTXLIB) -endif -endif +PROGNAME = signal +PRIORITY = 100 +STACKSIZE = $(CONFIG_ELF_STACKSIZE) +MODULE = m +MAINSRC = signal.c -ifeq ($(CONFIG_EXAMPLES_ELF_LIBC),y) -LDLIBS += -lc -endif - -ifeq ($(CONFIG_EXAMPLES_ELF_SYSCALL),y) -LDLIBS += -lproxies -endif - -BIN = signal - -SRCS = $(BIN).c -OBJS = $(SRCS:.c=$(OBJEXT)) - -all: $(BIN) -.PHONY: all clean install - -$(OBJS): %$(OBJEXT): %.c - @echo "CC: $<" - $(Q) $(CC) -c $(CELFFLAGS) $< -o $@ - -$(BIN): $(OBJS) - @echo "LD: $<" - $(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) -o $@ $(ARCHCRT0OBJ) $^ $(LDLIBS) - -$(FSIMG_DIR)/$(BIN): $(BIN) - $(Q) mkdir -p $(FSIMG_DIR) - $(Q) install $(BIN) $(FSIMG_DIR)/$(BIN) -ifneq ($(CONFIG_DEBUG_SYMBOLS),y) - $(Q) $(STRIP) $(FSIMG_DIR)/$(BIN) -endif - -install: $(FSIMG_DIR)/$(BIN) - -clean: - $(call DELFILE, $(BIN)) - $(call CLEAN) +include $(APPDIR)/Application.mk diff --git a/examples/elf/tests/struct/Kconfig b/examples/elf/tests/struct/Kconfig new file mode 100644 index 00000000000..f72f3c094ce --- /dev/null +++ b/examples/elf/tests/struct/Kconfig @@ -0,0 +1,4 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# diff --git a/examples/elf/tests/struct/Makefile b/examples/elf/tests/struct/Makefile index 990d990c25d..88ab66f3fe9 100644 --- a/examples/elf/tests/struct/Makefile +++ b/examples/elf/tests/struct/Makefile @@ -22,48 +22,11 @@ include $(APPDIR)/Make.defs -ifeq ($(CONFIG_EXAMPLES_ELF_SYSCALL),y) -LDELFFLAGS += -Bstatic -LDLIBPATH += -L $(NUTTXLIB) -else -ifeq ($(CONFIG_EXAMPLES_ELF_LIBC),y) -LDELFFLAGS += -Bstatic -LDLIBPATH += -L $(NUTTXLIB) -endif -endif - -ifeq ($(CONFIG_EXAMPLES_ELF_LIBC),y) -LDLIBS += -lc -endif - -ifeq ($(CONFIG_EXAMPLES_ELF_SYSCALL),y) -LDLIBS += -lproxies -endif - -BIN = struct -SRCS = struct_main.c struct_dummy.c -OBJS = $(SRCS:.c=$(OBJEXT)) - -all: $(BIN) -.PHONY: all clean install - -$(OBJS): %$(OBJEXT): %.c - @echo "CC: $<" - $(Q) $(CC) -c $(CELFFLAGS) $< -o $@ - -$(BIN): $(OBJS) - @echo "LD: $<" - $(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) -o $@ $(ARCHCRT0OBJ) $^ $(LDLIBS) - -$(FSIMG_DIR)/$(BIN): $(BIN) - $(Q) mkdir -p $(FSIMG_DIR) - $(Q) install $(BIN) $(FSIMG_DIR)/$(BIN) -ifneq ($(CONFIG_DEBUG_SYMBOLS),y) - $(Q) $(STRIP) $(FSIMG_DIR)/$(BIN) -endif - -install: $(FSIMG_DIR)/$(BIN) - -clean: - $(call DELFILE, $(BIN)) - $(call CLEAN) +PROGNAME = struct +PRIORITY = 100 +STACKSIZE = $(CONFIG_ELF_STACKSIZE) +MODULE = m +CSRCS = struct_dummy.c +MAINSRC = struct_main.c + +include $(APPDIR)/Application.mk diff --git a/examples/elf/tests/task/Kconfig b/examples/elf/tests/task/Kconfig new file mode 100644 index 00000000000..f72f3c094ce --- /dev/null +++ b/examples/elf/tests/task/Kconfig @@ -0,0 +1,4 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# diff --git a/examples/elf/tests/task/Makefile b/examples/elf/tests/task/Makefile index b57b98885f9..09424ac9607 100644 --- a/examples/elf/tests/task/Makefile +++ b/examples/elf/tests/task/Makefile @@ -22,49 +22,10 @@ include $(APPDIR)/Make.defs -ifeq ($(CONFIG_EXAMPLES_ELF_SYSCALL),y) -LDELFFLAGS += -Bstatic -LDLIBPATH += -L $(NUTTXLIB) -else -ifeq ($(CONFIG_EXAMPLES_ELF_LIBC),y) -LDELFFLAGS += -Bstatic -LDLIBPATH += -L $(NUTTXLIB) -endif -endif +PROGNAME = task +PRIORITY = 100 +STACKSIZE = $(CONFIG_ELF_STACKSIZE) +MODULE = m +MAINSRC = task.c -ifeq ($(CONFIG_EXAMPLES_ELF_LIBC),y) -LDLIBS += -lc -endif - -ifeq ($(CONFIG_EXAMPLES_ELF_SYSCALL),y) -LDLIBS += -lproxies -endif - -BIN = task - -SRCS = $(BIN).c -OBJS = $(SRCS:.c=$(OBJEXT)) - -all: $(BIN) -.PHONY: all clean install - -$(OBJS): %$(OBJEXT): %.c - @echo "CC: $<" - $(Q) $(CC) -c $(CELFFLAGS) $< -o $@ - -$(BIN): $(OBJS) - @echo "LD: $<" - $(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) -o $@ $(ARCHCRT0OBJ) $^ $(LDLIBS) - -$(FSIMG_DIR)/$(BIN): $(BIN) - $(Q) mkdir -p $(FSIMG_DIR) - $(Q) install $(BIN) $(FSIMG_DIR)/$(BIN) -ifneq ($(CONFIG_DEBUG_SYMBOLS),y) - $(Q) $(STRIP) $(FSIMG_DIR)/$(BIN) -endif - -install: $(FSIMG_DIR)/$(BIN) - -clean: - $(call DELFILE, $(BIN)) - $(call CLEAN) +include $(APPDIR)/Application.mk From 490d7632b9bf8393993c76988f0eda262efacdfe Mon Sep 17 00:00:00 2001 From: anjiahao Date: Fri, 29 Aug 2025 10:05:06 +0800 Subject: [PATCH 2/4] elf:Delete unnecessary generation, elf does not use kernel api delete the mod_symtab.c generate procedure Signed-off-by: anjiahao --- examples/elf/main/Makefile | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/examples/elf/main/Makefile b/examples/elf/main/Makefile index 0cb59156bbf..074ea6a3d6c 100644 --- a/examples/elf/main/Makefile +++ b/examples/elf/main/Makefile @@ -30,12 +30,6 @@ MAINSRC = elf_main.c SYMTABSRC = test_symtab.c SYMTABOBJ = $(SYMTABSRC:.c=$(OBJEXT)) - -ifneq ($(CONFIG_BUILD_FLAT),y) - PASS1_SYMTAB = $(TOPDIR)/pass1/mod_symtab.c - MODLUE_NAME = tests -endif - $(SYMTABSRC): $(Q) $(APPDIR)$(DELIM)tools$(DELIM)mksymtab.sh $(BINDIR) g_elf >$@.tmp $(Q) $(call TESTANDREPLACEFILE, $@.tmp, $@) @@ -82,15 +76,7 @@ $(FSIMG_OBJ): %$(OBJEXT): %.c endif -# Copy the symbol table into the kernel pass1/ build directory - -ifneq ($(CONFIG_BUILD_FLAT),y) -$(PASS1_SYMTAB): $(SYMTABSRC) - $(Q) install -m 0644 $(SYMTABSRC) $(PASS1_SYMTAB) - $(Q) mv $(BINDIR)$(DELIM)$(MODLUE_NAME) . -endif - -postinstall:: $(ROMFSOBJ) $(SYMTABOBJ) $(FSIMG_OBJ) $(PASS1_SYMTAB) +postinstall:: $(ROMFSOBJ) $(SYMTABOBJ) $(FSIMG_OBJ) $(call ARLOCK, $(call CONVERT_PATH,$(BIN)), $^) distclean:: From f60286463c3ce64b9560bd21ac6550c445831417 Mon Sep 17 00:00:00 2001 From: v-tangmeng Date: Fri, 31 Oct 2025 14:10:10 +0800 Subject: [PATCH 3/4] examples/elf: add support for CONFIG_DISABLE_SIGNALS make the example elf can work with SIGNAL disabled Signed-off-by: v-tangmeng --- examples/elf/main/elf_main.c | 2 ++ examples/elf/tests/Make.defs | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/examples/elf/main/elf_main.c b/examples/elf/main/elf_main.c index 23930e1f90e..7a52b5f6e5d 100644 --- a/examples/elf/main/elf_main.c +++ b/examples/elf/main/elf_main.c @@ -136,7 +136,9 @@ const char *dirlist[] = { "errno", "hello", +#ifndef CONFIG_DISABLE_SIGNALS "signal", +#endif "struct", #ifdef CONFIG_HAVE_CXX "hello++1", diff --git a/examples/elf/tests/Make.defs b/examples/elf/tests/Make.defs index b8f77f37cff..e29058c49ae 100644 --- a/examples/elf/tests/Make.defs +++ b/examples/elf/tests/Make.defs @@ -21,7 +21,9 @@ ifeq ($(CONFIG_EXAMPLES_ELF),y) CONFIGURED_APPS += $(APPDIR)/examples/elf/tests/errno CONFIGURED_APPS += $(APPDIR)/examples/elf/tests/hello - CONFIGURED_APPS += $(APPDIR)/examples/elf/tests/signal + ifneq ($(CONFIG_DISABLE_SIGNALS),y) + CONFIGURED_APPS += $(APPDIR)/examples/elf/tests/signal + endif CONFIGURED_APPS += $(APPDIR)/examples/elf/tests/struct ifeq ($(CONFIG_HAVE_CXX),y) CONFIGURED_APPS += $(APPDIR)/examples/elf/tests/helloxx From 44023f0c083eef5d3f2eca065e496e79c86f09c4 Mon Sep 17 00:00:00 2001 From: anjiahao Date: Tue, 25 Nov 2025 20:32:40 +0800 Subject: [PATCH 4/4] elf:avoid interference between different ELFs generated by symtab if defined CONFIG_EXAMPLES_ELF and CONFIG_EXAMPLES_MODLUE, elf will generated BINDIR, so generated symtab will interference. It supports inputting multiple specified files in mksymtab.sh to avoid interference. Signed-off-by: anjiahao --- examples/elf/main/Makefile | 28 +++++++++- examples/module/main/Makefile | 5 +- tools/mksymtab.sh | 97 ++++++++++++++++++++++++++--------- 3 files changed, 101 insertions(+), 29 deletions(-) diff --git a/examples/elf/main/Makefile b/examples/elf/main/Makefile index 074ea6a3d6c..76093ea5f88 100644 --- a/examples/elf/main/Makefile +++ b/examples/elf/main/Makefile @@ -30,8 +30,34 @@ MAINSRC = elf_main.c SYMTABSRC = test_symtab.c SYMTABOBJ = $(SYMTABSRC:.c=$(OBJEXT)) +ELFNAME_BASE = errno hello +ifneq ($(CONFIG_DISABLE_SIGNALS),y) + ELFNAME_BASE += signal +endif + +ifeq ($(CONFIG_HAVE_CXX),y) + ELFNAME_BASE += hello++1 hello++2 + ifeq ($(CONFIG_HAVE_CXXINITIALIZE),y) + ELFNAME_BASE += hello++3 + endif + ifeq ($(CONFIG_EXAMPLES_ELF_CXX),y) + ELFNAME_BASE += hello++4 hello++5 + endif +endif +ifeq ($(CONFIG_EXAMPLES_ELF_LONGJMP),y) + ELFNAME_BASE += longjmp +endif +ifneq ($(CONFIG_DISABLE_PTHREAD),y) + ELFNAME_BASE += pthread mutex +endif +ifneq ($(CONFIG_ARCH_ADDRENV),y) + ELFNAME_BASE += task +endif + +ELFNAME = $(addprefix $(BINDIR)$(DELIM),$(ELFNAME_BASE)) + $(SYMTABSRC): - $(Q) $(APPDIR)$(DELIM)tools$(DELIM)mksymtab.sh $(BINDIR) g_elf >$@.tmp + $(Q) $(APPDIR)$(DELIM)tools$(DELIM)mksymtab.sh $(ELFNAME) g_elf >$@.tmp $(Q) $(call TESTANDREPLACEFILE, $@.tmp, $@) diff --git a/examples/module/main/Makefile b/examples/module/main/Makefile index f5294b25748..466af6dbf04 100644 --- a/examples/module/main/Makefile +++ b/examples/module/main/Makefile @@ -34,14 +34,13 @@ MAINSRC = module_main.c SYMTABSRC = mod_symtab.c SYMTABOBJ = $(SYMTABSRC:.c=$(OBJEXT)) - +MODLUE_NAME = chardev ifneq ($(CONFIG_BUILD_FLAT),y) PASS1_SYMTAB = $(TOPDIR)/pass1/mod_symtab.c - MODLUE_NAME = chardev endif $(SYMTABSRC): - $(Q) $(APPDIR)$(DELIM)tools$(DELIM)mksymtab.sh $(BINDIR) g_mod >$@.tmp + $(Q) $(APPDIR)$(DELIM)tools$(DELIM)mksymtab.sh $(BINDIR)$(DELIM)$(MODLUE_NAME) g_mod >$@.tmp $(Q) $(call TESTANDREPLACEFILE, $@.tmp, $@) diff --git a/tools/mksymtab.sh b/tools/mksymtab.sh index 1f9d7ed8c24..cdb141b03d0 100755 --- a/tools/mksymtab.sh +++ b/tools/mksymtab.sh @@ -27,28 +27,43 @@ usage() { if [ $# -ne 0 ]; then echo "ERROR: $@" fi - echo -e "\nUsage: $0 [symtabprefix] [-a additionalsymbolspath]" + echo -e "\nUsage: $0 [imagedirpath2 ... ] [symtabprefix] [-a additionalsymbolspath]" exit 1 } -# Check for the required directory path +# Collect all image directory/file paths until we hit a non-path argument +dirs=() +prefix="" +arg_count=0 -dir=$1 -if [ -z "$dir" ]; then - usage "Missing " -fi +while [ $# -gt 0 ]; do + # Check if this is an option flag + if [ "x${1:0:1}" = "x-" ]; then + break + fi -# Get the symbol table prefix + arg_count=$((arg_count + 1)) -if [ "x${2:0:1}" != "x-" ]; then - prefix=$2 - OPTIND=3 -else - OPTIND=2 -fi + # Always collect the argument (whether path exists or not) + # Only treat as prefix if it doesn't look like a path + if [[ "$1" =~ ^/ ]] || [ -e "$1" ]; then + # Looks like a path (starts with /) or exists + dirs+=("$1") + shift + else + # Doesn't look like a path, treat as prefix + prefix=$1 + shift + break + fi +done -# Parse remaining arguments +# Check we have at least one argument +if [ $arg_count -eq 0 ]; then + usage "Missing " +fi +# Parse remaining arguments for options while getopts a: opt; do case $opt in a) @@ -63,28 +78,60 @@ if [ $OPTIND != $(($# + 1)) ]; then usage "Arguments remaining: \"${@:$OPTIND}\"" fi +# Function to get exec list from a path (file or directory) +get_exec_list() { + local path=$1 + if [ -f "$path" ]; then + echo "$path" + elif [ -d "$path" ]; then + find "$path" -type f 2>/dev/null + fi +} + # Extract all of the undefined symbols from the ELF files and create a # list of sorted, unique undefined variable names. -varlist=`find $dir -name *-thunk.S 2>/dev/null | xargs grep -h asciz | cut -f3 | sort | uniq` +# First try to find thunk files from all directories +varlist="" +for dir in "${dirs[@]}"; do + if [ -d "$dir" ]; then + thunklist=`find $dir -name *-thunk.S 2>/dev/null | xargs grep -h asciz 2>/dev/null | cut -f3` + if [ ! -z "$thunklist" ]; then + varlist="${varlist} ${thunklist}" + fi + fi +done + if [ -z "$varlist" ]; then - execlist=`find $dir -type f 2>/dev/null` - if [ ! -z "$execlist" ]; then + # Collect all executable files from all paths + execlist="" + for dir in "${dirs[@]}"; do + # Only process if path exists + if [ -e "$dir" ]; then + pathlist=`get_exec_list "$dir"` + if [ ! -z "$pathlist" ]; then + execlist="${execlist} ${pathlist}" + fi + fi + done -# Get all undefined symbol names - varlist=`nm $execlist 2>/dev/null | grep -F ' U ' | sed -e "s/^[ ]*//g" | cut -d' ' -f2 | sort | uniq` + if [ ! -z "$execlist" ]; then + # Get all undefined symbol names + varlist=$(nm $execlist 2>/dev/null | grep -F ' U ' | sed -e "s/^[ ]*//g" | cut -d' ' -f2) -# Get all defined symbol names - deflist=`nm $execlist 2>/dev/null | grep -F -v -e ' U ' -e ':' | sed -e "s/^[0-9a-z]* //g" | cut -d' ' -f2 | sort | uniq` + # Get all defined symbol names + deflist=$(nm $execlist 2>/dev/null | grep -F -v -e ' U ' -e ':' | sed -e "s/^[0-9a-z]* //g" | cut -d' ' -f2) -# Remove the intersection between them, and the remaining symbols are found in the main image - common=`echo "$varlist" | tr ' ' '\n' | grep -Fxf <(echo "$deflist" | tr ' ' '\n') | tr '\n' ' '` - if [ "x$common" != "x" ]; then - varlist=`echo $varlist | sed "s/$common//g"` + # Remove the intersection between them, and the remaining symbols are found in the main image + if [ ! -z "$varlist" ] && [ ! -z "$deflist" ]; then + varlist=$(echo "$varlist" | tr ' ' '\n' | sort -u | grep -vFxf <(echo "$deflist" | tr ' ' '\n' | sort -u) | tr '\n' ' ') fi fi fi +# Sort and unique the varlist +varlist=`echo "$varlist" | tr ' ' '\n' | sort | uniq | tr '\n' ' '` + for addsym in ${addlist[@]}; do if [ -f $addsym ]; then varlist="${varlist}\n$(cat $addsym | grep -v "^,.*")"