diff --git a/ChangeLog b/ChangeLog index 4a3e93db1b5..c0ba51ab8b6 100755 --- a/ChangeLog +++ b/ChangeLog @@ -10866,3 +10866,12 @@ as defined in the standard. Original implementation used that for numeric addresses but for DNS lookup returned pointer to whole sockaddr_in or sockaddr_in6. From Pavel Pisa (2015-08-21). + * tools/mksymtab: declare g_symtab array as conts to occupy RO + section (Flash). From Pavel Pisa (2015-08-23). + * libc/symtab: Optional canned symtab inclusion to the build. When + option CONFIG_LIBC_SYMTAB is selected and symbol table file + libc/symtab/canned_symtab.inc is prepared then application can + use system provided complete symbol table. The option has + substantial effect on system image size. Mainly code/text. If + loading of applications at runtime is not planned do not select + this. From Pavel Pisa (2015-08-23). diff --git a/README.txt b/README.txt index 4f8b3643534..035159dea8c 100644 --- a/README.txt +++ b/README.txt @@ -1513,6 +1513,8 @@ nuttx/ |- lib/ | `- README.txt |- libc/ + | |- symtab/ + | | `- README.txt | `- README.txt |- libnx/ | `- README.txt diff --git a/include/nuttx/binfmt/canned_symtab.h b/include/nuttx/binfmt/canned_symtab.h new file mode 100644 index 00000000000..ba3419dec31 --- /dev/null +++ b/include/nuttx/binfmt/canned_symtab.h @@ -0,0 +1,102 @@ +/**************************************************************************** + * include/nuttx/binfmt/canned_symtab.h + * + * Copyright (C) 2015 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. + * + ****************************************************************************/ + +#ifndef __INCLUDE_NUTTX_BINFMT_CANNED_SYMTAB_H +#define __INCLUDE_NUTTX_BINFMT_CANNED_SYMTAB_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +/* struct symbtab_s describes one entry in the symbol table. A symbol table + * is a fixed size array of struct symtab_s. The information is intentionally + * minimal and supports only: + * + * 1. Function pointers as sym_values. Of other kinds of values need to be + * supported, then typing information would also need to be included in + * the structure. + * + * 2. Fixed size arrays. There is no explicit provisional for dynamically + * adding or removing entries from the symbol table (realloc might be + * used for that purpose if needed). The intention is to support only + * fixed size arrays completely defined at compilation or link time. + */ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +#undef EXTERN +#if defined(__cplusplus) +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Name: canned_symtab_initialize + * + * Description: + * Setup system provided canned symbol table. + * + * Input Parameters: + * None + * + * Returned Value: + * None + * + ****************************************************************************/ + +void canned_symtab_initialize(void); + +#undef EXTERN +#if defined(__cplusplus) +} +#endif + +#endif /* __INCLUDE_NUTTX_BINFMT_CANNED_SYMTAB_H */ + diff --git a/libc/Kconfig b/libc/Kconfig index e51915d1c27..1be0aedcd0d 100644 --- a/libc/Kconfig +++ b/libc/Kconfig @@ -195,6 +195,8 @@ config EXECFUNCS_NSYMBOLS symbols in that table. This selection provides the number of symbols in the symbol table. +source libc/symtab/Kconfig + endif # EXECFUNCS_HAVE_SYMTAB endif # LIBC_EXECFUNCS diff --git a/libc/Makefile b/libc/Makefile index 76d3e473aa7..6509aa61d7d 100644 --- a/libc/Makefile +++ b/libc/Makefile @@ -84,6 +84,7 @@ include queue/Make.defs include wqueue/Make.defs include misc/Make.defs include audio/Make.defs +include symtab/Make.defs # REVISIT: Backslash causes problems in $(COBJS) target DELIM := $(strip /) diff --git a/libc/symtab/Kconfig b/libc/symtab/Kconfig new file mode 100644 index 00000000000..317abaff47a --- /dev/null +++ b/libc/symtab/Kconfig @@ -0,0 +1,14 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +config LIBC_SYMTAB + bool "Include canned symtab for applications and shell" + default n + depends on EXECFUNCS_HAVE_SYMTAB + ---help--- + Build and include default symbol table in the NuttX library. + The symbol table is selected by call canned_symtab_initialize(). + The table libc/symtab/canned_symtab.inc has to be generated + by mksymtab manually before this option is selected. diff --git a/libc/symtab/Make.defs b/libc/symtab/Make.defs new file mode 100644 index 00000000000..98954a0e0df --- /dev/null +++ b/libc/symtab/Make.defs @@ -0,0 +1,45 @@ +############################################################################ +# libc/symtab/Make.defs +# +# Copyright (C) 2015 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. +# +############################################################################ + +ifeq ($(CONFIG_LIBC_SYMTAB),y) + +# Include canned symtab to the build + +CSRCS += lib_symtab.c + +DEPPATH += --dep-path symtab +VPATH += :symtab + +endif diff --git a/libc/symtab/README.txt b/libc/symtab/README.txt new file mode 100644 index 00000000000..21bb1759da5 --- /dev/null +++ b/libc/symtab/README.txt @@ -0,0 +1,19 @@ +symtab +====== + +This directory provide support for canned symbol table which provides +all/most of system and libc services/functions to the application and NSH. + +The support is selected by CONFIG_LIBC_SYMTAB option and table has to be +prepared in advance manually. + +It can be prepared from NuttX top level directory by next commands + + cat syscall/syscall.csv libc/libc.csv | sort >libc/symtab/canned_symtab.csv + tools/mksymtab libc/symtab/canned_symtab.csv libc/symtab/canned_symtab.inc + +Next code selectes canned symtab from application: + + #include + ... + canned_symtab_initialize(); diff --git a/libc/symtab/lib_symbtab.c b/libc/symtab/lib_symbtab.c new file mode 100644 index 00000000000..bdf9d32413b --- /dev/null +++ b/libc/symtab/lib_symbtab.c @@ -0,0 +1,61 @@ +/**************************************************************************** + * libc/symtab/lib_symtab.c + * + * Copyright (C) 2015 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Canned symtab implemented by Pavel Pisa + * + * 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 + +#ifdef CONFIG_LIBC_SYMTAB + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include + +#include "canned_symtab.inc" + +/************************************************************************ + * Public Functions + ************************************************************************/ + +void canned_symtab_initialize(void) +{ + exec_setsymtab(g_symtab, NSYMBOLS); +} + +#endif /* CONFIG_LIBC_SYMTAB */