kernel.ld 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. OUTPUT_FORMAT(elf32-i386)
  2. OUTPUT_ARCH(i386:i386)
  3. MEMORY
  4. {
  5. MEM : org = 0x00000000, l = 4096M
  6. }
  7. SECTIONS
  8. {
  9. .stage1 0x8000 : AT(0x00000000)
  10. {
  11. __stage1_start = .;
  12. *(.stage1)
  13. . = ALIGN(0x1000);
  14. __stage1_end = .;
  15. } > MEM
  16. .kinit :
  17. AT(LOADADDR(.stage1) + SIZEOF(.stage1))
  18. {
  19. __kinit_start = .;
  20. *(.text.kinit)
  21. LONG(0x00000000)
  22. LONG(0x19191919)
  23. LONG(0x00000000)
  24. *(.rodata.kinit)
  25. . = ALIGN(16);
  26. start_ctors = .;
  27. KEEP(*(.init_array));
  28. KEEP(*(SORT_BY_INIT_PRIORITY(.init_array*)));
  29. KEEP(*(.ctors));
  30. KEEP(*(SORT_BY_INIT_PRIORITY(.ctors*)));
  31. end_ctors = .;
  32. LONG(0x00000000)
  33. LONG(0x19191919)
  34. LONG(0x00000000)
  35. *(.data.kinit)
  36. LONG(0x00000000)
  37. LONG(0x19191919)
  38. LONG(0x00000000)
  39. *(.bss.kinit)
  40. LONG(0x00000000)
  41. LONG(0x19191919)
  42. LONG(0x00000000)
  43. . = ALIGN(0x1000);
  44. __kinit_end = .;
  45. } > MEM
  46. .text 0xc0000000 :
  47. AT(LOADADDR(.kinit) + SIZEOF(.kinit))
  48. {
  49. __text_start = .;
  50. *(.text)
  51. *(.text*)
  52. . = ALIGN(0x1000);
  53. __text_end = .;
  54. } > MEM
  55. .rodata :
  56. AT(LOADADDR(.text) + SIZEOF(.text))
  57. {
  58. __rodata_start = .;
  59. *(.rodata)
  60. *(.rodata*)
  61. . = ALIGN(16);
  62. kmod_loaders_start = .;
  63. *(.kmods)
  64. __kmod_loaders_end = .;
  65. LONG(0);
  66. . = ALIGN(16);
  67. bss_addr = .;
  68. LONG(ABSOLUTE(__bss_start));
  69. bss_len = .;
  70. LONG(__bss_end - __bss_start);
  71. kernel_size = .;
  72. LONG(__data_end - __kinit_start);
  73. . = ALIGN(0x1000);
  74. __rodata_end = .;
  75. } > MEM
  76. .data :
  77. AT(LOADADDR(.rodata) + SIZEOF(.rodata))
  78. {
  79. __data_start = .;
  80. *(.data)
  81. *(.data*)
  82. . = ALIGN(0x1000);
  83. __data_end = .;
  84. } > MEM
  85. .bss :
  86. {
  87. __bss_start = .;
  88. *(.bss)
  89. *(.bss*)
  90. . = ALIGN(0x1000);
  91. __bss_end = .;
  92. } > MEM
  93. .sentry :
  94. AT(0x50000)
  95. { LONG(0x01145140); } > MEM
  96. .eh_frame :
  97. AT(LOADADDR(.sentry) + SIZEOF(.sentry))
  98. {
  99. __eh_frame_start = .;
  100. *(.eh_frame*)
  101. . = ALIGN(0x1000);
  102. __eh_frame_end = .;
  103. } > MEM
  104. /* Stabs debugging sections. */
  105. .stab 0 : { *(.stab) }
  106. .stabstr 0 : { *(.stabstr) }
  107. .stab.excl 0 : { *(.stab.excl) }
  108. .stab.exclstr 0 : { *(.stab.exclstr) }
  109. .stab.index 0 : { *(.stab.index) }
  110. .stab.indexstr 0 : { *(.stab.indexstr) }
  111. .comment 0 : { *(.comment) }
  112. /* DWARF debug sections.
  113. Symbols in the DWARF debugging sections are relative to the beginning
  114. of the section so we begin them at 0. */
  115. /* DWARF 1 */
  116. .debug 0 : { *(.debug) }
  117. .line 0 : { *(.line) }
  118. /* GNU DWARF 1 extensions */
  119. .debug_srcinfo 0 : { *(.debug_srcinfo) }
  120. .debug_sfnames 0 : { *(.debug_sfnames) }
  121. /* DWARF 1.1 and DWARF 2 */
  122. .debug_aranges 0 : { *(.debug_aranges) }
  123. .debug_pubnames 0 : { *(.debug_pubnames) }
  124. /* DWARF 2 */
  125. .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
  126. .debug_abbrev 0 : { *(.debug_abbrev) }
  127. .debug_line 0 : { *(.debug_line) }
  128. .debug_frame 0 : { *(.debug_frame) }
  129. .debug_str 0 : { *(.debug_str) }
  130. .debug_loc 0 : { *(.debug_loc) }
  131. .debug_macinfo 0 : { *(.debug_macinfo) }
  132. /* SGI/MIPS DWARF 2 extensions */
  133. .debug_weaknames 0 : { *(.debug_weaknames) }
  134. .debug_funcnames 0 : { *(.debug_funcnames) }
  135. .debug_typenames 0 : { *(.debug_typenames) }
  136. .debug_varnames 0 : { *(.debug_varnames) }
  137. /DISCARD/ :
  138. {
  139. *(.fini_array*)
  140. *(.note*)
  141. *(.dtors*)
  142. }
  143. }