Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

i386.lds 7.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  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. * The linker symbols {prefix,decompress,text,data}_link_addr,
  15. * load_addr, and _max_align may be specified explicitly. If not
  16. * specified, they will default to:
  17. *
  18. * _prefix_link_addr = 0
  19. * _decompress_link_addr = 0
  20. * _text_link_addr = 0
  21. * _data_link_addr = _text_link_addr + sizeof ( text sections )
  22. * _load_addr = 0
  23. * _max_align = 16
  24. *
  25. * We guarantee alignment of virtual addresses to any alignment
  26. * specified by the constituent object files (e.g. via
  27. * __attribute__((aligned(x)))). Load addresses are guaranteed
  28. * only up to _max_align. Provided that all loader and relocation
  29. * code honours _max_align, this means that physical addresses are
  30. * also guaranteed up to _max_align.
  31. *
  32. * Note that when using -DKEEP_IT_REAL, the UNDI segments are only
  33. * guaranteed to be loaded on a paragraph boundary (i.e. 16-byte
  34. * alignment). Using _max_align>16 will therefore not guarantee
  35. * >16-byte alignment of physical addresses when -DKEEP_IT_REAL is
  36. * used (though virtual addresses will still be fully aligned).
  37. *
  38. * The real-mode prefixes rely on _text_link_addr and
  39. * _decompress_link_addr being 0, since they issue far calls into
  40. * those sections, thus requiring that symbol_value ==
  41. * symbol_offset therein. Using the linker to calculate
  42. * e.g. offset_setup16=setup16-_text will not work, since you then
  43. * cannot use the reference from the prefix to setup16 to drag in
  44. * setup16.o. Life is hard.
  45. *
  46. * If librm is included, then it must go at offset 0 within the
  47. * text section. This is because librm is dual-usage: it is
  48. * called from setup16 with %cs:0000 pointing to the start of the
  49. * text section, and later it will be copied to base memory and
  50. * called with %cs:0000 pointing to the start of librm.
  51. *
  52. * The decompressor is designed to decompress in-place. After
  53. * calling the decompressor, the image will look exactly the same
  54. * as the uncompressed image; the compressed data and the
  55. * decompressor code itself will have been overwritten.
  56. */
  57. /*
  58. * The prefix
  59. */
  60. _prefix_link_addr = DEFINED ( _prefix_link_addr ) ? _prefix_link_addr : 0;
  61. . = _prefix_link_addr;
  62. _prefix = .;
  63. .prefix : AT ( _prefix_load_offset + __prefix ) {
  64. __prefix = .;
  65. _entry = .;
  66. *(.prefix)
  67. *(.prefix.*)
  68. }
  69. _eprefix = .;
  70. /*
  71. * The decompressor (may be absent)
  72. */
  73. _decompress_link_addr = DEFINED ( _decompress_link_addr ) ?
  74. _decompress_link_addr : 0;
  75. . = _decompress_link_addr;
  76. _decompress = .;
  77. .decompress : AT ( _decompress_load_offset + __decompress ) {
  78. __decompress = .;
  79. *(.decompress)
  80. *(.decompress.*)
  81. }
  82. _edecompress = .;
  83. /*
  84. * The text sections
  85. */
  86. _text_link_addr = DEFINED ( _text_link_addr ) ? _text_link_addr : 0;
  87. . = _text_link_addr;
  88. _text = .;
  89. .text16 : AT ( _text_load_offset + __text16 ) {
  90. __text16 = .;
  91. /* librm is a special case; it must go at the start of the
  92. * text section if it is included.
  93. */
  94. _assert = ASSERT ( ( . == _text_link_addr ), "librm cannot go first" );
  95. *(.librm)
  96. *(.text16)
  97. *(.text16.*)
  98. } = 0x9090
  99. .text : AT ( _text_load_offset + __text ) {
  100. __text = .;
  101. *(.text)
  102. *(.text.*)
  103. } = 0x9090
  104. _etext = .;
  105. /*
  106. * The data sections
  107. */
  108. _data_link_addr = DEFINED ( _data_link_addr ) ? _data_link_addr : .;
  109. . = _data_link_addr;
  110. _data = .;
  111. .rodata : AT ( _data_load_offset + __rodata ) {
  112. __rodata = .;
  113. *(.rodata)
  114. *(.rodata.*)
  115. }
  116. .data : AT ( _data_load_offset + __data ) {
  117. __data = .;
  118. *(.data)
  119. *(.data.*)
  120. pci_drivers = .;
  121. *(.drivers.pci)
  122. pci_drivers_end = .;
  123. isa_drivers = .;
  124. *(.drivers.isa)
  125. isa_drivers_end = .;
  126. console_drivers = .;
  127. *(.drivers.console)
  128. console_drivers_end = .;
  129. init_fns = .;
  130. *(SORT(.init_fns.*))
  131. init_fns_end = .;
  132. _progbits_end = .;
  133. }
  134. .bss : AT ( _data_load_offset + __bss ) {
  135. __bss = .;
  136. _bss = .;
  137. *(.bss)
  138. *(.bss.*)
  139. *(COMMON)
  140. _ebss = .;
  141. }
  142. .stack : AT ( _data_load_offset + __stack ) {
  143. __stack = .;
  144. *(.stack)
  145. *(.stack.*)
  146. }
  147. _edata = .;
  148. _end = .;
  149. /*
  150. * Dispose of the comment and note sections to make the link map
  151. * easier to read
  152. */
  153. /DISCARD/ : {
  154. *(.comment)
  155. *(.note)
  156. }
  157. /*
  158. * Load address calculations. The slightly obscure nature of the
  159. * calculations is because ALIGN(x) can only operate on the
  160. * location counter.
  161. */
  162. _max_align = DEFINED ( _max_align ) ? _max_align : 16;
  163. _load_addr = DEFINED ( _load_addr ) ? _load_addr : 0;
  164. . = _load_addr;
  165. . -= _prefix_link_addr;
  166. _prefix_load_offset = ALIGN ( _max_align );
  167. _prefix_load_addr = _prefix_link_addr + _prefix_load_offset;
  168. _prefix_size = _eprefix - _prefix;
  169. . = _prefix_load_addr + _prefix_size;
  170. . -= _decompress_link_addr;
  171. _decompress_load_offset = ALIGN ( _max_align );
  172. _decompress_load_addr = _decompress_link_addr + _decompress_load_offset;
  173. _decompress_size = _edecompress - _decompress;
  174. . = _decompress_load_addr + _decompress_size;
  175. . -= _text_link_addr;
  176. _text_load_offset = ALIGN ( _max_align );
  177. _text_load_addr = _text_link_addr + _text_load_offset;
  178. _text_size = _etext - _text;
  179. . = _text_load_addr + _text_size;
  180. . -= _data_link_addr;
  181. _data_load_offset = ALIGN ( _max_align );
  182. _data_load_addr = _data_link_addr + _data_load_offset;
  183. _data_size = _edata - _data;
  184. . = _data_load_addr + _data_size;
  185. /*
  186. * Alignment checks. ALIGN() can only operate on the location
  187. * counter, so we set the location counter to each value we want
  188. * to check.
  189. */
  190. . = _prefix_load_addr - _prefix_link_addr;
  191. _assert = ASSERT ( ( . == ALIGN ( _max_align ) ),
  192. "_prefix is badly aligned" );
  193. . = _decompress_load_addr - _prefix_link_addr;
  194. _assert = ASSERT ( ( . == ALIGN ( _max_align ) ),
  195. "_decompress is badly aligned" );
  196. . = _text_load_addr - _text_link_addr;
  197. _assert = ASSERT ( ( . == ALIGN ( _max_align ) ),
  198. "_text is badly aligned" );
  199. . = _data_load_addr - _data_link_addr;
  200. _assert = ASSERT ( ( . == ALIGN ( _max_align ) ),
  201. "_data is badly aligned" );
  202. /*
  203. * setup16 needs to know this when KEEP_IT_REAL is used. There
  204. * are no harmful side-effects of calculating it all the time.
  205. */
  206. _text_load_size_pgh = ( _data_load_addr - _text_load_addr ) / 16 ;
  207. /*
  208. * Useful-to-know values.
  209. */
  210. /* Size of the decompressed runtime image */
  211. _runtime_size = _edata - _text;
  212. /* Size of the initialised-contents portion of the runtime image */
  213. _runtime_progbits_size = _progbits_end - _text;
  214. /* Size of the (non-compressed) binary file */
  215. _file_size = _prefix_size + _runtime_progbits_size;
  216. /* Size of the non-compressed portion of the compressed binary file */
  217. _zfile_noncompressed_size = _prefix_size + _decompress_size;
  218. }