The IMPORT command specifies that a symbol is defined in a shared object at runtime.
Note
A symbol can be imported only if the reference has STV_DEFAULT
visibility.
You must use the --override_visibility
command-line
option to enable the linker to override symbol visibility to STV_DEFAULT
.
IMPORT
pattern
[ AS replacement_pattern
] [ ,pattern
[ AS replacement_pattern
]]
where:
pattern
Is a string, optionally including wildcard characters (either
*
or?
), that matches zero or more undefined global symbols. If
does not match any undefined global symbol, the linker ignores the command. The operand can match only undefined global symbols.pattern
replacement_pattern
Is a string, optionally including wildcard characters (either
*
or?
), to which the symbol is to be renamed. Wild characters must have a corresponding wildcard in
. The characters matched by thepattern
wildcard are substituted for thepattern
wildcard.replacement_pattern
For example:
IMPORT my_func AS func
imports and renames the undefined symbol
my_func
asfunc
.
You cannot import a symbol that has been defined in the current
shared object or executable. Only one wildcard character (either *
or ?
)
is permitted in IMPORT.
The undefined symbol is included in the dynamic symbol table
(as
if
given, otherwise as replacement_pattern
),
if a dynamic symbol table is present.pattern
Note
The IMPORT command only affects undefined global symbols. Symbols that have been resolved by a shared library are implicitly imported into the dynamic symbol table. The linker ignores any IMPORT directive that targets an implicitly imported symbol.
- Concepts
Using the Linker:
- Reference