clinkerembeddedtoolchainlinker-scripts

Which part of Embedded toolchain generates the linker script


Which part of the Embedded toolchain is responsible for generating the linker script? And if it is the linker, why would the linker generate a script for itself to define the memory segments? Aren't files like symbol table, map file,.. etc are generated by some tool to be used by some other tool that comes after it?


Solution

  • Linker script is not automatically generated file. It can be generated by the startup code generators like STM32CubeMX.

    Linker script defines how the memory is organized and it strongly depends on the hardware architecture and programmers needs.

    So basically linker script has to be written by the programmer. Some manufacturers provide ready-made ones for their hardware (for example MicroChip) or software which helps generate one for your hardware.

    Even having such generated by software or provided by the manufacturer is not enough as most more advanced projects require special memory layouts and the programmer has to modify them to suit his needs