In this Blog Entry I will be presenting a "birds-eye" view of the build process. An overview of the build process is provided in Figure 1.
The .c C source files (in conjunction with their corresponding .h header files) are converted to .o object files by the GNU GCC (C) compiler. The .asm assembly source files are also converted to .o object files by the GNU AS assembler. These object files are like pieces of the final binary file output that contain the binary equivalent of the source files from which they were derived but lack "location" information. In otherwords they do not know where in memory they should go or which object file goes into which location.
Determining the memory location of the various sections of each object file is the job of the GNU (LD) linker. The GNU linker determines where to put each section of each object file based on instructions coded in the "linker file" "*.ld" Once the linker has assigned the necessary location information to each section of each object file in combines all the location aware object files into a binary output file with extensions such as .bin, .hex, .elf or .axf. While this process targets specifically the GNU tools, this is in general how all toolchains; GNU based or otherwise operate.
In each object file there will be different sections. The main sections are:
- .isr_vector - This section defines the section of memory containing the interrupt vector table. Sometimes its put as a subsection under the .text section (program memory section)
- .text - This section stores all the instructions that make the program typically ends up in the program Flash memory.
- .rodata - All constant data variables make up this section. It is typically stored in the Flash. Again, sometimes its put as a subsection under the .text section (program memory section)
- .data - This section is composed of all global and static variables. These are typically stored in Flash and then copied into RAM during the initialization code which runs right after the MCU exits from a reset condition.
- .bss - This section consists of uninitialized static and global variables and is stored directly into RAM. the Value of these variables is set to '0' in the MCU initilization code.
These sections are typically specified in the linker file or script. I will be showing you an example script file in my next blog entry.