Porting from GCC to SEGGER Linker

From SEGGER - Support Wiki
Jump to: navigation, search

The SEGGER Linker can easily be used in an existing project to replace the GNU Linker.

Porting an existing Embedded Studio Project

In a standard Embedded Studio project the target's memory layout is defined in *_MemoryMap.xml. The memory map file can be reused with the SEGGER Linker so that in most cases the sample linker script SEGGER_Flash.icf can be used without modification.

The section placement file *_placement.xml is not used by the SEGGER Linker. Instead you use the SEGGER linker script (*.icf). It is way more simple to write a SEGGER linker script than a GNU linker script.

For a default project with one FLASH and one RAM region, these steps need to be done:

  1. Copy the SEGGER Linker Script template file from $(StudioDir)/samples/SEGGER_Flash.icf into your project directory.
  2. Copy the matching startup file from $(StudioDir)/samples/SEGGER_THUMB_Startup.s into your project directory.
  3. Set the project option "Linker" to "SEGGER".
  4. Set the project option "Linker Script File" to the linker script in your project directory.
  5. Remove thumb_crt0.s from your project.
  6. Add SEGGER_THUMB_Startup.s to your project.

If your memory layout contains multiple FLASH or RAM regions, you can tell the SEGGER Linker to automatically place into multiple regions:

 place in RAM1 then RAM2 { ... };

If you added additional sections to your *_placement.xml, you can also do this in the SEGGER Linker script:

 place in RAM { ..., .myregion };

The SEGGER Linker offers even more functionality to provide you with extensive placement options to best utilize your target's memory. Refer to the SEGGER Linker User Guide (included in Embedded Studio).