Complete the process of running the program, before the main function call in the end which actions?

        Many people know from the main function of the program is started, but before the main implementation of what was not enough to understand, this paper describes the call ARMCC Keil and ARM-NONE-EABI-GCC compiler generates two operations before the main :

Keil MDK startup file

MDK summarize the boot process: 
1. System initialization, including the interrupt vector table remapping 
2. RW loading segment (.data section initialization) 
3. Load ZI section (.bss section initialization) 
4. Initialize the user stack 
5. Initialize Microlib 
6. call the main function 
        microlib default C library is an alternative library. It is designed with the needs to be loaded into the deeply embedded applications with a very small amount of memory in use. These applications do not run in the operating system. 
        microlib highly optimized so that the code becomes small. It has less functionality than the default C library, and does not have some ISO C features. Some library functions running speed is relatively slow, for example, memcpy (). 
       The figure is from Keil calling ARMCC loaded into the running change view: 
Write pictures described here

        FIG slightly explain this, the switching from the load when performing load view view, the code stored in ROM is not changed, the pointer to the initial address pc program instructions can be sequentially executed, it has been initialized global variable data segment uninitialized global variables bss section needs to be loaded from the flash memory to the specified address.

For RO and RW section 
        Loadregion_nameBase region_name represents the load address area 
       "Imageregion_nameBase" indicates execution address region_name area 
       "Imageregion_nameLength" indicates the length region_name area (unit: bytes) 
of ZI section 
       "Imageregion_nameZIBase" indicates execution address region_name area 
       "Imageregion_nameZILength" region_name area represents the length (unit: bytes)

 ARM-NONE-EABI-GCC start the process of crt0

        Use arm-none-eabi-gcc compiler generates ELF files, the ELF files objdump disassembler can find out before the main initialization function _mainCRTStartup.
        The following figure shows a substantially lower flow _mainCRTStartup ARM7V-M platform:

Write pictures described here

The following paragraphs look at the distribution of the ELF file: 
Write pictures described here 
the actual address with .data segment, but the address of the .data section of the RAM directly after .text seen from the above chart.

 summary:

        arm-none-eabi-gcc armcc not there will be flash, so there is no load the global variable to a value stored in the global variable as a function of scatter_load from flash ram, the arm-none-eabi-gcc only by the loader .data segment loaded directly into the ram.

Published 36 original articles · won praise 4 · Views 2794

Guess you like

Origin blog.csdn.net/qq845699/article/details/104163193