The modified OS loader makes it possible to save memory occupied by the section with the initialization data and remap read-only data back to read-only segment.
Loader Support API
The compiler provides a special library routine that can be used to initialize big-endian data in any OS loader. This routine implements an internal mechanism to perform big-endian data initialization. The task of the modified OS loader is to make a proper call to that routine.
To save memory occupied by the data initialization section, the loader should either remove the entire data initialization section from the loadable segment or remove all items except an end marker from the section. In the former case, it is additionally required to set the __initdata_begin
symbol to zero.
The routine for initializing big-endian data is defined as follows:
Name:
biendian_datainit - initialize big-endian data
Syntax:
#include <loader/bedatainit.h> int biendian_datainit(void *initdata);
Description:
The biendian_datainit
API (routine) performs initialization of big-endian data for applications or shared libraries. You must load and relocate the application or shared library image in a writable memory segment prior to the big-endian data initialization. Apply any write protection on the application image only after performing data initialization.
The initdata
argument is a pointer to the preloaded and relocated contents of the initdata
executable and linking format (ELF) section for the application or shared library that is being initialized.
Return value:
Upon successful completion, 0 is returned. On error, biendian_datainit
returns a non-zero error code.
Errors:
A complete list of errors has not yet been defined.
Prototype:
The initialization routine prototype is declared in:
<install-dir>/include/loader/bedatainit.h
Static library:
The static library libbedatainit.a
containing this routine is located at:
<install-dir>/lib/libbedatainit.a