global_imports.hss 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. [Main]
  2. Title=Global Imports
  3. Subsections=global_imports_conditional, global_imports_auto
  4. [Top]
  5. Just like <A HREF="$$LINK(startup)">startup sections</A>, the concept of
  6. <U>global imports</U> is unique to the TIGCC linker. Global imports and
  7. startup sections are closely related to each other: It is best to keep
  8. startup sections in archive files, so they can be imported as needed, but
  9. the existing method of importing archive file members does not work. Usually,
  10. an archive file member is imported if a symbol it exports is referenced in
  11. a relocation entry. However, code that requires a specific startup section to
  12. be included does not necessarily reference any of the symbols in the
  13. corresponding archive member; it just needs the startup code to be there. A
  14. global import solves this problem by importing an archive member without
  15. inserting its address anywhere.
  16. <BR><BR>
  17. Actually, a global import imports all archive members that export the symbol
  18. referenced by the import (and even more, see
  19. <A HREF="$$LINK(global_imports_conditional)">Conditional Reaction to Global
  20. Imports</A>). If no archive member exports this symbol, a warning is emitted.
  21. This way, it is very easy to create archive files that react to multiple
  22. imports; for example:
  23. <UL>
  24. <LI>File 1 exports the symbols <I>A</I> and <I>B</I>.</LI>
  25. <LI>File 2 exports the symbols <I>B</I> and <I>C</I>.</LI>
  26. <LI>File 3 exports the symbols <I>A</I> and <I>C</I>.</LI>
  27. </UL>
  28. A global import for <I>A</I> would cause the files 1 and 3 to be included in
  29. the program. If it could only import one file, 6 files would be needed to get
  30. the same result:
  31. <UL>
  32. <LI>File 1 exports the symbol <I>A</I> and creates two global imports for <I>File4</I> and <I>File6</I>.</LI>
  33. <LI>File 2 exports the symbol <I>B</I> and creates two global imports for <I>File4</I> and <I>File5</I>.</LI>
  34. <LI>File 3 exports the symbol <I>C</I> and creates two global imports for <I>File5</I> and <I>File6</I>.</LI>
  35. <LI>File 4 exports the symbol <I>File4</I>.</LI>
  36. <LI>File 5 exports the symbol <I>File5</I>.</LI>
  37. <LI>File 6 exports the symbol <I>File6</I>.</LI>
  38. </UL>
  39. Global import can be created using the
  40. <A HREF="$$LINK(control_ref_all)">__ref_all_...</A> control symbol. Some
  41. global imports are also created automatically by the linker on certain
  42. conditions.