You copied the Doc URL to your clipboard.

Linker options for mapping code and data to target memory

For an image to run correctly on a target, you must place the various parts of the image at the correct locations in memory. Linker command-line options are available to map the various parts of an image to target memory.

The options implement the scatter-loading mechanism that describes the memory layout for the image. The options that you use depend on the complexity of your image:

  • For simple images, use the following memory map related options:
    • --ro_base to specify the address of both the load and execution region containing the RO output section.
    • --rw_base to specify the address of the execution region containing the RW output section.
    • --zi_base to specify the address of the execution region containing the ZI output section.


    For objects that include execute-only (XO) sections, the linker provides the --xo_base option to locate the XO sections. These sections are objects that are targeted at Arm®v7‑M or Armv8‑M architectures, or objects that are built with the armclang -mthumb option,
  • For complex images, use a text format scatter-loading description file. This file is known as a scatter file, and you specify it with the --scatter option.


You cannot use the memory map related options with the --scatter option.


The following example shows how to place code and data using the memory map related options:

armlink --ro_base=0x0 --rw_base=0x400000 --zi_base=0x405000 --first="init.o(init)" init.o main.o


In this example, --first is also included to make sure that the initialization routine is executed first.

The following example shows a scatter file, scatter.scat, that defines an equivalent memory map:

LR1 0x0000 0x20000
    ER_RO 0x0
        init.o (INIT, +FIRST)

    ER_RW 0x400000

    ER_ZI 0x405000

To link with this scatter file, use the following command:

armlink --scatter=scatter.scat init.o main.o