Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

i386.lds 6.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. /* -*- sh -*- */
  2. /*
  3. * Linker script for i386 images
  4. *
  5. */
  6. OUTPUT_FORMAT ( "elf32-i386", "elf32-i386", "elf32-i386" )
  7. OUTPUT_ARCH ( i386 )
  8. ENTRY ( _entry )
  9. SECTIONS {
  10. /* All sections in the resulting file have consecutive load
  11. * addresses, but may have individual link addresses depending on
  12. * the memory model being used.
  13. *
  14. * We guarantee alignment of virtual addresses to any alignment
  15. * specified by the constituent object files (e.g. via
  16. * __attribute__((aligned(x)))). Load addresses are guaranteed
  17. * only up to _max_align. Provided that all loader and relocation
  18. * code honours _max_align, this means that physical addresses are
  19. * also guaranteed up to _max_align.
  20. *
  21. * Note that when using -DKEEP_IT_REAL, the UNDI segments are only
  22. * guaranteed to be loaded on a paragraph boundary (i.e. 16-byte
  23. * alignment). Using _max_align>16 will therefore not guarantee
  24. * >16-byte alignment of physical addresses when -DKEEP_IT_REAL is
  25. * used (though virtual addresses will still be fully aligned).
  26. *
  27. */
  28. /*
  29. * The prefix
  30. */
  31. _prefix_link_addr = 0;
  32. . = _prefix_link_addr;
  33. _prefix = .;
  34. .prefix : AT ( _prefix_load_offset + __prefix ) {
  35. __prefix = .;
  36. _entry = .;
  37. *(.prefix)
  38. *(.prefix.*)
  39. _eprefix_progbits = .;
  40. }
  41. _eprefix = .;
  42. /*
  43. * The 16-bit sections, if present
  44. */
  45. _text16_link_addr = 0;
  46. . = _text16_link_addr;
  47. _text16 = .;
  48. . += 1; /* Prevent NULL being valid */
  49. .text16 : AT ( _text16_load_offset + __text16 ) {
  50. __text16 = .;
  51. *(.text16)
  52. *(.text16.*)
  53. _etext16_progbits = .;
  54. } = 0x9090
  55. _etext16 = .;
  56. _data16_link_addr = 0;
  57. . = _data16_link_addr;
  58. _data16 = .;
  59. . += 1; /* Prevent NULL being valid */
  60. .rodata16 : AT ( _data16_load_offset + __rodata16 ) {
  61. __rodata16 = .;
  62. *(.rodata16)
  63. *(.rodata16.*)
  64. }
  65. .data16 : AT ( _data16_load_offset + __data16 ) {
  66. __data16 = .;
  67. *(.data16)
  68. *(.data16.*)
  69. _edata16_progbits = .;
  70. }
  71. .bss16 : AT ( _data16_load_offset + __bss16 ) {
  72. __bss16 = .;
  73. _bss16 = .;
  74. *(.bss16)
  75. *(.bss16.*)
  76. _ebss16 = .;
  77. }
  78. .stack16 : AT ( _data16_load_offset + __stack16 ) {
  79. __stack16 = .;
  80. *(.stack16)
  81. *(.stack16.*)
  82. }
  83. _edata16 = .;
  84. /*
  85. * The 32-bit sections
  86. */
  87. _textdata_link_addr = 0;
  88. . = _textdata_link_addr;
  89. _textdata = .;
  90. _text = .;
  91. . += 1; /* Prevent NULL being valid */
  92. .text : AT ( _textdata_load_offset + __text ) {
  93. __text = .;
  94. *(.text.null_trap)
  95. *(.text)
  96. *(.text.*)
  97. } = 0x9090
  98. _etext = .;
  99. _data = .;
  100. .rodata : AT ( _textdata_load_offset + __rodata ) {
  101. __rodata = .;
  102. *(.rodata)
  103. *(.rodata.*)
  104. }
  105. .data : AT ( _textdata_load_offset + __data ) {
  106. __data = .;
  107. *(.data)
  108. *(.data.*)
  109. *(SORT(.tbl.*)) /* Various tables. See include/tables.h */
  110. _etextdata_progbits = .;
  111. }
  112. .bss : AT ( _textdata_load_offset + __bss ) {
  113. __bss = .;
  114. _bss = .;
  115. *(.bss)
  116. *(.bss.*)
  117. *(COMMON)
  118. _ebss = .;
  119. }
  120. .stack : AT ( _textdata_load_offset + __stack ) {
  121. __stack = .;
  122. *(.stack)
  123. *(.stack.*)
  124. }
  125. _edata = .;
  126. _etextdata = .;
  127. _end = .;
  128. /*
  129. * Compressor information block
  130. */
  131. _zinfo_link_addr = 0;
  132. . = _zinfo_link_addr;
  133. _zinfo = .;
  134. .zinfo : AT ( _zinfo_load_offset + __zinfo ) {
  135. __zinfo = .;
  136. _entry = .;
  137. *(.zinfo)
  138. *(.zinfo.*)
  139. _ezinfo_progbits = .;
  140. }
  141. _ezinfo = .;
  142. /*
  143. * Dispose of the comment and note sections to make the link map
  144. * easier to read
  145. */
  146. /DISCARD/ : {
  147. *(.comment)
  148. *(.note)
  149. }
  150. /*
  151. * Load address calculations. The slightly obscure nature of the
  152. * calculations is because ALIGN(x) can only operate on the
  153. * location counter.
  154. */
  155. _max_align = 16;
  156. _load_addr = 0;
  157. . = _load_addr;
  158. . -= _prefix_link_addr;
  159. _prefix_load_offset = ALIGN ( _max_align );
  160. _prefix_load_addr = _prefix_link_addr + _prefix_load_offset;
  161. _prefix_size = _eprefix - _prefix;
  162. _prefix_progbits_size = _eprefix_progbits - _prefix;
  163. . = _prefix_load_addr + _prefix_progbits_size;
  164. . -= _text16_link_addr;
  165. _text16_load_offset = ALIGN ( _max_align );
  166. _text16_load_addr = _text16_link_addr + _text16_load_offset;
  167. _text16_size = _etext16 - _text16;
  168. _text16_progbits_size = _etext16_progbits - _text16;
  169. . = _text16_load_addr + _text16_progbits_size;
  170. . -= _data16_link_addr;
  171. _data16_load_offset = ALIGN ( _max_align );
  172. _data16_load_addr = _data16_link_addr + _data16_load_offset;
  173. _data16_size = _edata16 - _data16;
  174. _data16_progbits_size = _edata16_progbits - _data16;
  175. . = _data16_load_addr + _data16_progbits_size;
  176. . -= _textdata_link_addr;
  177. _textdata_load_offset = ALIGN ( _max_align );
  178. _textdata_load_addr = _textdata_link_addr + _textdata_load_offset;
  179. _textdata_size = _etextdata - _textdata;
  180. _textdata_progbits_size = _etextdata_progbits - _textdata;
  181. . = _textdata_load_addr + _textdata_progbits_size;
  182. _load_size = . - _load_addr;
  183. . -= _zinfo_link_addr;
  184. _zinfo_load_offset = ALIGN ( _max_align );
  185. _zinfo_load_addr = _zinfo_link_addr + _zinfo_load_offset;
  186. _zinfo_size = _ezinfo - _zinfo;
  187. _zinfo_progbits_size = _ezinfo_progbits - _zinfo;
  188. . = _zinfo_load_addr + _zinfo_progbits_size;
  189. _payload_offset = _text16_load_offset;
  190. /*
  191. * Alignment checks. ALIGN() can only operate on the location
  192. * counter, so we set the location counter to each value we want
  193. * to check.
  194. */
  195. . = _prefix_load_addr - _prefix_link_addr;
  196. _assert = ASSERT ( ( . == ALIGN ( _max_align ) ),
  197. "_prefix is badly aligned" );
  198. . = _text16_load_addr - _text16_link_addr;
  199. _assert = ASSERT ( ( . == ALIGN ( _max_align ) ),
  200. "_text16 is badly aligned" );
  201. . = _data16_load_addr - _data16_link_addr;
  202. _assert = ASSERT ( ( . == ALIGN ( _max_align ) ),
  203. "_data16 is badly aligned" );
  204. . = _textdata_load_addr - _textdata_link_addr;
  205. _assert = ASSERT ( ( . == ALIGN ( _max_align ) ),
  206. "_text is badly aligned" );
  207. /*
  208. * Values calculated to save code from doing it
  209. */
  210. _prefix_size_pgh = ( ( _prefix_size + 15 ) / 16 );
  211. _prefix_size_sect = ( ( _prefix_size + 511 ) / 512 );
  212. _text16_size_pgh = ( ( _text16_size + 15 ) / 16 );
  213. _data16_size_pgh = ( ( _data16_size + 15 ) / 16 );
  214. /*
  215. * Load sizes in paragraphs and sectors. Note that wherever the
  216. * _load_size variables are used, there must be a corresponding
  217. * .zinfo.fixup section.
  218. */
  219. _load_size_pgh = ( ( _load_size + 15 ) / 16 );
  220. _load_size_sect = ( ( _load_size + 511 ) / 512 );
  221. }