6.8.6. EXPORT or GLOBAL

The EXPORT directive declares a symbol that can be used by the linker to resolve symbol references in separate object and library files. GLOBAL is a synonym for EXPORT.

Syntax

EXPORT {symbol}{[WEAK,attr]}

where:

symbol

is the symbol name to export. The symbol name is case-sensitive. If symbol is omitted, all symbols are exported.

[WEAK]

means that this instance of symbol should only be imported into other sources if no other source exports an alternative instance. If [WEAK] is used without symbol, all exported symbols are weak.

[attr]

is symbol visibility when linked into a dynamic component. By default, symbol binding defines visibility, that is, global and weak symbols are visible to other components and local symbols are not hidden.

Valid attributes are:

DYNAMIC

symbol is visible to other components, and can be redefined by other components.

HIDDEN

symbol cannot be referenced outside the component where it is defined, either directly or indirectly.

The linker also accepts INTERNAL and currently treats it as HIDDEN. If you specify both, for example:

EXPORT SymA[WEAK,INTERNAL,HIDDEN]

the assembler chooses the most restrictive (INTERNAL).

PROTECTED

symbol is visible to other components, and cannot be redefined by other components.

Usage

Use EXPORT to give code in other files access to symbols in the current file.

Use the [WEAK] attribute to inform the linker that a different instance of symbol takes precedence over this one, if a different one is available from another source. You can use the [WEAK] attribute with any of the symbol visibility attributes.

Symbol visibility can be overridden for duplicate exports. In the following example, the last EXPORT takes precedence for both binding and visibility:

        EXPORT  SymA[WEAK]      ; Export as weak-hidden
        EXPORT  SymA[DYNAMIC]   ; SymA becomes non-weak dynamic.

See also IMPORT.

Example

        AREA    Example,CODE,READONLY
        EXPORT  DoAdd           ; Export the function name
                                ; to be used by external
                                ; modules.
DoAdd   ADD     r0,r0,r1
Copyright © 2002-2005 ARM Limited. All rights reserved.ARM DUI 0204F
Non-Confidential