[Main]
Title=Global Imports
Subsections=global_imports_conditional, global_imports_auto
[Top]
Just like startup sections, the concept of
global imports is unique to the TIGCC linker. Global imports and
startup sections are closely related to each other: It is best to keep
startup sections in archive files, so they can be imported as needed, but
the existing method of importing archive file members does not work. Usually,
an archive file member is imported if a symbol it exports is referenced in
a relocation entry. However, code that requires a specific startup section to
be included does not necessarily reference any of the symbols in the
corresponding archive member; it just needs the startup code to be there. A
global import solves this problem by importing an archive member without
inserting its address anywhere.
Actually, a global import imports all archive members that export the symbol
referenced by the import (and even more, see
Conditional Reaction to Global
Imports). If no archive member exports this symbol, a warning is emitted.
This way, it is very easy to create archive files that react to multiple
imports; for example: