Second Stage Initialization Files - 2021.2 English

Vitis Unified Software Platform Documentation: Embedded Software Development (UG1400)

Document ID
UG1400
ft:locale
English (United States)
Release Date
2021-12-15
Version
2021.2 English

According to the C standard specification, all global and static variables must be initialized to 0. This is a common functionality required by all the CRTs above. Another routine, _crtinit, is invoked. The _crtinit routine initializes memory in the .bss section of the program. The _crtinit routine is also the wrapper that invokes the main procedure. Before invoking the main procedure, it might invoke other initialization functions. The _crtinit routine is supplied by the startup files described below.

crtinit.o

This default, second stage, C startup file performs the following steps:

  1. Clears the .bss section to zero.
  2. Invokes _program_init.
  3. Invokes “constructor” functions (_init).
  4. Sets up the arguments for main and invokes main.
  5. Invokes “destructor” functions (_fini).
  6. Invokes _program_clean and returns.
pgcrtinit.o

This second stage startup file is used during profiling, and performs the following steps:

  1. Clears the .bss section to zero.
  2. Invokes _program_init.
  3. Invokes _profile_init to initialize the profiling library.
  4. Invokes “constructor” functions (_init).
  5. Sets up the arguments for main and invokes main.
  6. Invokes “destructor” functions (_fini).
  7. Invokes _profile_clean to cleanup the profiling library.
  8. Invokes _program_clean, and then returns.
sim-crtinit.o

This second-stage startup file is used when the -mno-clearbss switch is used in the compiler, and performs the following steps:

  1. Invokes _program_init.
  2. Invokes “constructor” functions (_init).
  3. Sets up the arguments for main and invokes main.
  4. Invokes “destructor” functions (_fini).
  5. Invokes _program_clean, and then returns.
sim-pgcrtinit.o

This second stage startup file is used during profiling in conjunction with the -mno-clearbss switch, and performs the following steps in order:

  1. Invokes _program_init.
  2. Invokes _profile_init to initialize the profiling library.
  3. Invokes “constructor” functions (_init).
  4. Sets up the arguments for and invokes main.
  5. Invokes “destructor” functions (_fini).
  6. Invokes _profile_clean to cleanup the profiling library.
  7. Invokes _program_clean, and then returns.