The C/C++ compiler produces data tables for initializing global variables. Section 7.10.3.1 discusses the format of these initialization tables. The initialization tables are used in one of the following ways:
- Global variables are initialized at run time. Use the --rom_model linker option (see Section 7.10.3.2).
- Global variables are initialized at load time. Use the --ram_model linker option (see Section 7.10.3.3).
If you use the linker command line without compiling any C/C++ files, you must use either the --rom_model or --ram_model option. These options tell the linker two things. First, they indicate that the linker should follow C/C++ conventions, using the definition of main() to link in the c_int00 boot routines. Second, they tell the linker whether to select initialization at run time or load time. If your command line fails to include one of these options when it is required, you will see "warning: no suitable entry-point found; setting to 0".
If you use a single command line to both compile and link, the --rom_model option is the default. If used, the --rom_model or --ram_model option must follow the --run_linker option (see Section 4.1).
For details on linking conventions for EABI with --rom_model and --ram_model, see Section 7.10.4.3 and Section 7.10.4.5, respectively.
For details on linking conventions for COFF with --rom_model and --ram_model, see Section 7.10.3.2 and Section 7.10.3.3, respectively. The following list outlines the linking conventions used for the COFF ABI with --rom_model or --ram_model:
- The symbol _c_int00 is defined as the program entry point; it identifies the beginning of the C/C++ boot routine in boot.c.obj. When you use --rom_model or --ram_model, _c_int00 is automatically referenced, ensuring that boot.c.obj is automatically linked in from the run-time-support library.
- The initialization output section is padded with a termination record so that the loader (load-time initialization) or the boot routine (run-time initialization) knows when to stop reading the initialization tables.
- When initializing at load time (the --ram_model option), the following occur:
- The linker sets the initialization table symbol to -1. This indicates that the initialization tables are not in memory, so no initialization is performed at run time.
- The STYP_COPY flag is set in the initialization table section header. STYP_COPY is the special attribute that tells the loader to perform autoinitialization directly and not to load the initialization table into memory. The linker does not allocate space in memory for the initialization table.
- When autoinitializing at run time (--rom_model option), the linker defines the initialization table symbol as the starting address of the initialization table. The boot routine uses this symbol as the starting point for autoinitialization.