Keil Logo

Technical Support

On-Line Manuals

Linker User Guide

Preface Overview of the Linker Linking Models Supported by armlink Image Structure and Generation Linker Optimization Features Getting Image Details Accessing and Managing Symbols with armlink Scatter-loading Features The scatter-loading mechanism Overview of scatter-loading When to use scatter-loading Linker-defined symbols that are not defined when s Specifying stack and heap using the scatter file Scatter-loading command-line options Scatter-loading images with a simple memory map Scatter-loading images with a complex memory map Scatter file with link to bit-band objects Root execution regions Root execution region and the initial entry point Root execution regions and the ABSOLUTE attribute Root execution regions and the FIXED attribute Methods of placing functions and data at specific Placement of code and data with __attribute__((sec Placement of __at sections at a specific address Restrictions on placing __at sections Automatic placement of __at sections Manual placement of __at sections Placement of a key in flash memory with an __at se Mapping a structure over a peripheral register wit Example of how to explicitly place a named section Placement of unassigned sections with the .ANY mod Placement rules when using multiple .ANY selectors Command-line options for controlling the placement Prioritization of .ANY sections Specify the maximum region size permitted for plac Examples of using placement algorithms for .ANY se Example of next_fit algorithm showing behavior of Examples of using sorting algorithms for .ANY sect Behavior when .ANY sections overflow because of li Placement of veneer input sections in a scatter fi Placement of sections with overlays Reserving an empty region Placement of ARM C and C++ library code Specifying ARM standard C and C++ libraries in a s Example of placing code in a root region Example of placing ARM C library code Example of placing ARM C++ library code Example of placing ARM library helper functions Creation of regions on page boundaries Overalignment of execution regions and input secti Preprocessing of a scatter file Example of using expression evaluation in a scatte Equivalent scatter-loading descriptions for simple Command-line options for creating simple images Type 1 image, one load region and contiguous execu Type 2 image, one load region and non-contiguous e Type 3 image, multiple load regions and non-contig How the linker resolves multiple matches when proc How the linker resolves path names when processing Scatter file to ELF mapping Scatter File Syntax Linker Command-line Options Linker Steering File Command Reference Via File Syntax

Preprocessing of a scatter file

7.11 Preprocessing of a scatter file

You can pass a scatter file through a C preprocessor. This permits access to all the features of the C preprocessor.

Use the first line in the scatter file to specify a preprocessor command that the linker invokes to process the file. The command is of the form:
#! preprocessor [pre_processor_flags]
Most typically the command is #! armcc -E. This passes the scatter file through the armcc preprocessor.
You can:
  • Add preprocessing directives to the top of the scatter file.
  • Use simple expression evaluation in the scatter file.
For example, a scatter file, file.scat, might contain:
#! armcc -E

#define ADDRESS 0x20000000
#include "include_file_1.h"

The linker parses the preprocessed scatter file and treats the directives as comments.
You can also use preprocessing of a scatter file in conjunction with the --predefine command-line option. For this example:
  1. Modify file.scat to delete the directive #define ADDRESS 0x20000000.
  2. Specify the command:
    armlink --predefine="-DADDRESS=0x20000000" --scatter=file.scat

Default behavior for armcc -E

armlink behaves in the same way as armcc when invoking other ARM tools. It searches for the armcc binary in the following order:
  • The same location as armlink.
  • The PATH locations.
armcc is invoked with the option -Iscatter_file_path so that any relative #includes work. The linker only adds this option if the full name of the preprocessor tool given is armcc or armcc.exe. This means that if an absolute path or a relative path is given, the linker does not give the -Iscatter_file_path option to the preprocessor. This also happens with the --cpu option.
On Windows, .exe suffixes are handled, so armcc.exe is considered the same as armcc. Executable names are case insensitive, so ARMCC is considered the same as armcc. The portable way to write scatter file preprocessing lines is to use correct capitalization, and omit the .exe suffix.

Using other preprocessors

You must ensure that the preprocessing command line is appropriate for execution on the host system. This means:
  • The string must be correctly quoted for the host system. The portable way to do this is to use double-quotes.
  • Single quotes and escaped characters are not supported and might not function correctly.
  • The use of a double-quote character in a path name is not supported and might not work.
These rules also apply to any strings passed with the --predefine option.
All preprocessor executables must accept the -o file option to mean output to file and accept the input as a filename argument on the command line. These options are automatically added to the user command line by armlink. Any options to redirect preprocessing output in the user-specified command line are not supported.
Non-ConfidentialPDF file icon PDF versionARM DUI0377H
Copyright © 2007, 2008, 2011, 2012, 2014-2016 ARM. All rights reserved. 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.