1.8.1 Initialization of the execution environment and execution of the application

You can customize execution initialization by defining your own __main that branches to __rt_entry.

The entry point of a program is at __main in the C library where library code:
  1. Copies non-root (RO and RW) execution regions from their load addresses to their execution addresses. Also, if any data sections are compressed, they are decompressed from the load address to the execution address.
  2. Zeroes ZI regions.
  3. Branches to __rt_entry.
If you do not want the library to perform these actions, you can define your own __main that branches to __rt_entry.
  IMPORT __rt_entry
  EXPORT __main
  ENTRY
__main
  B  __rt_entry
  END
The library function __rt_entry() runs the program as follows:
  1. Sets up the stack and the heap by one of a number of means that include calling __user_setup_stackheap(), calling __rt_stackheap_init(), or loading the absolute addresses of scatter-loaded regions.
  2. Calls __rt_lib_init() to initialize referenced library functions, initialize the locale and, if necessary, set up argc and argv for main().
    For C++, calls the constructors for any top-level objects by way of __cpp_initialize__aeabi_.
  3. Calls main(), the user-level root of the application.
    From main(), your program might call, among other things, library functions.
  4. Calls exit() with the value returned by main().
Related concepts
1.8.5 Library functions called from main()
1.8 Tailoring the C library to a new execution environment
1.8.2 C++ initialization, construction and destruction
Related reference
1.6.6 Direct semihosting C library function dependencies
4.23 __rt_entry
4.28 __rt_lib_init()
Non-ConfidentialPDF file icon PDF versionARM DUI0378G
Copyright © 2007, 2008, 2011, 2012, 2014, 2015 ARM. All rights reserved.