You copied the Doc URL to your clipboard.

What the linker does to create an image

The linker takes object files that a compiler or assembler produces and combines them into an executable image. The linker also uses a memory description to assign the input code and data from the object files to the required addresses in the image.

You can specify object files directly on the command line or specify a user library containing object files. The linker:

  • Resolves symbolic references between the input object files.
  • Extracts object modules from libraries to resolve otherwise unresolved symbolic references.
  • Removes unused sections.
  • Eliminates duplicate common groups and common code, data, and debug sections.
  • Sorts input sections according to their attributes and names, and merges sections with similar attributes and names into contiguous chunks.
  • Organizes object fragments into memory regions according to the grouping and placement information that is provided in a memory description.
  • Assigns addresses to relocatable values.
  • Generates either a partial object if requested, for input to another link step, or an executable image.

The linker has a built-in memory description that it uses by default. However, you can override this default memory description with command-line options or with a scatter file. The method that you use depends how much you want to control the placement of the various output sections in the image:

  • Allow the linker to automatically place the output sections using the default memory map for the specified linking model. armlink uses default locations for the RO, RW, execute-only (XO), and ZI output sections.
  • Use the memory map related command-line options to specify the locations of the RO, RW, XO, and ZI output sections.
  • Use a scatter file if you want to have the most control over where the linker places various parts of your image. For example, you can place individual functions at specific addresses or certain data structures at peripheral addresses.


XO sections are supported only for images that are targeted at Armv7‑M or Armv8‑M architectures.

This section contains the following subsection: