diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index cb14281de2..df9e345fe2 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -3537,4 +3537,5 @@ they don't draw in so much un-necessary code when doing a dumb link. * binfmt/libelf: The ELF loader is working correctly with C++ static constructors and destructors and all. + * Documentation/NuttXBinfmt.html: Add documentionof the binary loader. diff --git a/nuttx/Documentation/NuttX.html b/nuttx/Documentation/NuttX.html index fc0291846c..0c98d4ad2e 100644 --- a/nuttx/Documentation/NuttX.html +++ b/nuttx/Documentation/NuttX.html @@ -453,17 +453,14 @@

  • - Support for separately linked, loadable ELF modules. -
  • -

    - - -
    - -

    -

  • - NXFLAT. - NXFLAT is a binary format that can be XIP from a file system. + A binary loader with support for the following formats: +
  • @@ -630,7 +627,7 @@

  • A NuttX port of Jeff Poskanzer's THTTPD HTTP server - integrated with NXFLAT to provide true, embedded CGI. + integrated with the NuttX binary loader to provide true, embedded CGI.
  • @@ -3691,7 +3688,11 @@ buildroot-1.10 2011-05-06 <gnutt@nuttx.org> - NXFLAT Binary Format + NuttX Binary Loader + + + + NXFLAT Binary Format diff --git a/nuttx/Documentation/NuttXBinfmt.html b/nuttx/Documentation/NuttXBinfmt.html new file mode 100644 index 0000000000..8d70d0135a --- /dev/null +++ b/nuttx/Documentation/NuttXBinfmt.html @@ -0,0 +1,467 @@ + + +NuttX Binary Loader + + +

    + + + + +
    +

    NuttX Binary Loader

    +

    Last Updated: October 30, 2012

    +
    +

    + + + + + +
    +

    Table of Contents

    +
    + + + + + + + +
    +

    1.0 Introduction

    +
    + +

    + Binary Loaders. + The purpose of a binary loader is to load and execute modules in various binary formats that reside in a file system. + Loading refers instiating the binary module in some fashion, usually copy all or some of the binary module into memory and then linking the module with other components. + In most architectures, it is thebase FLASH code that is the primary component that the binary module must link with because that is where the RTOS and primary tasks reside. + Program modules can then be executed after they have been loaded. +

    + +

    + Binary Formats. + The binary loader provides generic support for different binary formats. + It supports a registration interface that allows the number of support binary formats to be loaded at run time. + Each binary format provides a common, interface for use by the binary loader. + When asked to load a binary, the binary loader will query each registered binary format, providing it with the path of the binary object to be loaded. + The binary loader will stop when first binary format the recognizes the binary object and successfully loads it or when all registered binary formats have attempt loading the binary object and failed. +

    + +

    + At present, the following binary formats are support by NuttX: +

    + + +

    + Executables and Libraries + The generic binary loader logic does not care what it is that it being loaded. It could load an executable program or a library. + There are no strict rules, but a library will tend to export symbols and a program will tend to import symbols: The program will use the symbols exported by the library. + However, at this point in time, none of the supported binary formts support exporting of symbols. +

    + +

    + binfmt. + In the NuttX source code, the short name binfmt is used to refer to the NuttX binary loader. + This is the name of the directory containing the binary loader and the name of the header files and variables used by the binary loader. +

    + +

    + The name binfmt is the same name used by the Linux binary loader. + However, the NuttX binary loader is an independent development and shares nothing with the Linux binary loader other the same name and the same basic functionality. +

    + + + + + +
    +

    2.0 Binary Loader Interface

    +
    + +

    2.1 Binary Loader Header Files

    +

    + The interface to the binary loader is described in the header file + + include/nuttx/binfmt/binfmt.h. + A brief summary of the data structurs and interfaces prototyped in that header file are listed below. +

    + +

    2.2 Binary Loader Data Structures

    + +

    + When a binary format registers with the binary loader, it provides a pointer to a write-able instance of the following data structure: +

    + + +

    + The load method is used to load the binary format into memory. + It returns either OK (0) meaning that the binary object was loaded successfully, or a negater errno indicating why the object was not loaded. +

    + +

    + The type struct binary_s is use both to (2) describe the binary object to be loaded, and if successfully loaded, (2) to provide information about where and how the binary object was loaded. + That structure is shown below: +

    + + +

    + Where the types binfmt_ctor_t and binfmt_dtor_t define the type of one C++ constructor or destructor: +

    + + + +

    2.3 Binary Loader Function Interfaces

    + + + +

    2.3.1 register_binfmt()

    + +

    Function Prototype:

    + +

    Description:

    + +

    Returned Value:

    + + +

    2.3.2 unregister_binfmt()

    +

    Function Prototype:

    + +

    Description:

    + +

    Returned Value:

    + + +

    2.3.3 load_module()

    +

    Function Prototype:

    + +

    Description:

    + +

    Returned Value:

    + + +

    2.3.4 unload_module()

    +

    Function Prototype:

    + +

    Description:

    + +

    Returned Value:

    + + +

    2.3.5 exec_module()

    +

    Function Prototype:

    + +

    Description:

    + +

    Returned Value:

    + + +

    2.3.7 exec()

    +

    Function Prototype:

    + +

    Description:

    + +

    Input Parameters:

    + +

    Returned Value:

    + + + + + + +
    +

    3.0 Symbol Tables

    +
    + +

    + Symbol Tables. + Symbol tables are lists of name value mappings: + The name is a string that identifies a symbol, and the value is an address in memory where the symbol of that name has been positioned. + In most NuttX architectures symbol tables are required, as a minimum, in order to dynamically link the loaded binary object with the base code on FLASH. + Since the binary object was separately built and separately linked, these symbols will appear as undefined symbols in the binary object. + The binary loader will use the symbol table to look up the symbol by its name and to provide the address associated with the symbol as needed to perform the dynamic linking of the binary object to the base FLASH code. +

    + +

    3.1 Symbol Table Header Files

    +

    + The interface to the symbol table logic is described in the header file + + include/nuttx/binfmt/symtab.h. + A brief summary of the data structurs and interfaces prototyped in that header file are listed below. +

    + +

    3.2 Symbol Table Data Structures

    +

    + 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. +
    3. + Fixed size arrays. + There is no explicit provisional for dyanamically 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. +
    4. +
    + +

    3.3 Symbol Table Function Interfaces

    + + + +

    3.3.1 symtab_findbyname()

    +

    Function Prototype:

    + +

    Description:

    + +

    Returned Value:

    + + +

    3.3.2 symtab_findorderedbyname()

    +

    Function Prototype:

    + +

    Description:

    + +

    Returned Value:

    + + +

    3.3.3 symtab_findbyvalue()

    +

    Function Prototype:

    + +

    Description:

    + +

    Returned Value:

    + + +

    3.3.4 symtab_findorderedbyvalue()

    +

    Function Prototype:

    + +

    Description:

    + +

    Returned Value:

    + + + + + + +
    +

    4.0 Configuration Variables

    +
    + + + +

    + Additional configuration options may be required for the each enabled binary format. +

    + + diff --git a/nuttx/Documentation/NuttXDocumentation.html b/nuttx/Documentation/NuttXDocumentation.html index b26c831753..b502adc687 100644 --- a/nuttx/Documentation/NuttXDocumentation.html +++ b/nuttx/Documentation/NuttXDocumentation.html @@ -32,6 +32,7 @@
  • User Guide
  • Porting Guide
  • NuttShell (NSH)
  • +
  • Binary Loader
  • NXFLAT
  • NX Graphics
  • NxWidgets
  • diff --git a/nuttx/Documentation/NuttxPortingGuide.html b/nuttx/Documentation/NuttxPortingGuide.html index dd9d66881f..a2c58b41f8 100644 --- a/nuttx/Documentation/NuttxPortingGuide.html +++ b/nuttx/Documentation/NuttxPortingGuide.html @@ -12,7 +12,7 @@

    NuttX RTOS Porting Guide

    -

    Last Updated: October 29, 2012

    +

    Last Updated: October 30, 2012

    @@ -4580,6 +4580,14 @@ build So for the architectures that define CONFIG_ARCH_MATH_H=y, include/math.h will be the redirecting math.h header file; for the architectures that don't select CONFIG_ARCH_MATH_H, the redirecting math.h header file will stay out-of-the-way in include/nuttx/.

    +
  • CONFIG_ARCH_FLOAT_H. +

    + If you enable the generic, built-in math library, then that math library will expect your toolchain to provide the standard float.h header file. + The float.h header file defines the properties of your floating point implementation. + It would always be best to use your toolchain's float.h header file but if none is avaiable, a default float.h header file will provided if this option is selected. + However, there is no assurance that the settings in this float.h are actually correct for your platform! +

    +
  • CONFIG_ARCH_STDARG_H.

    There is also a redirecting version of stdarg.h in the source tree as well. diff --git a/nuttx/Documentation/NuttxUserGuide.html b/nuttx/Documentation/NuttxUserGuide.html index 457347727c..24dc6b6ab7 100644 --- a/nuttx/Documentation/NuttxUserGuide.html +++ b/nuttx/Documentation/NuttxUserGuide.html @@ -186,8 +186,10 @@ paragraphs.

    Executing Programs within a File System. NuttX also provides internal interfaces for the execution of separately built programs that reside in a file system. - These internal interfaces are, however, non-standard and are documented - elsewhere. + These internal interfaces are, however, non-standard and are documented with the + NuttX binary loader and + NXFLAT. +

    Task Control Interfaces. The following task control interfaces are provided by NuttX:

    diff --git a/nuttx/README.txt b/nuttx/README.txt index 4c008e6f16..d567d88c8c 100644 --- a/nuttx/README.txt +++ b/nuttx/README.txt @@ -154,9 +154,15 @@ Notes about Header Files Even though you should not use a foreign C-Library, you may still need to use other, external libraries with NuttX. In particular, you may - need to use the math library, libm.a. The math libary header file, - math.h, is a special case. If you do nothing, the standard math.h - header file that is provided with your toolchain will be used. + need to use the math library, libm.a. NuttX supports a generic, built-in + math library that can be enabled using CONFIG_LIBM=y. However, you may + still want to use a higher performance external math library that has + been tuned for your CPU. Sometimes such such tuned math libraries are + bundled with your toolchain. + + The math libary header file, math.h, is a then special case. If you do + nothing, the standard math.h header file that is provided with your + toolchain will be used. If you have a custom, architecture specific math.h header file, then that header file should be placed at arch//include/math.h. There @@ -171,6 +177,16 @@ Notes about Header Files than to include that archicture-specific math.h header file as the system math.h header file. + float.h + + If you enable the generic, built-in math library, then that math library + will expect your toolchain to provide the standard float.h header file. + The float.h header file defines the properties of your floating point + implementation. It would always be best to use your toolchain's float.h + header file but if none is avaiable, a default float.h header file will + provided if this option is selected. However, there is no assurance that + the settings in this float.h are actually correct for your platform! + stdarg.h In most cases, the correct version of stdarg.h is the version provided with your toolchain. However, sometimes there are issues with with using your toolchains stdarg.h. For example, it may attempt to draw in header files that do not exist in NuttX or perhaps the header files that is uses are not compatible with the NuttX header files. In those cases, you can use an architecture-specific stdarg.h header file by defining CONFIG_ARCH_STDARG_H=y. diff --git a/nuttx/binfmt/libelf/gnu-elf.ld b/nuttx/binfmt/libelf/gnu-elf.ld index bdf82836b3..b2a3dc1131 100644 --- a/nuttx/binfmt/libelf/gnu-elf.ld +++ b/nuttx/binfmt/libelf/gnu-elf.ld @@ -1,5 +1,5 @@ /**************************************************************************** - * examples/elf/gnu-elf.ld + * binfmt/libelf/gnu-elf.ld * * Copyright (C) 2012 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -51,8 +51,8 @@ SECTIONS */ *(.gnu.linkonce.t.*) - *(.init) - *(.fini) + *(.init) /* Old ABI */ + *(.fini) /* Old ABI */ _etext = . ; } @@ -86,15 +86,17 @@ SECTIONS .ctors : { - _sctros = . ; - *(.ctors) + _sctors = . ; + *(.ctors) /* Old ABI: Unallocated */ + *(.init_array) /* New ABI: Allocated */ _edtors = . ; } - .ctors : + .dtors : { _sdtors = . ; - *(.dtors) + *(.dtors) /* Old ABI: Unallocated */ + *(.fini_array) /* New ABI: Allocated */ _edtors = . ; } diff --git a/nuttx/configs/README.txt b/nuttx/configs/README.txt index 0849837c1f..cca4d7f324 100644 --- a/nuttx/configs/README.txt +++ b/nuttx/configs/README.txt @@ -723,6 +723,15 @@ defconfig -- This is a configuration file similar to the Linux don't select CONFIG_ARCH_MATH_H, the redirecting math.h header file will stay out-of-the-way in include/nuttx/. + CONFIG_ARCH_FLOAT_H + If you enable the generic, built-in math library, then that math library + will expect your toolchain to provide the standard float.h header file. + The float.h header file defines the properties of your floating point + implementation. It would always be best to use your toolchain's float.h + header file but if none is avaiable, a default float.h header file will + provided if this option is selected. However, there is no assurance that + the settings in this float.h are actually correct for your platform! + CONFIG_ARCH_STDARG_H - There is also a redirecting version of stdarg.h in the source tree as well. It also resides out-of-the-way at include/nuttx/stdarg.h. This is because you should normally use your toolchain's stdarg.h file. But diff --git a/nuttx/include/nuttx/binfmt/symtab.h b/nuttx/include/nuttx/binfmt/symtab.h index 497327031d..346c6099fd 100644 --- a/nuttx/include/nuttx/binfmt/symtab.h +++ b/nuttx/include/nuttx/binfmt/symtab.h @@ -54,7 +54,7 @@ * is a fixed size array of struct symtab_s. The information is intentionally * minimal and supports only: * - * 1. Function points as sym_values. Of other kinds of values need to be + * 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. *