diff --git a/examples/README.txt b/examples/README.txt index 304dc53ce..e08c2872d 100644 --- a/examples/README.txt +++ b/examples/README.txt @@ -1468,10 +1468,12 @@ examples/posix_spawn CONFIG_BINFMT_DISABLE=n - Don't disable the binary loader CONFIG_ELF=y - Enable ELF binary loader CONFIG_LIBC_EXECFUNCS=y - Enable support for posix_spawn - CONFIG_EXECFUNCS_SYMTAB="g_spawn_exports" - The name of the symbol table + CONFIG_EXECFUNCS_SYMTAB_ARRAY="g_spawn_exports" + - The name of the symbol table created by the test. - CONFIG_EXECFUNCS_NSYMBOLS=10 - Value does not matter, it will be - corrected at runtime. + CONFIG_EXECFUNCS_NSYMBOLS_VAR="g_spawn_nexports" + - Name of variable holding the + number of symbols CONFIG_POSIX_SPAWN_STACKSIZE=768 - This default setting. Test-specific configuration options: diff --git a/fsutils/mkfatfs/Makefile b/fsutils/mkfatfs/Makefile index bc5ecdde0..9e843a688 100644 --- a/fsutils/mkfatfs/Makefile +++ b/fsutils/mkfatfs/Makefile @@ -39,34 +39,34 @@ include $(APPDIR)/Make.defs # mkfatfs utility -ASRCS = -CSRCS = +ASRCS = +CSRCS = ifeq ($(CONFIG_FSUTILS_MKFATFS),y) -CSRCS = mkfatfs.c configfat.c writefat.c +CSRCS = mkfatfs.c configfat.c writefat.c endif -AOBJS = $(ASRCS:.S=$(OBJEXT)) -COBJS = $(CSRCS:.c=$(OBJEXT)) +AOBJS = $(ASRCS:.S=$(OBJEXT)) +COBJS = $(CSRCS:.c=$(OBJEXT)) -SRCS = $(ASRCS) $(CSRCS) -OBJS = $(AOBJS) $(COBJS) +SRCS = $(ASRCS) $(CSRCS) +OBJS = $(AOBJS) $(COBJS) ifeq ($(CONFIG_WINDOWS_NATIVE),y) - BIN = ..\..\libapps$(LIBEXT) + BIN = ..\..\libapps$(LIBEXT) else ifeq ($(WINTOOL),y) - BIN = ..\\..\\libapps$(LIBEXT) + BIN = ..\\..\\libapps$(LIBEXT) else - BIN = ../../libapps$(LIBEXT) + BIN = ../../libapps$(LIBEXT) endif endif -ROOTDEPPATH = --dep-path . +ROOTDEPPATH = --dep-path . # Common build -VPATH = +VPATH = all: .built .PHONY: context depend clean distclean preconfig diff --git a/import/.gitignore b/import/.gitignore index 35582e04a..50f55d5b1 100644 --- a/import/.gitignore +++ b/import/.gitignore @@ -1,4 +1,7 @@ /.config +/System.map +/User.map +/symtab.c /arch /build /libs diff --git a/import/Makefile b/import/Makefile index ec60c22ed..116e183af 100644 --- a/import/Makefile +++ b/import/Makefile @@ -1,7 +1,7 @@ ############################################################################ # apps/import/Makefile # -# Copyright (C) 2014 Gregory Nutt. All rights reserved. +# Copyright (C) 2014, 2018 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -39,25 +39,39 @@ # Sub-directories from the NuttX export package SUBDIRS = arch build include libs startup tmp -FILES = .config +FILES = .config System.map User.map -all: nothing -.PHONY: nothing context depend clean distclean + +define MKSYMTAB +ifeq (,$(wildcard ./symtab.c)) + $(Q) $(MAKE) -f Makefile.symtab $1 +endif +endef + +all: symtab +.PHONY: context depend clean distclean .PRECIOUS: ../libapps$(LIBEXT) -nothing: +symtab: + $(call MKSYMTAB, all) install: + $(call MKSYMTAB, install) context: + $(call MKSYMTAB, context) depend: + $(call MKSYMTAB, depend) clean: + $(call MKSYMTAB, clean) distclean: $(foreach SDIR, $(SUBDIRS), $(call DELDIR, $(SDIR))) $(foreach FILE, $(FILES), $(call DELFILE, $(FILE))) + $(call MKSYMTAB, distclean) + $(call DELFILE, symtab.c) # Library path diff --git a/import/Makefile.symtab b/import/Makefile.symtab new file mode 100644 index 000000000..d73f4467e --- /dev/null +++ b/import/Makefile.symtab @@ -0,0 +1,40 @@ +############################################################################ +# apps/import/Makefile.symtab +# +# Copyright (C) 2018 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name NuttX nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +-include $(TOPDIR)/Make.defs + +CSRCS = symtab.c + +include $(APPDIR)/Application.mk diff --git a/tools/mksymtab.sh b/tools/mksymtab.sh new file mode 100644 index 000000000..105cd5f4e --- /dev/null +++ b/tools/mksymtab.sh @@ -0,0 +1,106 @@ +#!/bin/bash +############################################################################ +# apps/tools/mksymtab.sh +# +# Copyright (C) 2018 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name NuttX nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +usage="Usage: $0 " + +# Make sure we understand where we are + +if [ ! -f tools/mksymtab.sh ]; then + cd .. || { echo "ERROR: cd .. failed"; exit 1; } + if [ ! -f tools/mksymtab.sh ]; then + error "This script must be executed from the top-level apps/ directory" + exit 1 + fi +fi + +# Check for the required directory path + +dir=$1 +if [ -z "$dir" ]; then + echo "ERROR: Missing " + echo "" + echo $usage + exit 1 +fi + +if [ ! -d "$dir" ]; then + echo "ERROR: Directory $dir does not exist" + echo "" + echo $usage + exit 1 +fi + +# Get the output file name + +outfile=$2 +if [ -z "$outfile" ]; then + echo "ERROR: Missing " + echo "" + echo $usage + exit 1 +fi + +rm -f $outfile + +# Extract all of the undefined symbols from the ELF files and create a +# list of sorted, unique undefined variable names. + +varlist=`find ${dir} -executable -type f | xargs nm | fgrep ' U ' | sed -e "s/^[ ]*//g" | cut -d' ' -f2 | sort | uniq` + +# Now output the symbol table as a structure in a C source file. All +# undefined symbols are declared as void* types. If the toolchain does +# any kind of checking for function vs. data objects, then this could +# faile + +echo "#include " >$outfile +echo "#include " >>$outfile +echo "" >>$outfile + +for var in $varlist; do + echo "extern void *${var};" >>$outfile +done + +echo "" >>$outfile +echo "const struct symtab_s g_symtab[] = " >>$outfile +echo "{" >>$outfile + +for var in $varlist; do + echo " {\"${var}\", &${var}}," >>$outfile +done + +echo "};" >>$outfile +echo "" >>$outfile +echo "const int g_nsymbols = sizeof(g_symtab) / sizeof(struct symtab_s);" >>$outfile