Second Stage Initialization Files - 2025.2 English - UG1400

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

Document ID
UG1400
Release Date
2025-11-20
Version
2025.2 English

It is a requirement to initialize all global and static variables to 0 according to C standard specification.

  • Initialization all global and static variables is a common requirement of all CRTs above.
  • The separate routine _crtinit 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 can 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
The profiling process uses the second stage startup file. This file 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
When the compiler uses the -mno-clearbss switch, it uses this second-stage startup file. This file 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
During profiling with the -mno-clearbss switch, this second-stage startup file 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.