3.3.3. Setting linker options from the command line

The ARM linker, armlink, enables you to:

Objects consist of input sections that contain code, initialized data, or the locations of memory that must be set to zero. Input sections can be Read-Only (RO), Read/Write (RW), or Zero-Initialized (ZI). These attributes are used by armlink to group input sections into bigger building blocks called output sections, regions and images. Output sections are approximately equivalent to ELF segments.

The default output from the linker is a non-relocatable image where the code starts at 0x8000 and the data section is placed immediately after the code. You can specify exactly where the code and data sections are located by using linker options or a scatter-load description file.

Linker input and output

Input to armlink consists of:

  • one or more object files in ELF Object Format

  • optionally, one or more libraries created by armar.

Output from a successful invocation of armlink is one of the following:

  • an executable image in ELF executable format

  • a partially linked object in ELF object format.

For simple images, ELF executable files contain segments that are approximately equivalent to RO and RW output sections in the image. An ELF executable file also has ELF sections that contain the image output sections.

An executable image in ELF executable format can be converted to other file formats by using the fromELF utility.

Linker syntax

The linker command syntax is of the form:

armlink [-help_options] [-output_options] [-via_options] [-memory_map_options] [-image_content_options] [[-image_info_options]] [-diagnostic_options]

See the ADS Linker and Utilities Guide for a detailed list of the linker options.

Using linker options to position sections

The following linker options control how sections are arranged in the final image and whether the code and data can be moved to a new location after the application starts:

-ropi

This option makes the load and execution region containing the RO output section position-independent. If this option is not used the region is marked as absolute.

-ro-base address

This option sets the execution addresses of the region containing the RO output section at address. The default address is 0x8000.

-rw-base address

This option sets the execution addresses of the region containing the RW output section at address. The default address is at the end of the RW section.

-rwpi

This option makes the load and execution region containing the RW and ZI output section position-independent. If this option is not used the region is marked as absolute. The -rwpi option is ignored if -rw-base is not also used. Usually each writable input section must be read-write position-independent.

If you want more control over how the sections are placed in an image, use the -scatter option and specify a scatter-load description file.

Using scatter-load description files for a simple image

The command-line options (-ro-base, -rw-base, -ropi, and -rwpi) create simple images.

You can create the more complex images by using the -scatter command-line option to specify a scatter-load description file. The -scatter option is mutually exclusive with the use of any of the simple memory map options -ro-base, -rw-base, -ropi, or -rwpi.

For more information on the linker and scatter-load description files, see the ADS Linker and Utilities Guide and the Writing Code for ROM chapter in the ADS Developer Guide.

Copyright © 1999-2001 ARM Limited. All rights reserved.ARM DUI 0064D
Non-Confidential