global_imports_conditional.hss 1.6 KB

1234567891011121314151617181920212223242526272829303132
  1. [Main]
  2. Title=Conditional Reaction to Global Imports
  3. Index=..._AND_..., NOT_...
  4. [Top]
  5. Sometimes, it is convenient for an archive member to react to a global import
  6. differently than just to be included whenever the import is created. For
  7. example, a startup section may be optimized better if a certain register
  8. already holds a certain value, otherwise it must compute the value by itself.
  9. The TIGCC linker defines two symbol operators for this purpose:
  10. <UL>
  11. <LI>..._AND_...</LI>
  12. <LI>NOT_...</LI>
  13. </UL>
  14. To be included only if the global imports <I>A</I> and <I>B</I> are defined,
  15. a file must export the symbol <CODE><I>A</I>_AND_<I>B</I></CODE>. To be
  16. included only if the global import <I>A</I> is not defined, a file must
  17. export the symbol <CODE>NOT_<I>A</I></CODE>. Symbol operators may be
  18. combined, i.e. a file exporting <CODE>NOT_<I>A</I>_AND_<I>B</I></CODE> is
  19. included only if no global import <I>A</I> exists, and a global import
  20. <I>B</I> is defined.
  21. <BR><BR>
  22. There is a small quirk related to negated conditions: At some point, the
  23. linker needs to assume that no global imports <I>A</I> and <I>B</I> exist,
  24. and any file exporting the symbol <CODE>NOT_<I>A</I></CODE> or
  25. <CODE>NOT_<I>B</I></CODE> needs to be imported. However, the file which
  26. exported <CODE>NOT_<I>B</I></CODE> may actually create a global import
  27. <I>A</I> after the file exporting <CODE>NOT_<I>A</I></CODE> has been
  28. imported. The linker does not detect this, so you need to be careful not to
  29. create such situations. They are especially difficult to detect if a lot of
  30. combinations of AND and NOT operators are used, and if a lot of files that
  31. react to global imports create imports of their own.