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.

This commit is contained in:
Pavel Pisa 2015-08-23 08:38:58 -06:00 committed by Gregory Nutt
parent ad5448d9b4
commit 81a257eeb0
9 changed files with 255 additions and 0 deletions

View File

@ -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).

View File

@ -1513,6 +1513,8 @@ nuttx/
|- lib/
| `- README.txt
|- libc/
| |- symtab/
| | `- README.txt
| `- README.txt
|- libnx/
| `- README.txt

View File

@ -0,0 +1,102 @@
/****************************************************************************
* include/nuttx/binfmt/canned_symtab.h
*
* Copyright (C) 2015 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.
*
****************************************************************************/
#ifndef __INCLUDE_NUTTX_BINFMT_CANNED_SYMTAB_H
#define __INCLUDE_NUTTX_BINFMT_CANNED_SYMTAB_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
/****************************************************************************
* 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 */

View File

@ -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

View File

@ -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 /)

14
libc/symtab/Kconfig Normal file
View File

@ -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.

45
libc/symtab/Make.defs Normal file
View File

@ -0,0 +1,45 @@
############################################################################
# libc/symtab/Make.defs
#
# Copyright (C) 2015 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.
#
############################################################################
ifeq ($(CONFIG_LIBC_SYMTAB),y)
# Include canned symtab to the build
CSRCS += lib_symtab.c
DEPPATH += --dep-path symtab
VPATH += :symtab
endif

19
libc/symtab/README.txt Normal file
View File

@ -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 <nuttx/binfmt/canned_symtab.h>
...
canned_symtab_initialize();

61
libc/symtab/lib_symbtab.c Normal file
View File

@ -0,0 +1,61 @@
/****************************************************************************
* libc/symtab/lib_symtab.c
*
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Canned symtab implemented by Pavel Pisa <ppisa@pikron.com>
*
* 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 <nuttx/config.h>
#ifdef CONFIG_LIBC_SYMTAB
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/compiler.h>
#include <nuttx/binfmt/symtab.h>
#include <nuttx/binfmt/canned_symtab.h>
#include "canned_symtab.inc"
/************************************************************************
* Public Functions
************************************************************************/
void canned_symtab_initialize(void)
{
exec_setsymtab(g_symtab, NSYMBOLS);
}
#endif /* CONFIG_LIBC_SYMTAB */