You copied the Doc URL to your clipboard.

21.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 iscase-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 treatedas data when the source is assembled and linked.

CODE

symbol is treatedas code when the source is assembled and linked.

ELFTYPE=n

symbol is treatedas 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 treatedas an ARM symbol.

THUMB

symbol is treatedas a Thumb symbol.

If unspecified, the assembler determines the most appropriateset.

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 instructionor 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 filesaccess to symbols in the current file.

Use the [WEAK] attribute to informthe linker that a different instance of symbol takesprecedence over this one, if a different one is available from anothersource. You can use the [WEAK] attribute withany 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 takesprecedence 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]

Related reference

Related information

Was this page helpful? Yes No