insert_preos_compressed_tables.hss 4.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. [Main]
  2. Title=__ld_insert_preos_compressed_tables
  3. See Also=insert_compressed_relocs: __ld_insert_compressed_relocs, insert_compressed_rom_calls: __ld_insert_compressed_rom_calls, insert_kernel_ram_calls: __ld_insert_kernel_ram_calls, insert_compressed_bss_refs: __ld_insert_compressed_bss_refs
  4. [Top]
  5. __ld_insert_preos_compressed_tables is the most complex of the automatic
  6. insertions. It inserts all relocation-related tables in the compressed format
  7. expected by PreOs 0.68 or higher. PreOs expects those tables to be pointed to
  8. by the same pointer, so they need to be inserted all at once. The reference
  9. address expected by PreOs is the same for all relocation tables: 36 (0x24).
  10. It is defined as the end address of the smallest possible header/stub
  11. combination. (However, the smallest possible stub is not usable in practice
  12. because it does not emit <I>any</I> error messages. Therefore, the address
  13. does not correspond to any actual address in TIGCCLIB, so it is hard-coded in
  14. the linker.) The tables it inserts are, in order:
  15. <UL>
  16. <LI><B>Library import table</B>:
  17. <UL>
  18. <LI>For each referenced library...
  19. <UL>
  20. <LI><B>8 bytes:</B> library variable name</LI>
  21. <LI><B>1 byte:</B> 0</LI>
  22. <LI><B>1 byte:</B> minimum version number (see
  23. <A HREF="$$LINK(control_lib_min_version)">Minimum Library
  24. Versions</A>)</LI>
  25. </UL></LI>
  26. <LI>For each referenced library (again)...
  27. <UL>
  28. <LI><B>PreOs index</B> (see below): number of imported
  29. functions/variables minus 1</LI>
  30. <LI>For each imported function/variable...
  31. <UL>
  32. <LI><B>PreOs index</B> (see below): <I>index</I> of the
  33. function/variable (relative to the previous one)</LI>
  34. <LI>Relocation table for this function/variable. See
  35. <A HREF="$$LINK(insert_compressed_relocs)">__ld_insert_compressed_relocs</A>
  36. for the format used.</LI>
  37. </UL></LI>
  38. </UL></LI>
  39. </UL></LI>
  40. <LI><B>ROM call import table</B>:
  41. <UL>
  42. <LI><B>PreOs index</B> (see below): the number of different ROM calls
  43. minus 1</LI>
  44. <LI>For each ROM call...
  45. <UL>
  46. <LI><B>PreOs index</B> (see below): <I>index</I> of the ROM
  47. call (relative to the previous one)</LI>
  48. <LI>A compressed relocation table for this ROM call. See
  49. <A HREF="$$LINK(insert_compressed_relocs)">__ld_insert_compressed_relocs</A>
  50. for the format used.</LI>
  51. </UL></LI>
  52. </UL></LI>
  53. <LI><B>RAM call import table</B>, in the same format as the ROM call import
  54. table. The indices used are the indices <I>after</I> setting the
  55. <I>size</I> and <I>type</I> flags described under
  56. <A HREF="$$LINK(insert_kernel_ram_calls)">__ld_insert_kernel_ram_calls</A>.</LI>
  57. <LI><B>Relocation table</B>: See
  58. <A HREF="$$LINK(insert_compressed_relocs)">__ld_insert_compressed_relocs</A>
  59. for the format used.</LI>
  60. <LI><B>BSS relocation table</B>:
  61. <UL>
  62. <LI><B>2 bytes:</B> <I>BSS size</I> / 4</LI>
  63. <LI>A compressed relocation table. See
  64. <A HREF="$$LINK(insert_compressed_bss_refs)">__ld_insert_compressed_bss_refs</A>
  65. for the format used.</LI>
  66. </UL></LI>
  67. </UL>
  68. PreOs uses a special format for the indices. It is <I>not</I> the same as for
  69. the relocation table. Instead, a <B>PreOs index</B> is encoded using
  70. <I>one</I> of the following formats:
  71. <UL>
  72. <LI><B>1 byte:</B> <I>offset</I> (must be between 0x00 and 0xFD)</LI>
  73. <LI><B>2 bytes:</B>
  74. <UL>
  75. <LI><B>1 byte:</B> 0xFE</LI>
  76. <LI><B>1 byte:</B> <I>offset</I> - 0xFE</LI>
  77. </UL></LI>
  78. <LI><B>3 bytes:</B>
  79. <UL>
  80. <LI><B>1 byte:</B> 0xFF</LI>
  81. <LI><B>2 bytes:</B> <I>index</I> (not <I>offset</I>!)</LI>
  82. </UL></LI>
  83. </UL>
  84. where <I>index</I> is the actual index, and <I>offset</I> is <I>index</I> + 1
  85. for the first index and the difference between <I>index</I> and the previous
  86. index for the following ones.
  87. <BR><BR>
  88. <B>Note:</B> Since parts of this insertion are dealing with relocs, the
  89. limitations of
  90. <A HREF="$$LINK(insert_kernel_relocs)">__ld_insert_kernel_relocs</A> also
  91. apply to this insertion.