A Dummy’s Guide to Linker Scripts
Posted: • ∞
Normally, writing C code is pretty straightforward. There are a few steps that are just repeated over and over:
- Write code.
- Compile code.
- Link code.
- A binary is created.
Most people overlook the black magic that happens in step 3, and some may not even realize it’s a step. This is because the linker is usually configured to hide all of the difficult decisions that it makes. Unfortunately, when we move away from the desktop environment into the embedded world, the linker no longer knows how to make the difficult decisions, and we need to tell it what to do. This is where linker scripts come in. But first, we need to discuss what exactly the linker needs to know in the first place.