5.8.43. IMPORT or EXTERN directive

The IMPORT directive provides the assembler with a name that is not defined in the current assembly. EXTERN is a synonym for IMPORT. See also EXPORT or GLOBAL directive.


The syntax of IMPORT is:

IMPORT symbol{[qualifier{,qualifier}]}



is a symbol name defined in a separately assembledsource file, object file, or library. The symbol name is case-sensitive.


can be:


specifies that symbol defines a function that expects floating-point arguments passed in floating-point registers.


prevents the linker generating an error message if the symbol is not defined elsewhere. It also prevents the linker searching libraries that are not already included.


The name is resolved at link time to a symbol defined in a separate object file. The symbol is treated as a program address. If [WEAK] is not specified, the linker generates an error if no corresponding symbol is found at link time.

If [WEAK] is specified and no corresponding symbol is found at link time:

  • if the reference is the destination of a Branch or Branch Link instruction, the value of the symbol is taken as the address of the referencing instruction. The instruction becomes B {PC} or BL {PC}.

  • otherwise, the value of the symbol is taken as zero.

You must avoid executing B {PC} and BL {PC} at runtime as they are non-terminating loops.

To avoid trying to access symbols that are not found at link time, use code like the example below to test your environment at runtime.


This example tests to see if the C++ library has been linked, and branches conditionally on the result.

		IMPORT 		__CPP_INITIALIZE[WEAK]						; If C++ library linked
										; gets the address of
										; CPP_INIT function.
		LDR		r0,__CPP_INITIALIZE						; If not linked, address
										; is zeroed.
		CMP		r0,#0						; Test if zero.
		BEQ		nocplusplus						; Branch on the result.
Copyright © 1997, 1998 ARM Limited. All rights reserved.ARM DUI 0041C