 |
Conditional Reaction to Global Imports |
Sometimes, it is convenient for an archive member to react to a global import
differently than just to be included whenever the import is created. For
example, a startup section may be optimized better if a certain register
already holds a certain value, otherwise it must compute the value by itself.
The TIGCC linker defines two symbol operators for this purpose:
To be included only if the global imports A and B are defined,
a file must export the symbol A_AND_B
. To be
included only if the global import A is not defined, a file must
export the symbol NOT_A
. Symbol operators may be
combined, i.e. a file exporting NOT_A_AND_B
is
included only if no global import A exists, and a global import
B is defined.
There is a small quirk related to negated conditions: At some point, the
linker needs to assume that no global imports A and B exist,
and any file exporting the symbol NOT_A
or
NOT_B
needs to be imported. However, the file which
exported NOT_B
may actually create a global import
A after the file exporting NOT_A
has been
imported. The linker does not detect this, so you need to be careful not to
create such situations. They are especially difficult to detect if a lot of
combinations of AND and NOT operators are used, and if a lot of files that
react to global imports create imports of their own.