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.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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. /*
  24. * The prefix
  25. *
  26. */
  27. .prefix 0x0 : AT ( _prefix_lma ) {
  28. _prefix = .;
  29. *(.prefix)
  30. *(.prefix.*)
  31. _mprefix = .;
  32. } .prefix_bss (NOLOAD) : {
  33. _eprefix = .;
  34. }
  35. _prefix_filesz = ABSOLUTE ( _mprefix - _prefix );
  36. _prefix_memsz = ABSOLUTE ( _eprefix - _prefix );
  37. /*
  38. * The 16-bit (real-mode) code section
  39. *
  40. */
  41. .text16 0x0 : AT ( _text16_lma ) {
  42. _text16 = .;
  43. *(.text16.null)
  44. . += 1; /* Prevent NULL being valid */
  45. *(.text16)
  46. *(.text16.*)
  47. _mtext16 = .;
  48. } .text16_bss (NOLOAD) : {
  49. _etext16 = .;
  50. }
  51. _text16_filesz = ABSOLUTE ( _mtext16 - _text16 );
  52. _text16_memsz = ABSOLUTE ( _etext16 - _text16 );
  53. /*
  54. * The 16-bit (real-mode) data section
  55. *
  56. */
  57. .data16 0x0 : AT ( _data16_lma ) {
  58. _data16 = .;
  59. . += 1; /* Prevent NULL being valid */
  60. *(.rodata16)
  61. *(.rodata16.*)
  62. *(.data16)
  63. *(.data16.*)
  64. _mdata16 = .;
  65. } .data16_bss (NOLOAD) : {
  66. *(.bss16)
  67. *(.bss16.*)
  68. *(.stack16)
  69. *(.stack16.*)
  70. _edata16 = .;
  71. }
  72. _data16_filesz = ABSOLUTE ( _mdata16 - _data16 );
  73. _data16_memsz = ABSOLUTE ( _edata16 - _data16 );
  74. /*
  75. * The 32-bit sections
  76. *
  77. */
  78. .textdata 0x0 : AT ( _textdata_lma ) {
  79. _textdata = .;
  80. *(.text.null_trap)
  81. . += 1; /* Prevent NULL being valid */
  82. *(.text)
  83. *(.text.*)
  84. *(.rodata)
  85. *(.rodata.*)
  86. *(.data)
  87. *(.data.*)
  88. *(SORT(.tbl.*)) /* Various tables. See include/tables.h */
  89. _mtextdata = .;
  90. } .textdata_bss (NOLOAD) : {
  91. *(.bss)
  92. *(.bss.*)
  93. *(COMMON)
  94. *(.stack)
  95. *(.stack.*)
  96. _etextdata = .;
  97. }
  98. _textdata_filesz = ABSOLUTE ( _mtextdata - _textdata );
  99. _textdata_memsz = ABSOLUTE ( _etextdata - _textdata );
  100. /*
  101. * Compressor information block
  102. *
  103. */
  104. .zinfo 0x0 : AT ( _zinfo_lma ) {
  105. _zinfo = .;
  106. *(.zinfo)
  107. *(.zinfo.*)
  108. _mzinfo = .;
  109. } .zinfo_bss (NOLOAD) : {
  110. _ezinfo = .;
  111. }
  112. _zinfo_filesz = ABSOLUTE ( _mzinfo - _zinfo );
  113. _zinfo_memsz = ABSOLUTE ( _ezinfo - _zinfo );
  114. /*
  115. * Weak symbols that need zero values if not otherwise defined
  116. *
  117. */
  118. .weak 0x0 : {
  119. _weak = .;
  120. *(.weak)
  121. _eweak = .;
  122. }
  123. _assert = ASSERT ( ( _weak == _eweak ), ".weak is non-zero length" );
  124. /*
  125. * Dispose of the comment and note sections to make the link map
  126. * easier to read
  127. *
  128. */
  129. /DISCARD/ : {
  130. *(.comment)
  131. *(.note)
  132. }
  133. /*
  134. * Load address calculations. In older versions of ld, ALIGN()
  135. * can operate only on the location counter, so we use that.
  136. *
  137. */
  138. PROVIDE ( _max_align = 16 );
  139. . = 0;
  140. _prefix_lma = .;
  141. . += _prefix_filesz;
  142. . = ALIGN ( _max_align );
  143. _payload_lma = .;
  144. _text16_lma = .;
  145. . += _text16_filesz;
  146. . = ALIGN ( _max_align );
  147. _data16_lma = .;
  148. . += _data16_filesz;
  149. . = ALIGN ( _max_align );
  150. _textdata_lma = .;
  151. . += _textdata_filesz;
  152. . = ALIGN ( _max_align );
  153. _filesz = .; /* Do not include zinfo block in file size */
  154. _zinfo_lma = .;
  155. . += _zinfo_filesz;
  156. . = ALIGN ( _max_align );
  157. /*
  158. * Values calculated to save code from doing it
  159. *
  160. */
  161. _prefix_memsz_pgh = ( ( _prefix_memsz + 15 ) / 16 );
  162. _prefix_memsz_sect = ( ( _prefix_memsz + 511 ) / 512 );
  163. _text16_memsz_pgh = ( ( _text16_memsz + 15 ) / 16 );
  164. _data16_memsz_pgh = ( ( _data16_memsz + 15 ) / 16 );
  165. /*
  166. * File size in paragraphs and sectors. Note that wherever the
  167. * _filesz variables are used, there must be a corresponding
  168. * .zinfo.fixup section.
  169. *
  170. */
  171. _filesz_pgh = ( ( _filesz + 15 ) / 16 );
  172. _filesz_sect = ( ( _filesz + 511 ) / 512 );
  173. }