mirror of
https://github.com/apache/nuttx.git
synced 2025-12-11 12:57:57 +08:00
binfmt/binfmt_execsymtab.c: Fix a recently introduced error: The size of the symbol table is now an 'int' variable; but a variable cannot be used as an initializer because it is not constant. Also updates a README file.
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* binfmt/binfmt_execsymtab.c
|
* binfmt/binfmt_execsymtab.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013, 2016 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2013, 2016, 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
|
||||||
@@ -81,13 +81,8 @@ extern int CONFIG_EXECFUNCS_NSYMBOLS_VAR;
|
|||||||
* Private Data
|
* Private Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_EXECFUNCS_HAVE_SYMTAB
|
|
||||||
static FAR const struct symtab_s *g_exec_symtab = CONFIG_EXECFUNCS_SYMTAB_ARRAY;
|
|
||||||
static int g_exec_nsymbols = CONFIG_EXECFUNCS_NSYMBOLS_VAR;
|
|
||||||
#else
|
|
||||||
static FAR const struct symtab_s *g_exec_symtab;
|
static FAR const struct symtab_s *g_exec_symtab;
|
||||||
static int g_exec_nsymbols;
|
static int g_exec_nsymbols;
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
@@ -112,13 +107,29 @@ void exec_getsymtab(FAR const struct symtab_s **symtab, FAR int *nsymbols)
|
|||||||
{
|
{
|
||||||
irqstate_t flags;
|
irqstate_t flags;
|
||||||
|
|
||||||
DEBUGASSERT(symtab && nsymbols);
|
DEBUGASSERT(symtab != NULL && nsymbols != NULL);
|
||||||
|
|
||||||
/* Disable interrupts very briefly so that both the symbol table and its
|
/* Disable interrupts very briefly so that both the symbol table and its
|
||||||
* size are returned as a single atomic operation.
|
* size are returned as a single atomic operation.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = enter_critical_section();
|
flags = enter_critical_section();
|
||||||
|
|
||||||
|
#ifdef CONFIG_EXECFUNCS_HAVE_SYMTAB
|
||||||
|
/* If a bring-up symbol table has been provided and if the exec symbol
|
||||||
|
* table has not yet been initialized, then use the provided start-up
|
||||||
|
* symbol table.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (g_exec_symtab == NULL)
|
||||||
|
{
|
||||||
|
g_exec_symtab = CONFIG_EXECFUNCS_SYMTAB_ARRAY;
|
||||||
|
g_exec_nsymbols = CONFIG_EXECFUNCS_NSYMBOLS_VAR;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Return the symbol table and its size */
|
||||||
|
|
||||||
*symtab = g_exec_symtab;
|
*symtab = g_exec_symtab;
|
||||||
*nsymbols = g_exec_nsymbols;
|
*nsymbols = g_exec_nsymbols;
|
||||||
leave_critical_section(flags);
|
leave_critical_section(flags);
|
||||||
@@ -143,7 +154,7 @@ void exec_setsymtab(FAR const struct symtab_s *symtab, int nsymbols)
|
|||||||
{
|
{
|
||||||
irqstate_t flags;
|
irqstate_t flags;
|
||||||
|
|
||||||
DEBUGASSERT(symtab);
|
DEBUGASSERT(symtab != NULL);
|
||||||
|
|
||||||
/* Disable interrupts very briefly so that both the symbol table and its
|
/* Disable interrupts very briefly so that both the symbol table and its
|
||||||
* size are set as a single atomic operation.
|
* size are set as a single atomic operation.
|
||||||
|
|||||||
@@ -4158,6 +4158,7 @@ Configurations
|
|||||||
6a. General build directions (boot from SD card):
|
6a. General build directions (boot from SD card):
|
||||||
|
|
||||||
A. Build with no symbol table
|
A. Build with no symbol table
|
||||||
|
|
||||||
$ cd nuttx : Go to the NuttX build directory
|
$ cd nuttx : Go to the NuttX build directory
|
||||||
$ tools/configure.sh sama5d4-ek/kernel : Establish this configuration
|
$ tools/configure.sh sama5d4-ek/kernel : Establish this configuration
|
||||||
$ export PATH=???:$PATH : Set up the PATH variable
|
$ export PATH=???:$PATH : Set up the PATH variable
|
||||||
@@ -4165,16 +4166,19 @@ Configurations
|
|||||||
: This should create the nuttx ELF
|
: This should create the nuttx ELF
|
||||||
|
|
||||||
B. Create the export package
|
B. Create the export package
|
||||||
|
|
||||||
$ make export : Create the kernel export package
|
$ make export : Create the kernel export package
|
||||||
: You should have a file like
|
: You should have a file like
|
||||||
: nuttx-export-*.zip
|
: nuttx-export-*.zip
|
||||||
|
|
||||||
C. Build the file system image at apps/bin
|
C. Build the file system image at apps/bin
|
||||||
|
|
||||||
$ cd apps/ : Go to the apps/ directory
|
$ cd apps/ : Go to the apps/ directory
|
||||||
$ tools/mkimport.sh -x <zip-file> : Use the full path to nuttx-export-*.zip
|
$ tools/mkimport.sh -x <zip-file> : Use the full path to nuttx-export-*.zip
|
||||||
$ make import : This will build the file system.
|
$ make import : This will build the file system.
|
||||||
|
|
||||||
D. Create the symbol table from the apps/bin
|
D. Create the symbol table from the apps/bin
|
||||||
|
|
||||||
$ tools/mksymtab.sh bin import/symtab.c
|
$ tools/mksymtab.sh bin import/symtab.c
|
||||||
$ ar rcs ../nuttx/binfmt/libbinfmt.a import/symtab.o
|
$ ar rcs ../nuttx/binfmt/libbinfmt.a import/symtab.o
|
||||||
|
|
||||||
@@ -4195,12 +4199,15 @@ Configurations
|
|||||||
You will then need to copy the files from apps/bin to an SD card or USB
|
You will then need to copy the files from apps/bin to an SD card or USB
|
||||||
FLASH drive to create the bootable SD card.
|
FLASH drive to create the bootable SD card.
|
||||||
|
|
||||||
But how does the SD card/USB drive get mounted? This must be done in
|
But how does the SD card/USB FLASH drive get mounted? This must be
|
||||||
board-specific logic before the 'init' program is started.
|
done in board-specific logic before the 'init' program is started.
|
||||||
|
That logic is not yet implemented for the case of SD card or USB FLASH
|
||||||
|
driver
|
||||||
|
|
||||||
6b. General build directions (boot from ROMFS image):
|
6b. General build directions (boot from ROMFS image):
|
||||||
|
|
||||||
A. Build with dummy ROMFS file system image and no symbol table
|
A. Build with dummy ROMFS file system image and no symbol table
|
||||||
|
|
||||||
$ tools/configure.sh sama5d4-ek/kernel : Establish this configuration
|
$ tools/configure.sh sama5d4-ek/kernel : Establish this configuration
|
||||||
$ export PATH=???:$PATH : Set up the PATH variable
|
$ export PATH=???:$PATH : Set up the PATH variable
|
||||||
$ touch configs/sama5d4-ek/include/boot_romfsimg.h
|
$ touch configs/sama5d4-ek/include/boot_romfsimg.h
|
||||||
@@ -4208,26 +4215,32 @@ Configurations
|
|||||||
: This should create the nuttx ELF
|
: This should create the nuttx ELF
|
||||||
|
|
||||||
B. Create the export package
|
B. Create the export package
|
||||||
|
|
||||||
$ make export : Create the kernel export package
|
$ make export : Create the kernel export package
|
||||||
: You should have a file like
|
: You should have a file like
|
||||||
: nuttx-export-*.zip
|
: nuttx-export-*.zip
|
||||||
|
|
||||||
C. Build the file system image at apps/bin
|
C. Build the file system image at apps/bin
|
||||||
|
|
||||||
$ cd apps/ : Go to the apps/ directory
|
$ cd apps/ : Go to the apps/ directory
|
||||||
$ tools/mkimport.sh -x <zip-file> : Use the full path to nuttx-export-*.zip
|
$ tools/mkimport.sh -x <zip-file> : Use the full path to nuttx-export-*.zip
|
||||||
$ make import : This will build the file system
|
$ make import : This will build the file system
|
||||||
|
|
||||||
D. Create the ROMFS file system image
|
D. Create the ROMFS file system image
|
||||||
|
|
||||||
$ tools/mkromfsimg.sh : Create the real ROMFS image
|
$ tools/mkromfsimg.sh : Create the real ROMFS image
|
||||||
$ mv boot_romfsimg.h ../nuttx/configs/sama5d4-ek/include/boot_romfsimg.h
|
$ mv boot_romfsimg.h ../nuttx/configs/sama5d4-ek/include/boot_romfsimg.h
|
||||||
|
|
||||||
E. Create the symbol table from the apps/bin
|
E. Create the symbol table from the apps/bin
|
||||||
|
|
||||||
$ tools/mksymtab.sh bin import/symtab.c
|
$ tools/mksymtab.sh bin import/symtab.c
|
||||||
|
$ make symtab : Compile the symbol table
|
||||||
$ ar rcs ../nuttx/binfmt/libbinfmt.a import/symtab.o
|
$ ar rcs ../nuttx/binfmt/libbinfmt.a import/symtab.o
|
||||||
|
|
||||||
NOTE: There are many ways to create symbol tables. The above will create
|
NOTE: There are many ways to create symbol tables. The above will create
|
||||||
the minimal symbol tabled needed.
|
the minimal symbol tabled needed.
|
||||||
|
|
||||||
F. Reconfigure and rebuild NuttX
|
F. Reconfigure and rebuild NuttX/bin
|
||||||
|
|
||||||
Enable the following in the configuration:
|
Enable the following in the configuration:
|
||||||
CONFIG_EXECFUNCS_HAVE_SYMTAB=y
|
CONFIG_EXECFUNCS_HAVE_SYMTAB=y
|
||||||
@@ -4238,8 +4251,8 @@ Configurations
|
|||||||
$ cd nuttx/ : Rebuild the system with the correct
|
$ cd nuttx/ : Rebuild the system with the correct
|
||||||
$ make clean_context all : ROMFS file system and symbol table
|
$ make clean_context all : ROMFS file system and symbol table
|
||||||
|
|
||||||
But how does the ROMFS file system get mounted? This must be done in
|
But how does the ROMFS file system get mounted? This is done in board-
|
||||||
board-specific logic before the 'init' program is started.
|
specific logic before the 'init' program is started.
|
||||||
|
|
||||||
STATUS:
|
STATUS:
|
||||||
|
|
||||||
@@ -4272,15 +4285,8 @@ Configurations
|
|||||||
|
|
||||||
2018-07-15: Revisited. It is not clear to me how, back in 2014, the
|
2018-07-15: Revisited. It is not clear to me how, back in 2014, the
|
||||||
symbol table was created. I have added logic to created the symbol
|
symbol table was created. I have added logic to created the symbol
|
||||||
table, but I am currently stuck in the 'make import' step. This
|
table. After some additional fixes, the full build is again
|
||||||
currently dies with a mysterious error '/bin/sh: -w: invalid option'
|
successful.
|
||||||
|
|
||||||
That mysterious error is comming from the COMPILE macro defined in
|
|
||||||
apps/import/Make.defs. There is something lethal about CFLAGS.
|
|
||||||
Although I can print all of the components of CFLAGS, the use of
|
|
||||||
CFLAGS causes the error. In fact, this will generate the same error;
|
|
||||||
|
|
||||||
$(warning CFLAGS=$(CFLAGS))
|
|
||||||
|
|
||||||
nsh:
|
nsh:
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user