| |||
| Home > Directives Reference > Miscellaneous directives > 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.
EXPORT {[WEAK]}
EXPORTsymbol{[SIZE=n]}
EXPORTsymbol{[type{,set}]}
EXPORTsymbol[attr{,type{,set}}{,SIZE=n}]
EXPORTsymbol[WEAK{,attr}{,type{,set}}{,SIZE=n}]
where:
symbolis the symbol name to export. The symbol name is
case-sensitive. If is omitted,
all symbols are exported.symbol
WEAK is
only imported into other sources if no other source exports an alternative symbol.
If symbol[WEAK] is used without ,
all exported symbols are weak.symbol
attrcan be any one of:
DYNAMICsets the ELF symbol visibility to STV_DEFAULT.
PROTECTEDsets the ELF symbol visibility to STV_PROTECTED.
HIDDENsets the ELF symbol visibility to STV_HIDDEN.
INTERNALsets the ELF symbol visibility to STV_INTERNAL.
typespecifies the symbol type:
DATA is
treated as data when the source is assembled and linked.symbol
CODE is
treated as code when the source is assembled and linked.symbol
ELFTYPE=n is
treated as a particular ELF symbol, as specified by the value of symboln,
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 there is no
need to specify the type.
setspecifies the instruction set:
ARM is
treated as an ARM symbol.symbol
THUMB is
treated as a Thumb symbol.symbol
If unspecified, the assembler determines the most appropriate set.
nspecifies 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.
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 takes
precedence over this one, if a different one is available from another
source. You can use the symbol[WEAK] attribute with any of
the symbol visibility attributes.
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]