3.1. Position independence

Both the ARM® and Thumb® instruction sets support position-independent, or relocatable, code through the use of PC-relative instructions (for example BL).


This is not the same as Relocatable ELF (an image type created by the linker).

You can write assembler code that is relocatable but it must not contain any address constants. Any literal addresses used to refer to code must be PC-relative offsets. The PC is added, using an ADD instruction, before the address is accessed.

Both code and data can be position-independent:

RVCT supports position-independent code and data for C and assembler (but not C++), and enables you to write code that is relocatable or reentrant. The rest of this chapter contains information about how to do this.

For more information, see the following in RealView Compilation Tools v3.0 Compiler and Libraries Guide:

Copyright © 2002-2006 ARM Limited. All rights reserved.ARM DUI 0203G