Squashed commit of the following:

binfmt/, libs/libc/unistd, and others:  Rename CONFIG_EXECFUNCS_SYMTAB to CONFIG_EXECFUNCS_SYMTAB_ARRAY.  Rename CONFIG_EXECFUNCS_NSYMBOLS to CONFIG_EXECFUNCS_NSYMBOLS_VAR.  Unlike CONFIG_EXECFUNCS_NSYMBOLS, CONFIG_EXECFUNCS_NSYMBOLS_VAR holds the name of an 'int' variable that contains the number of symbols in the symbol table.

    configs/sama5d4-ek:  Partial update to knsh build instructions.
This commit is contained in:
Gregory Nutt 2018-07-15 11:20:37 -06:00
parent 07b13260ce
commit 4c67062457
10 changed files with 97 additions and 36 deletions

View file

@ -13,7 +13,7 @@
<h1><big><font color="#3c34ec"><i>NuttX Operating System<p>User's Manual</i></font></big></h1>
<p><small>by</small></p>
<p>Gregory Nutt<p>
<p>Last Updated: October 20, 2017</p>
<p>Last Updated: July 15, 2018</p>
</td>
</tr>
</table>
@ -953,12 +953,12 @@ int execv(FAR const char *path, FAR char *const argv[]);
Enable <code>execv()</code> and <code>execl()</code> support
</li>
<li>
<code>CONFIG_EXECFUNCS_SYMTAB</code>:
Symbol table used by <code>execv()</code> or <code>execl()</code>.
<code>CONFIG_EXECFUNCS_SYMTAB_ARRAY</code>:
Name of the ymbol table used by <code>execv()</code> or <code>execl()</code>.
</li>
<li>
<code>CONFIG_EXECFUNCS_NSYMBOLS</code>:
Number of symbols in the symbol table
<code>CONFIG_EXECFUNCS_NSYMBOLS_VAR</code>:
Name of the <code>int</code> variable holding the number of symbols in the symbol table
</li>
</ul>
<p>

View file

@ -57,14 +57,14 @@
#ifdef CONFIG_EXECFUNCS_HAVE_SYMTAB
/* Symbol table used by exec[l|v] */
# ifndef CONFIG_EXECFUNCS_SYMTAB
# error "CONFIG_EXECFUNCS_SYMTAB must be defined"
# ifndef CONFIG_EXECFUNCS_SYMTAB_ARRAY
# error "CONFIG_EXECFUNCS_SYMTAB_ARRAY must be defined"
# endif
/* Number of Symbols in the Table */
# ifndef CONFIG_EXECFUNCS_NSYMBOLS
# error "CONFIG_EXECFUNCS_NSYMBOLS must be defined"
# ifndef CONFIG_EXECFUNCS_NSYBOLS_VAR
# error "CONFIG_EXECFUNCS_NSYBOLS_VAR must be defined"
# endif
#endif
@ -73,7 +73,8 @@
****************************************************************************/
#ifdef CONFIG_EXECFUNCS_HAVE_SYMTAB
extern const struct symtab_s CONFIG_EXECFUNCS_SYMTAB;
extern const struct symtab_s CONFIG_EXECFUNCS_SYMTAB_ARRAY[];
extern int CONFIG_EXECFUNCS_NSYBOLS_VAR;
#endif
/****************************************************************************
@ -81,8 +82,8 @@ extern const struct symtab_s CONFIG_EXECFUNCS_SYMTAB;
****************************************************************************/
#ifdef CONFIG_EXECFUNCS_HAVE_SYMTAB
static FAR const struct symtab_s *g_exec_symtab = &CONFIG_EXECFUNCS_SYMTAB;
static int g_exec_nsymbols = CONFIG_EXECFUNCS_NSYMBOLS;
static FAR const struct symtab_s *g_exec_symtab = CONFIG_EXECFUNCS_SYMTAB_ARRAY;
static int g_exec_nsymbols = CONFIG_EXECFUNCS_NSYBOLS_VAR;
#else
static FAR const struct symtab_s *g_exec_symtab;
static int g_exec_nsymbols;

View file

@ -103,7 +103,7 @@ Here is a simple test configuration using the NuttX simulator:
4. In lieu of a a real test application, this Quick'n'Dirty patch can be used
to initialize the P-Code binary format:
@@ -115,6 +115,7 @@ const struct symtab_s CONFIG_EXECFUNCS_SYMTAB[1];
@@ -115,6 +115,7 @@ const struct symtab_s CONFIG_EXECFUNCS_SYMTAB_ARRAY[1];
/****************************************************************************
* Name: nsh_main
****************************************************************************/

View file

