Squashed commit of the following:
cosmetic import/: Add Makefile.symtab which can be used to compile the dynamically created symbol table C file. Add tools/mksymtab.sh
This commit is contained in:
parent
aea8d948d4
commit
878fa8afd5
@ -1468,10 +1468,12 @@ examples/posix_spawn
|
|||||||
CONFIG_BINFMT_DISABLE=n - Don't disable the binary loader
|
CONFIG_BINFMT_DISABLE=n - Don't disable the binary loader
|
||||||
CONFIG_ELF=y - Enable ELF binary loader
|
CONFIG_ELF=y - Enable ELF binary loader
|
||||||
CONFIG_LIBC_EXECFUNCS=y - Enable support for posix_spawn
|
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.
|
created by the test.
|
||||||
CONFIG_EXECFUNCS_NSYMBOLS=10 - Value does not matter, it will be
|
CONFIG_EXECFUNCS_NSYMBOLS_VAR="g_spawn_nexports"
|
||||||
corrected at runtime.
|
- Name of variable holding the
|
||||||
|
number of symbols
|
||||||
CONFIG_POSIX_SPAWN_STACKSIZE=768 - This default setting.
|
CONFIG_POSIX_SPAWN_STACKSIZE=768 - This default setting.
|
||||||
|
|
||||||
Test-specific configuration options:
|
Test-specific configuration options:
|
||||||
|
@ -39,34 +39,34 @@ include $(APPDIR)/Make.defs
|
|||||||
|
|
||||||
# mkfatfs utility
|
# mkfatfs utility
|
||||||
|
|
||||||
ASRCS =
|
ASRCS =
|
||||||
CSRCS =
|
CSRCS =
|
||||||
|
|
||||||
ifeq ($(CONFIG_FSUTILS_MKFATFS),y)
|
ifeq ($(CONFIG_FSUTILS_MKFATFS),y)
|
||||||
CSRCS = mkfatfs.c configfat.c writefat.c
|
CSRCS = mkfatfs.c configfat.c writefat.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
AOBJS = $(ASRCS:.S=$(OBJEXT))
|
AOBJS = $(ASRCS:.S=$(OBJEXT))
|
||||||
COBJS = $(CSRCS:.c=$(OBJEXT))
|
COBJS = $(CSRCS:.c=$(OBJEXT))
|
||||||
|
|
||||||
SRCS = $(ASRCS) $(CSRCS)
|
SRCS = $(ASRCS) $(CSRCS)
|
||||||
OBJS = $(AOBJS) $(COBJS)
|
OBJS = $(AOBJS) $(COBJS)
|
||||||
|
|
||||||
ifeq ($(CONFIG_WINDOWS_NATIVE),y)
|
ifeq ($(CONFIG_WINDOWS_NATIVE),y)
|
||||||
BIN = ..\..\libapps$(LIBEXT)
|
BIN = ..\..\libapps$(LIBEXT)
|
||||||
else
|
else
|
||||||
ifeq ($(WINTOOL),y)
|
ifeq ($(WINTOOL),y)
|
||||||
BIN = ..\\..\\libapps$(LIBEXT)
|
BIN = ..\\..\\libapps$(LIBEXT)
|
||||||
else
|
else
|
||||||
BIN = ../../libapps$(LIBEXT)
|
BIN = ../../libapps$(LIBEXT)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ROOTDEPPATH = --dep-path .
|
ROOTDEPPATH = --dep-path .
|
||||||
|
|
||||||
# Common build
|
# Common build
|
||||||
|
|
||||||
VPATH =
|
VPATH =
|
||||||
|
|
||||||
all: .built
|
all: .built
|
||||||
.PHONY: context depend clean distclean preconfig
|
.PHONY: context depend clean distclean preconfig
|
||||||
|
3
import/.gitignore
vendored
3
import/.gitignore
vendored
@ -1,4 +1,7 @@
|
|||||||
/.config
|
/.config
|
||||||
|
/System.map
|
||||||
|
/User.map
|
||||||
|
/symtab.c
|
||||||
/arch
|
/arch
|
||||||
/build
|
/build
|
||||||
/libs
|
/libs
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
############################################################################
|
############################################################################
|
||||||
# apps/import/Makefile
|
# apps/import/Makefile
|
||||||
#
|
#
|
||||||
# Copyright (C) 2014 Gregory Nutt. All rights reserved.
|
# Copyright (C) 2014, 2018 Gregory Nutt. All rights reserved.
|
||||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# Redistribution and use in source and binary forms, with or without
|
||||||
@ -39,25 +39,39 @@
|
|||||||
# Sub-directories from the NuttX export package
|
# Sub-directories from the NuttX export package
|
||||||
|
|
||||||
SUBDIRS = arch build include libs startup tmp
|
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)
|
.PRECIOUS: ../libapps$(LIBEXT)
|
||||||
|
|
||||||
nothing:
|
symtab:
|
||||||
|
$(call MKSYMTAB, all)
|
||||||
|
|
||||||
install:
|
install:
|
||||||
|
$(call MKSYMTAB, install)
|
||||||
|
|
||||||
context:
|
context:
|
||||||
|
$(call MKSYMTAB, context)
|
||||||
|
|
||||||
depend:
|
depend:
|
||||||
|
$(call MKSYMTAB, depend)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
$(call MKSYMTAB, clean)
|
||||||
|
|
||||||
distclean:
|
distclean:
|
||||||
$(foreach SDIR, $(SUBDIRS), $(call DELDIR, $(SDIR)))
|
$(foreach SDIR, $(SUBDIRS), $(call DELDIR, $(SDIR)))
|
||||||
$(foreach FILE, $(FILES), $(call DELFILE, $(FILE)))
|
$(foreach FILE, $(FILES), $(call DELFILE, $(FILE)))
|
||||||
|
$(call MKSYMTAB, distclean)
|
||||||
|
$(call DELFILE, symtab.c)
|
||||||
|
|
||||||
# Library path
|
# Library path
|
||||||
|
|
||||||
|
40
import/Makefile.symtab
Normal file
40
import/Makefile.symtab
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
############################################################################
|
||||||
|
# apps/import/Makefile.symtab
|
||||||
|
#
|
||||||
|
# Copyright (C) 2018 Gregory Nutt. All rights reserved.
|
||||||
|
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
|
#
|
||||||
|
# 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
|
106
tools/mksymtab.sh
Normal file
106
tools/mksymtab.sh
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
############################################################################
|
||||||
|
# apps/tools/mksymtab.sh
|
||||||
|
#
|
||||||
|
# Copyright (C) 2018 Gregory Nutt. All rights reserved.
|
||||||
|
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
|
#
|
||||||
|
# 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 <imagedirpath> <outfilepath>"
|
||||||
|
|
||||||
|
# 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 <imagedirpath>"
|
||||||
|
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 <outfilepath>"
|
||||||
|
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 <nuttx/compiler.h>" >$outfile
|
||||||
|
echo "#include <nuttx/binfmt/symtab.h>" >>$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
|
Loading…
x
Reference in New Issue
Block a user