Keil Logo

Instruction and directive relocations

4.24 Instruction and directive relocations

The assembler can embed relocation directives in object files to indicate labels with addresses that are unknown at assembly time. The assembler can relocate several types of instruction.

A relocation is a directive embedded in the object file that enables source code to refer to a label whose target address is unknown or cannot be calculated at assembly time. The assembler emits a relocation in the object file, and the linker resolves this to the address where the target is placed.
The assembler relocates the data directives DCB, DCW, DCWU, DCD, and DCDU if their syntax contains an external symbol, that is a symbol declared using IMPORT or EXTERN. This causes the bottom 8, 16, or 32 bits of the address to be used at link-time.
The REQUIRE directive emits a relocation to signal to the linker that the target label must be present if the current section is present.
The assembler is permitted to emit a relocation for these instructions:
LDR (PC-relative)
All Thumb instructions, except the Thumb doubleword instruction, can be relocated.
All Thumb instructions can be relocated.
B, BL, and BLX
All Thumb instructions can be relocated.
All Thumb instructions can be relocated but this is discouraged because of the limited branch range of these instructions.
The assembler emits a relocation for these instructions if the label used meets any of the following requirements, as appropriate for the instruction type:
  • The label is WEAK.
  • The label is not in the same AREA.
  • The label is external to the object (IMPORT or EXTERN).
For B, BL, and BX instructions, the assembler emits a relocation also if:
  • The label is a function.
  • The label is exported using EXPORT or GLOBAL.


You can use the RELOC directive to control the relocation at a finer level, but this requires knowledge of the ABI.


    IMPORT sym   ; sym is an external symbol
    DCW sym      ; Because DCW only outputs 16 bits, only the lower
                 ; 16 bits of the address of sym are inserted at 
                 ; link-time.
Related information
Non-ConfidentialPDF file icon PDF versionARM DUI0379H
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.