15.27 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 {[WEAK]}

EXPORT symbol {[SIZE=n]}

EXPORT symbol {[type{,set}]}

EXPORT symbol [attr{,type{,set}}{,SIZE=n}]

EXPORT symbol [WEAK {,attr}{,type{,set}}{,SIZE=n}]

where:

symbol

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

WEAK

symbol is only imported into other sources if no other source exports an alternative symbol. If [WEAK] is used without symbol, all exported symbols are weak.

attr

can be any one of:

DYNAMIC

sets the ELF symbol visibility to STV_DEFAULT.

PROTECTED

sets the ELF symbol visibility to STV_PROTECTED.

HIDDEN

sets the ELF symbol visibility to STV_HIDDEN.

INTERNAL

sets the ELF symbol visibility to STV_INTERNAL.

type

specifies the symbol type:

DATA

symbol is treated as data when the source is assembled and linked.

CODE

symbol is treated as code when the source is assembled and linked.

ELFTYPE=n

symbol is treated as a particular ELF symbol, as specified by the value of n, where n can be any number from 0 to 15.

If unspecified, the assembler determines the most appropriate type. Usually the assembler determines the correct type so you are not required to specify it.

set

specifies the instruction set:

ARM

symbol is treated as an ARM symbol.

THUMB

symbol is treated as a Thumb symbol.

If unspecified, the assembler determines the most appropriate set.

n

specifies the size and can be any 32-bit value. If the SIZE attribute is not specified, the assembler calculates the size:

  • For PROC and FUNCTION symbols, the size is set to the size of the code until its ENDP or ENDFUNC.

  • For other symbols, the size is the size of instruction or data on the same source line. If there is no instruction or data, the size is zero.

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.

Examples

        AREA    Example,CODE,READONLY
        EXPORT  DoAdd           ; Export the function name
                                ; to be used by external modules.
DoAdd   ADD     r0,r0,r1

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.

The following examples show the use of the SIZE attribute:

        EXPORT symA [SIZE=4]
        EXPORT symA [DATA, SIZE=4]
Non-ConfidentialPDF file icon PDF versionARM DUI0473M
Copyright © 2010-2016 ARM Limited or its affiliates. All rights reserved.