Native Client ABI for application startup

At application startup, the ELF entry point address (e_entry) is used as the entry point for a C function of one argument.
This function is not expected to return.  The argument is a pointer to uint32_t representing an array of values, as follows:
  • fini, a pointer to a finalizer function
    • This is a function of no arguments that returns no value (i.e. void (*)(void)).
    • On initial entry to untrusted code this is always NULL.
    • When a dynamic linker is in use, initial entry goes first to the dynamic linker, which sets up shared libraries and then jumps to the application's entry point.  In this case, the finalizer will be a function provided by the dynamic linker to run shared library finalizer functions.
    • If the pointer is not NULL, the application startup code is expected to call atexit with it as the parameter.
  • envc, the count of environment string pointers (envp[]), not the including NULL terminator
  • argc, the count of argument string pointers (argv[]), not the including NULL terminator
  • argv[], a sequence of argc string pointers (char *), followed by a NULL pointer (at argv[argc])
    • Each of these is an argument to the application as a C string (terminated by a zero byte), the first traditionally being the name of the application file.  i.e., the normal C convention for the argc and argv parameters to main.
  • envp[], a sequence of envc string pointers (char *), followed by a NULL pointer (at envp[envc])
    • Each of these is an environment string in the form "variable=value" as a C string (terminated by a zero byte).  i.e., the normal C convention for the envp parameter to main (normally stored in the environ global variable by the startup code).
  • auxv[], a sequence of pairs of integer values, terminated by a pair whose values are both zero
    • The first integer of each pair is a type code, one of several values denoted by AT_NAME macros.
    • The second integer of each pair is a value whose meaning is indicated by the type code.
    • The full set of expected type codes remains to be specified.
    • The type code AT_SYSINFO (32) denotes a value that is a function pointer provided for interface query (see below).

Interface Query

The interface query function provided via AT_SYSINFO is the sole means of access to facilities provided by the operating environment.
This includes facilities such as dynamic memory allocation, input/output access, process termination, etc.  In browser-based environments, it includes Web-oriented facilities.

The interface query function has the C type:

    size_t (*interface_query)(const char *interface_ident, void *table, size_t tablesize)

The interface_ident argument is a C string identifying a particular interface of interest.
The table and tablesize arguments give a block of memory that will be filled with contents depending on the particular interface.
The return value is the number of bytes at table actually filled in, which will be zero if interface_ident is unrecognized or tablesize is too short.  (It is always valid to supply a larger tablesize than is required.)
The contents of each such table are specified elsewhere; each unique interface_ident string denotes a particular such specification.  Usually it is a table of function pointers.
Comments