The compiler converts C statements into assembler and performs optimisation of the assembly instructions. The C compiler then implicitly calls the assembler to assemble that file (usually a temporary) into an object file.This will have relocatable machine code in it along with symbol information for the linker to use.
It generally sets up a stack pointer, and it always includes a call to _main.Here’s an important note: symbols present in C code get prepended with an underscore in the generation of the assembler version of the code.So where the start of a C program is the main symbol, in assembler we need to refer to it as it’s assembler version which is _main.All of the source in the tutorials is available from the Github repo.These days the C compiler pipes the assembly to the assembler so there is no intermediate file as creating files is a lot slower than passing data from one program to another through a pipe.
The linker’s job is to link everything into an executable file. The linker script tells the linker how to organise the various object files.
The settings are gleaned from the GCC ARM options page.
In order to use a C compiler, we need to understand what the compiler does and what the linker does in order to generate executable code.
So go clone or fork now so you have all the code to compile and modify as you work through the tutorials.
Let’s have a look at compiling one of the simplest programs that we can.
If you want to learn a bit of assembler too, then definitely head off to there!