|Home > armclang Integrated Assembler > Symbol binding directives|
These directives modify the ELF binding of one or more symbols.
.global directive sets the symbol binding to
STB_GLOBAL. These symbols will be visible to all object files being
linked, so a definition in one object file can satisfy a reference
.local directive sets the symbol binding in the
symbol table to STB_LOCAL. These symbols are not visible outside the
object file they are defined or referenced in, so multiple object
files can use the same symbol names without interfering with each
.weak directive sets the symbol binding to STB_WEAK.
These symbols behave similarly to global symbols, with these
The symbol binding directive can be at any point in the assembly file, before or after any references or definitions of the symbol.
If the binding of a symbol is not specified using one of these directives, the default binding is:
.Lare different directives. Symbols starting with
.Lare not put into the symbol table.
// This function has global binding, so can be referenced from other object // files. The symbol 'value' defaults to local binding, so other object // files can use the symbol name 'value' without interfering with this // definition and reference. .global get_val get_val: ldr r0, value bx lr value: .word 0x12345678 // The symbol 'printf' is not defined in this file, so defaults to global // binding, so the linker will search other object files and libraries to // find a definition of it. bl printf // The debug_trace symbol is a weak reference. If a definition of it is // found by the linker, this call will be relocated to point to it. If a // definition is not found (e.g. in a release build, which does not include // the debug code), the linker will point the bl instruction at the next // instruction, so it has no effect. .weak debug_trace bl debug_trace