@ -3900,7 +3900,7 @@ Configurations
4. A system call interface is enabled and the ELF test programs interface
with the base RTOS code system calls. This eliminates the need for symbol
tables to link with the base RTOS (symbol tables are still used, however,
to interface with the common C library instaniation). Relevant
to interface with the common C library instantiation). Relevant
configuration settings:
RTOS Features -> System call support
@ -4157,38 +4157,89 @@ Configurations
6a. General build directions (boot from SD card):
A. Build with no symbol table
$ cd nuttx : Go to the NuttX build directory
$ tools/configure.sh sama5d4-ek/kernel : Establish this configuration
$ export PATH=???:$PATH : Set up the PATH variable
$ make : Build the kerne with a dummy ROMFS image
: This should create the nuttx ELF
B. Create the export package
$ make export : Create the kernel export package
: You should have a file like
: nuttx-export-*.zip
C. Build the file system image at apps/bin
$ cd apps/ : Go to the apps/ directory
$ tools/mkimport.sh -x <zip-file> : Use the full path to nuttx-export-*.zip
$ make import : This will build the file system.
You will then need to copy the files from apps/bin to an SD card to
create the bootable SD card.
D. Create the symbol table from the apps/bin
$ tools/mksymtab.sh bin import/symtab.c
$ ar rcs ../nuttx/binfmt/libbinfmt.a import/symtab.o
NOTE: There are many ways to create symbol tables. The above will create
the minimal symbol tabled needed.
E. Reconfigure and rebuild NuttX
Enable the following in the configuration:
CONFIG_EXECFUNCS_HAVE_SYMTAB=y
CONFIG_EXECFUNCS_SYMTAB_ARRAY="g_symtab"
CONFIG_EXEDFUNCS_NSYMBOLS_VAR="g_nsymbols"
CONFIG_USER_INITPATH="/bin/init"
$ cd nuttx/ : Rebuild the system with the correct
$ make clean_context all : symbol table
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.
But how does the SD card/USB drive get mounted? This must be done in
board-specific logic before the 'init' program is started.
6b. General build directions (boot from ROMFS image):
A. Build with dummy ROMFS file system image and no symbol table
$ tools/configure.sh sama5d4-ek/kernel : Establish this configuration
$ export PATH=???:$PATH : Set up the PATH variable
$ touch configs/sama5d4-ek/include/boot_romfsimg.h
$ make : Build the kernel with a dummy ROMFS image
: This should create the nuttx ELF
B. Create the export package
$ make export : Create the kernel export package
: You should have a file like
: nuttx-export-*.zip
C. Build the file system image at apps/bin
$ cd apps/ : Go to the apps/ directory
$ tools/mkimport.sh -x <zip-file> : Use the full path to nuttx-export-*.zip
$ make import : This will build the file system
D. Create the ROMFS file system image
$ tools/mkromfsimg.sh : Create the real ROMFS image
$ mv boot_romfsimg.h ../nuttx/configs/sama5d4-ek/include/boot_romfsimg.h
E. Create the symbol table from the apps/bin
$ tools/mksymtab.sh bin import/symtab.c
$ ar rcs ../nuttx/binfmt/libbinfmt.a import/symtab.o
NOTE: There are many ways to create symbol tables. The above will create
the minimal symbol tabled needed.
F. Reconfigure and rebuild NuttX
Enable the following in the configuration:
CONFIG_EXECFUNCS_HAVE_SYMTAB=y
CONFIG_EXECFUNCS_SYMTAB_ARRAY="g_symtab"
CONFIG_EXEDFUNCS_NSYMBOLS_VAR="g_nsymbols"
CONFIG_USER_INITPATH="/bin/init"
$ cd nuttx/ : Rebuild the system with the correct
$ make clean_context all : ROMFS file system
$ make clean_context all : ROMFS file system and symbol table
But how does the ROMFS file system get mounted? This must be done in
board-specific logic before the 'init' program is started.
STATUS:
@ -4210,14 +4261,19 @@ Configurations
Update: I don't believe that this HSMCI error occurs if file system
debug output is enabled.
2014-9-11: Everything seems to be working quite nicely witn the ROMFS
2014-9-11: Everything seems to be working quite nicely with the ROMFS
file system. A considerable amount of testing has been done and
there are no known defects as of this writing.
2014-9-16: After some substantial effort, I think I may have resolved
the last of the mainstream bugs that prevented from executing other
user processes from a user processes. Long story but I am glad to
haave that done.
have that done.
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
table, but I am currently stuck in the 'make import' step. This
currently dies with a mysterious error '/bin/sh: -w: invalid option'
nsh:

View file

@ -1,3 +1,4 @@
# CONFIG_EXECFUNCS_HAVE_SYMTAB is not set
# CONFIG_MMCSD_MMCSUPPORT is not set
# CONFIG_NSH_CMDPARMS is not set
# CONFIG_SAMA5_UART0 is not set

View file

@ -13,7 +13,9 @@ CONFIG_BOARD_LOOPSPERMSEC=16717
CONFIG_DEV_LOWCONSOLE=y
CONFIG_ELF=y
CONFIG_EXAMPLES_POSIXSPAWN=y
CONFIG_EXECFUNCS_NSYMBOLS=10
CONFIG_EXECFUNCS_HAVE_SYMTAB=y
CONFIG_EXECFUNCS_NSYMBOLS_VAR="g_spawn_nsymbols"
CONFIG_EXECFUNCS_SYMTAB_ARRAY="g_spawn_symtab"
CONFIG_FS_ROMFS=y
CONFIG_HAVE_CXX=y
CONFIG_HOST_WINDOWS=y

