Recent

This Page

User

Using your own linker scripts

The GNU tools use linker scripts to define how the linker creates an executable image from your sources. This article examines how the Code Red tools suite uses linker scripts.

The Code Red tools suite by default use a "managed linker script" mechanism to create a script for each Build configuration that is suitable for the MCU selected for the project, and the C libraries being used.

It will create (and at times modify) three linker script files for each build configuration of your project:

This set of hierarchical files are used to define the C libraries being used, the memory map of the system and the way your code and data is placed in memory. These files will be located in the build configuration subdirectories of your project (Debug and Release).

Bypassing the managed linker script mechanism

Note - Red Suite 3.6 / LPCXpresso 3.6 (Windows) and LPCXpresso 3.8 (Linux) introduced a number of major enhancements to the managed linker script mechanism. These enhancements remove many of the reasons for needing to bypass the managed linker script mechanism. For more details, please see the FAQ Enhanced Managed Linker Scripts.

In some circumstances, you might want to bypass the managed linker script mechanism and create your own bespoke linker scripts. In such cases you can either create your own linker script from scratch, or you can use the managed linker scripts as a starting point.

One very important point though is that you are advised not to simply modify the managed linker scripts in place, but instead to copy them to another location and modify them there. This will prevent any chance of the tools accidentally overwritting them if at some point in the future you turn the managed make script mechanism back on.

To turn off the managed linker script mechanism, carry out the following steps:

Open the Project properties. There are a number of ways of doing this. For example, make sure the Project is highlighted in the Project Explorer view then open the menu "Project -> Properties".

In the left-hand list of the Properties window, open "C/C++ Build" and select "Settings" and then the "Tool Settings" tab.

Now enter the name of the your linker script into the Libnker script field. This will need to include relative path information, so that the linker can find the script (relative to the current build configuration directory (i.e. Debug or Release). For example if your linker script is called myscript.ld and is located in the linkscripts subdirectory of your project, then you need to add "../linkscripts/myscript.ld" to the linker script field (the quote marks ARE required).

Note that if your linker script includes additional files (as the managed linker scripts do), then you will also need to include the relative path information in the include.