**** Advance Notice ****

This site will be closed on 31 December 2015,

Important Information for users of NXP LPCXpresso

This site is for users of Code Red branded products.

NXP LPCXpresso users should visit the LPCXpresso FAQ's for up-to-date information relevant to that product.

Differences between revisions 5 and 6
Deletions are marked like this. Additions are marked like this.
Line 47: Line 47:
 * Newlib (None), add
        GROUP(libgcc.a libc.a)

 * Newlib (Nohost), add
        GROUP(libgcc.a libc.a libcr_newlib_nohost.a)

 * Newlib (Semihost), add
        GROUP(libgcc.a libc.a libcr_newlib_semihost.a)
Line 64: Line 55:

 * Newlib (None), add
        GROUP(libgcc.a libc.a libm.a)

 * Newlib (Nohost), add
        GROUP(libgcc.a libc.a libm.a libcr_newlib_nohost.a)

 * Newlib (Semihost), add
        GROUP(libgcc.a libc.a libm.a libcr_newlib_semihost.a)

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:

  1. 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".

  2. In the left-hand list of the Properties window, open "C/C++ Build" and select "Settings" and then the "Tool Settings" tab.
  3. Now choose "MCU Linker - Target" and untick the Manage linker script box.
  4. 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.

Creating linker scripts

The GNU linker documentation contains a great deal of information on linker scripts. Please see the copy of the documentation included with your tool suite, or view online at: http://sourceware.org/binutils/docs-2.20/ld/index.html

There is also a good introduction to linker scripts available in Building Bare-Metal ARM Systems with GNU: Part 3 at: http://www.embedded.com/design/201000339

Linker scripts and C libraries

If you are providing your own linker script, you will need to add one of the following entries before the SECTION line in your linker script:

  • Redlib (None), add
    • GROUP(libcr_c.a libcr_eabihelpers.a)
  • Redlib (Nohost), add
    • GROUP(libcr_nohost.a libcr_c.a libcr_eabihelpers.a)
  • Redlib (Semihost), add
    • GROUP(libcr_semihost.a libcr_c.a libcr_eabihelpers.a)
  • Newlib (None), add
    • GROUP(libgcc.a libc.a libm.a)
  • Newlib (Nohost), add
    • GROUP(libgcc.a libc.a libm.a libcr_newlib_nohost.a)
  • Newlib (Semihost), add
    • GROUP(libgcc.a libc.a libm.a libcr_newlib_semihost.a)

OwnLinkScripts (last edited 2010-12-21 10:23:14 by CrSupportAb)