View file

@ -43,7 +43,7 @@ config EXECFUNCS_HAVE_SYMTAB
cases in order to link executable programs to the base code.
NOTE: This option only pre-initializes the system symbol table as
defined by CONFIG_EXECFUNCS_SYMTAB and CONFIG_EXECFUNCS_NSYMBOLS.
defined by CONFIG_EXECFUNCS_SYMTAB_ARRAY and CONFIG_EXECFUNCS_NSYMBOLS_VAR.
This is simply an optional, automatic initialization of the
system symbol table. You would need to do this, for example, in
in the kernel build were the first task must be run from a program
@ -54,8 +54,8 @@ config EXECFUNCS_HAVE_SYMTAB
from your application initialization logic.
if EXECFUNCS_HAVE_SYMTAB
config EXECFUNCS_SYMTAB
string "Symbol table used by exec[l|v]"
config EXECFUNCS_SYMTAB_ARRAY
string "Symbol table name used by exec[l|v]"
default "g_symtab"
---help---
The exec[l|v] and posix_spawn() functions are wrapper functions that
@ -65,16 +65,16 @@ config EXECFUNCS_SYMTAB
symbols in that table. This selection provides the name of that
symbol table.
config EXECFUNCS_NSYMBOLS
int "Number of Symbols in the Table"
default 0
config EXECFUNCS_NSYMBOLS_VAR
string"Name of variable holding the number of symbols"
default "g_nsymbols"
---help---
The exec[l|v] and posix_spawn() functions are wrapper functions that
call the non-standard binfmt function 'exec'). The binfmt
function 'exec' needs to have (1) a symbol table that provides the
list of symbols exported by the base code, and (2) the number of
symbols in that table. This selection provides the number of
symbols in the symbol table.
symbols in that table. This selection provides the name of an 'int'
variable that contains the number of symbols in the symbol table.
endif # EXECFUNCS_HAVE_SYMTAB
endif # LIBC_EXECFUNCS

View file

@ -98,9 +98,9 @@
* (2) the number of symbols in that table. This information is currently
* provided to 'exec()' from 'exec[l|v]()' via NuttX configuration settings:
*
* CONFIG_LIBC_EXECFUNCS : Enable exec[l|v] support
* CONFIG_EXECFUNCS_SYMTAB : Symbol table used by exec[l|v]
* CONFIG_EXECFUNCS_NSYMBOLS : Number of symbols in the table
* CONFIG_LIBC_EXECFUNCS : Enable exec[l|v] support
* CONFIG_EXECFUNCS_SYMTAB_ARRAY : Symbol table name used by exec[l|v]
* CONFIG_EXECFUNCS_NSYMBOLS_VAR : Variable holding number of symbols in the table
*
* As a result of the above, the current implementations of 'execl()' and
* 'execv()' suffer from some incompatibilities that may or may not be

View file

@ -92,10 +92,10 @@
* (2) the number of symbols in that table. This information is currently
* provided to 'exec()' from 'exec[l|v]()' via NuttX configuration settings:
*
* CONFIG_LIBC_EXECFUNCS : Enable exec[l|v] support
* CONFIG_EXECFUNCS_HAVE_SYMTAB : Defined if there is a pre-defined symbol table
* CONFIG_EXECFUNCS_SYMTAB : Symbol table used by exec[l|v]
* CONFIG_EXECFUNCS_NSYMBOLS : Number of symbols in the table
* CONFIG_LIBC_EXECFUNCS : Enable exec[l|v] support
* CONFIG_EXECFUNCS_HAVE_SYMTAB : Defined if there is a pre-defined symbol table
* CONFIG_EXECFUNCS_SYMTAB_ARRAY : Symbol table name used by exec[l|v]
* CONFIG_EXECFUNCS_NSYMBOLS_VAR : Variable holding number of symbols in the table
*
* As a result of the above, the current implementations of 'execl()' and
* 'execv()' suffer from some incompatibilities that may or may not be

View file

@ -64,7 +64,8 @@ static const char *dequote_list[] =
/* NuttX */
"CONFIG_USER_ENTRYPOINT", /* Name of entry point function */
"CONFIG_EXECFUNCS_SYMTAB", /* Symbol table used by exec[l|v] */
"CONFIG_EXECFUNCS_SYMTAB_ARRAY", /* Symbol table array used by exec[l|v] */
"CONFIG_EXECFUNCS_NSYMBOLS_VAR", /* Variable holding number of symbols in the table */
"CONFIG_PASS1_BUILDIR", /* Pass1 build directory */
"CONFIG_PASS1_TARGET", /* Pass1 build target */
"CONFIG_PASS1_OBJECT", /* Pass1 build object */