You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

i386.lds 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. /* -*- sh -*- */
  2. /*
  3. * Linker script for i386 images
  4. *
  5. */
  6. SECTIONS {
  7. /* Each section starts at a virtual address of zero.
  8. *
  9. * We guarantee alignment of virtual addresses to any alignment
  10. * specified by the constituent object files (e.g. via
  11. * __attribute__((aligned(x)))). Load addresses are guaranteed
  12. * only up to _max_align. Provided that all loader and relocation
  13. * code honours _max_align, this means that physical addresses are
  14. * also guaranteed up to _max_align.
  15. *
  16. * Note that when using -DKEEP_IT_REAL, the UNDI segments are only
  17. * guaranteed to be loaded on a paragraph boundary (i.e. 16-byte
  18. * alignment). Using _max_align>16 will therefore not guarantee
  19. * >16-byte alignment of physical addresses when -DKEEP_IT_REAL is
  20. * used (though virtual addresses will still be fully aligned).
  21. *
  22. */
  23. PROVIDE ( _max_align = 16 );
  24. /*
  25. * The prefix
  26. *
  27. */
  28. .prefix 0x0 : AT ( _prefix_lma ) {
  29. _prefix = .;
  30. *(.prefix)
  31. *(.prefix.*)
  32. _mprefix = .;
  33. } .bss.prefix (NOLOAD) : AT ( _end_lma ) {
  34. _eprefix = .;
  35. }
  36. _prefix_filesz = ABSOLUTE ( _mprefix - _prefix );
  37. _prefix_memsz = ABSOLUTE ( _eprefix - _prefix );
  38. /*
  39. * The 16-bit (real-mode) code section
  40. *
  41. */
  42. .text16.early 0x0 : AT ( _text16_early_lma ) {
  43. _text16 = .;
  44. *(.text16.null)
  45. . += 1; /* Prevent NULL being valid */
  46. *(.text16.early)
  47. *(.text16.early.*)
  48. _etext16_early = .;
  49. } .text16.late ALIGN ( _max_align ) : AT ( _text16_late_lma ) {
  50. _text16_late = .;
  51. *(.text16)
  52. *(.text16.*)
  53. _mtext16 = .;
  54. } .bss.text16 (NOLOAD) : AT ( _end_lma ) {
  55. _etext16 = .;
  56. }
  57. _text16_early_filesz = ABSOLUTE ( _etext16_early - _text16 );
  58. _text16_early_memsz = ABSOLUTE ( _etext16_early - _text16 );
  59. _text16_late_filesz = ABSOLUTE ( _mtext16 - _text16_late );
  60. _text16_late_memsz = ABSOLUTE ( _etext16 - _text16_late );
  61. _text16_memsz = ABSOLUTE ( _etext16 - _text16 );
  62. /*
  63. * The 16-bit (real-mode) data section
  64. *
  65. */
  66. .data16 0x0 : AT ( _data16_lma ) {
  67. _data16 = .;
  68. . += 1; /* Prevent NULL being valid */
  69. *(.rodata16)
  70. *(.rodata16.*)
  71. *(.data16)
  72. *(.data16.*)
  73. _mdata16 = .;
  74. } .bss.data16 (NOLOAD) : AT ( _end_lma ) {
  75. *(.bss16)
  76. *(.bss16.*)
  77. *(.stack16)
  78. *(.stack16.*)
  79. _edata16 = .;
  80. }
  81. _data16_filesz = ABSOLUTE ( _mdata16 - _data16 );
  82. _data16_memsz = ABSOLUTE ( _edata16 - _data16 );
  83. /*
  84. * The 32-bit sections
  85. *
  86. */
  87. .textdata 0x0 : AT ( _textdata_lma ) {
  88. _textdata = .;
  89. *(.text.null_trap)
  90. . += 1; /* Prevent NULL being valid */
  91. *(.text)
  92. *(.text.*)
  93. *(.rodata)
  94. *(.rodata.*)
  95. *(.data)
  96. *(.data.*)
  97. *(SORT(.tbl.*)) /* Various tables. See include/tables.h */
  98. _mtextdata = .;
  99. } .bss.textdata (NOLOAD) : AT ( _end_lma ) {
  100. *(.bss)
  101. *(.bss.*)
  102. *(COMMON)
  103. *(.stack)
  104. *(.stack.*)
  105. _etextdata = .;
  106. }
  107. _textdata_filesz = ABSOLUTE ( _mtextdata - _textdata );
  108. _textdata_memsz = ABSOLUTE ( _etextdata - _textdata );
  109. /*
  110. * Compressor information block
  111. *
  112. */
  113. .zinfo 0x0 : AT ( _zinfo_lma ) {
  114. _zinfo = .;
  115. *(.zinfo)
  116. *(.zinfo.*)
  117. _mzinfo = .;
  118. } .bss.zinfo (NOLOAD) : AT ( _end_lma ) {
  119. _ezinfo = .;
  120. }
  121. _zinfo_filesz = ABSOLUTE ( _mzinfo - _zinfo );
  122. _zinfo_memsz = ABSOLUTE ( _ezinfo - _zinfo );
  123. /*
  124. * Weak symbols that need zero values if not otherwise defined
  125. *
  126. */
  127. .weak 0x0 : AT ( _end_lma ) {
  128. _weak = .;
  129. *(.weak)
  130. _eweak = .;
  131. }
  132. _assert = ASSERT ( ( _weak == _eweak ), ".weak is non-zero length" );
  133. /*
  134. * Dispose of the comment and note sections to make the link map
  135. * easier to read
  136. *
  137. */
  138. /DISCARD/ : {
  139. *(.comment)
  140. *(.comment.*)
  141. *(.note)
  142. *(.note.*)
  143. *(.eh_frame)
  144. *(.eh_frame.*)
  145. *(.rel)
  146. *(.rel.*)
  147. *(.einfo)
  148. *(.einfo.*)
  149. *(.discard)
  150. }
  151. /*
  152. * Load address calculations. In older versions of ld, ALIGN()
  153. * can operate only on the location counter, so we use that.
  154. *
  155. */
  156. . = 0;
  157. . = ALIGN ( _max_align );
  158. _prefix_lma = .;
  159. . += _prefix_filesz;
  160. . = ALIGN ( _max_align );
  161. _text16_early_lma = .;
  162. . += _text16_early_filesz;
  163. . = ALIGN ( _max_align );
  164. _payload_lma = .;
  165. _text16_late_lma = .;
  166. . += _text16_late_filesz;
  167. . = ALIGN ( _max_align );
  168. _data16_lma = .;
  169. . += _data16_filesz;
  170. . = ALIGN ( _max_align );
  171. _textdata_lma = .;
  172. . += _textdata_filesz;
  173. _filesz = .; /* Do not include zinfo block in file size */
  174. . = ALIGN ( _max_align );
  175. _zinfo_lma = .;
  176. . += _zinfo_filesz;
  177. . = ALIGN ( _max_align );
  178. _end_lma = .;
  179. /*
  180. * Values calculated to save code from doing it
  181. *
  182. */
  183. _text16_memsz_pgh = ( ( _text16_memsz + 15 ) / 16 );
  184. _data16_memsz_pgh = ( ( _data16_memsz + 15 ) / 16 );
  185. _textdata_memsz_pgh = ( ( _textdata_memsz + 15 ) / 16 );
  186. _textdata_memsz_kb = ( ( _textdata_memsz + 1023 ) / 1024 );
  187. }