3.3 From source to running code
What the compiler, assembler and linker each do, cross toolchains, build systems, linker scripts, reading ELF and map files, and everything that happens…
Lessons
- The compilation pipeline · Preprocessor, compiler, assembler and linker, and what each one produces.
- Toolchains and cross-compilation · Target triplets, sysroots, float ABI and the flags that must agree.
- Make and CMake for embedded · Rules, dependencies, toolchain files and a sane firmware build.
- Linker scripts · MEMORY, SECTIONS, the location counter, KEEP and ALIGN.
- ELF, map files and binary inspection · Reading what the linker built with size, nm, objdump and the map file.
- Memory layout and startup code · From reset to main: copying .data, zeroing .bss and the C runtime.
- Boot, vector table and clock bring-up · Reset sources, the vector table and bringing up the clock tree.
Project: Smart electricity meter firmware image
Everything between your source code and a running meter: whether the image fits the chip, what fills the flash, the startup code that prepares RAM before main, and the clock setup the chip needs first.