Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

i386.lds 7.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  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. * Weak symbols that need zero values if not otherwise defined
  30. */
  31. . = 0;
  32. .weak : AT ( 0 ) {
  33. *(.weak)
  34. }
  35. _assert = ASSERT ( ( . == 0 ), ".weak is non-zero length" );
  36. /*
  37. * The prefix
  38. */
  39. _prefix_link_addr = 0;
  40. . = _prefix_link_addr;
  41. _prefix = .;
  42. .prefix : AT ( _prefix_load_offset + __prefix ) {
  43. __prefix = .;
  44. _entry = .;
  45. *(.prefix)
  46. *(.prefix.*)
  47. _eprefix_progbits = .;
  48. }
  49. _eprefix = .;
  50. /*
  51. * The 16-bit sections, if present
  52. */
  53. _text16_link_addr = 0;
  54. . = _text16_link_addr;
  55. _text16 = .;
  56. /* We need to allow code at the NULL address in .text16 */
  57. .text16 : AT ( _text16_load_offset + __text16 ) {
  58. __text16 = .;
  59. *(.text16.null)
  60. . += 1; /* Prevent NULL being valid */
  61. *(.text16)
  62. *(.text16.*)
  63. _etext16_progbits = .;
  64. } = 0x9090
  65. _etext16 = .;
  66. _data16_link_addr = 0;
  67. . = _data16_link_addr;
  68. _data16 = .;
  69. . += 1; /* Prevent NULL being valid */
  70. .rodata16 : AT ( _data16_load_offset + __rodata16 ) {
  71. __rodata16 = .;
  72. *(.rodata16)
  73. *(.rodata16.*)
  74. }
  75. .data16 : AT ( _data16_load_offset + __data16 ) {
  76. __data16 = .;
  77. *(.data16)
  78. *(.data16.*)
  79. _edata16_progbits = .;
  80. }
  81. .bss16 : AT ( _data16_load_offset + __bss16 ) {
  82. __bss16 = .;
  83. _bss16 = .;
  84. *(.bss16)
  85. *(.bss16.*)
  86. _ebss16 = .;
  87. }
  88. .stack16 : AT ( _data16_load_offset + __stack16 ) {
  89. __stack16 = .;
  90. *(.stack16)
  91. *(.stack16.*)
  92. }
  93. _edata16 = .;
  94. /*
  95. * The 32-bit sections
  96. */
  97. _textdata_link_addr = 0;
  98. . = _textdata_link_addr;
  99. _textdata = .;
  100. _text = .;
  101. . += 1; /* Prevent NULL being valid */
  102. .text : AT ( _textdata_load_offset + __text ) {
  103. __text = .;
  104. *(.text.null_trap)
  105. *(.text)
  106. *(.text.*)
  107. } = 0x9090
  108. _etext = .;
  109. _data = .;
  110. .rodata : AT ( _textdata_load_offset + __rodata ) {
  111. __rodata = .;
  112. *(.rodata)
  113. *(.rodata.*)
  114. }
  115. .data : AT ( _textdata_load_offset + __data ) {
  116. __data = .;
  117. *(.data)
  118. *(.data.*)
  119. *(SORT(.tbl.*)) /* Various tables. See include/tables.h */
  120. _etextdata_progbits = .;
  121. }
  122. .bss : AT ( _textdata_load_offset + __bss ) {
  123. __bss = .;
  124. _bss = .;
  125. *(.bss)
  126. *(.bss.*)
  127. *(COMMON)
  128. _ebss = .;
  129. }
  130. .stack : AT ( _textdata_load_offset + __stack ) {
  131. __stack = .;
  132. *(.stack)
  133. *(.stack.*)
  134. }
  135. _edata = .;
  136. _etextdata = .;
  137. _end = .;
  138. /*
  139. * Compressor information block
  140. */
  141. _zinfo_link_addr = 0;
  142. . = _zinfo_link_addr;
  143. _zinfo = .;
  144. .zinfo : AT ( _zinfo_load_offset + __zinfo ) {
  145. __zinfo = .;
  146. _entry = .;
  147. *(.zinfo)
  148. *(.zinfo.*)
  149. _ezinfo_progbits = .;
  150. }
  151. _ezinfo = .;
  152. /*
  153. * Dispose of the comment and note sections to make the link map
  154. * easier to read
  155. */
  156. /DISCARD/ : {
  157. *(.comment)
  158. *(.note)
  159. }
  160. /*
  161. * Load address calculations. The slightly obscure nature of the
  162. * calculations is because ALIGN(x) can only operate on the
  163. * location counter.
  164. */
  165. _max_align = 16;
  166. _load_addr = 0;
  167. . = _load_addr;
  168. . -= _prefix_link_addr;
  169. _prefix_load_offset = ALIGN ( _max_align );
  170. _prefix_load_addr = _prefix_link_addr + _prefix_load_offset;
  171. _prefix_size = _eprefix - _prefix;
  172. _prefix_progbits_size = _eprefix_progbits - _prefix;
  173. . = _prefix_load_addr + _prefix_progbits_size;
  174. . -= _text16_link_addr;
  175. _text16_load_offset = ALIGN ( _max_align );
  176. _text16_load_addr = _text16_link_addr + _text16_load_offset;
  177. _text16_size = _etext16 - _text16;
  178. _text16_progbits_size = _etext16_progbits - _text16;
  179. . = _text16_load_addr + _text16_progbits_size;
  180. . -= _data16_link_addr;
  181. _data16_load_offset = ALIGN ( _max_align );
  182. _data16_load_addr = _data16_link_addr + _data16_load_offset;
  183. _data16_size = _edata16 - _data16;
  184. _data16_progbits_size = _edata16_progbits - _data16;
  185. . = _data16_load_addr + _data16_progbits_size;
  186. . -= _textdata_link_addr;
  187. _textdata_load_offset = ALIGN ( _max_align );
  188. _textdata_load_addr = _textdata_link_addr + _textdata_load_offset;
  189. _textdata_size = _etextdata - _textdata;
  190. _textdata_progbits_size = _etextdata_progbits - _textdata;
  191. . = _textdata_load_addr + _textdata_progbits_size;
  192. _load_size = . - _load_addr;
  193. . -= _zinfo_link_addr;
  194. _zinfo_load_offset = ALIGN ( _max_align );
  195. _zinfo_load_addr = _zinfo_link_addr + _zinfo_load_offset;
  196. _zinfo_size = _ezinfo - _zinfo;
  197. _zinfo_progbits_size = _ezinfo_progbits - _zinfo;
  198. . = _zinfo_load_addr + _zinfo_progbits_size;
  199. _payload_offset = _text16_load_offset;
  200. /*
  201. * Alignment checks. ALIGN() can only operate on the location
  202. * counter, so we set the location counter to each value we want
  203. * to check.
  204. */
  205. . = _prefix_load_addr - _prefix_link_addr;
  206. _assert = ASSERT ( ( . == ALIGN ( _max_align ) ),
  207. "_prefix is badly aligned" );
  208. . = _text16_load_addr - _text16_link_addr;
  209. _assert = ASSERT ( ( . == ALIGN ( _max_align ) ),
  210. "_text16 is badly aligned" );
  211. . = _data16_load_addr - _data16_link_addr;
  212. _assert = ASSERT ( ( . == ALIGN ( _max_align ) ),
  213. "_data16 is badly aligned" );
  214. . = _textdata_load_addr - _textdata_link_addr;
  215. _assert = ASSERT ( ( . == ALIGN ( _max_align ) ),
  216. "_text is badly aligned" );
  217. /*
  218. * Values calculated to save code from doing it
  219. */
  220. _prefix_size_pgh = ( ( _prefix_size + 15 ) / 16 );
  221. _prefix_size_sect = ( ( _prefix_size + 511 ) / 512 );
  222. _text16_size_pgh = ( ( _text16_size + 15 ) / 16 );
  223. _data16_size_pgh = ( ( _data16_size + 15 ) / 16 );
  224. /*
  225. * Load sizes in paragraphs and sectors. Note that wherever the
  226. * _load_size variables are used, there must be a corresponding
  227. * .zinfo.fixup section.
  228. */
  229. _load_size_pgh = ( ( _load_size + 15 ) / 16 );
  230. _load_size_sect = ( ( _load_size + 511 ) / 512 );
  231. }