x15.lds.S 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. #ifdef __LP64__
  2. OUTPUT_FORMAT ("elf64-x86-64")
  3. OUTPUT_ARCH (i386:x86-64)
  4. #else
  5. OUTPUT_FORMAT ("elf32-i386")
  6. OUTPUT_ARCH (i386)
  7. #endif
  8. ENTRY (boot_start)
  9. #include <kern/init.h>
  10. #include <machine/boot.h>
  11. #include <machine/cpu.h>
  12. #include <machine/page.h>
  13. #include <machine/pmap.h>
  14. PHDRS
  15. {
  16. // Flags are actually similar to classic Unix permissions.
  17. boot PT_LOAD FLAGS (7);
  18. init PT_LOAD FLAGS (7);
  19. percpu PT_LOAD FLAGS (6);
  20. text PT_LOAD FLAGS (5);
  21. rodata PT_LOAD FLAGS (4);
  22. data PT_LOAD FLAGS (6);
  23. unwind PT_LOAD FLAGS (4);
  24. #ifdef CONFIG_SYMTAB
  25. symbol PT_LOAD FLAGS (4);
  26. #endif
  27. }
  28. SECTIONS
  29. {
  30. . = BOOT_OFFSET;
  31. _boot = .;
  32. .boot ALIGN (PAGE_SIZE) :
  33. {
  34. *(.boot.hdr)
  35. *(.boot.text)
  36. *(.boot.data)
  37. } : boot
  38. . = ALIGN (PAGE_SIZE);
  39. _boot_end = .;
  40. . += PMAP_KERNEL_OFFSET;
  41. _init = .;
  42. .init ALIGN (PAGE_SIZE) : AT (BOOT_VTOP (ADDR (.init)))
  43. {
  44. *(.init.text)
  45. *(.init.data)
  46. . = ALIGN (INIT_OP_ALIGN);
  47. _init_ops = .;
  48. *(.init.ops)
  49. _init_ops_end = .;
  50. } : init
  51. . = ALIGN (PAGE_SIZE);
  52. _init_end = .;
  53. _percpu = .;
  54. .percpu 0 : AT (BOOT_VTOP (_percpu))
  55. {
  56. *(.percpu*)
  57. } : percpu
  58. . = _percpu + SIZEOF (.percpu);
  59. . = ALIGN (PAGE_SIZE);
  60. _percpu_end = .;
  61. _text = .;
  62. .text ALIGN (PAGE_SIZE) : AT (BOOT_VTOP (ADDR (.text)))
  63. {
  64. *(.text*)
  65. } : text
  66. . = ALIGN (PAGE_SIZE);
  67. _rodata = .;
  68. .rodata ALIGN (PAGE_SIZE) : AT (BOOT_VTOP (ADDR (.rodata)))
  69. {
  70. *(.rodata*)
  71. } : rodata
  72. . = ALIGN (PAGE_SIZE);
  73. _data = .;
  74. .data ALIGN (PAGE_SIZE) : AT (BOOT_VTOP (ADDR (.data)))
  75. {
  76. . = ALIGN (CPU_L1_SIZE);
  77. *(.data.read_mostly)
  78. . = ALIGN (CPU_L1_SIZE);
  79. *(.data*)
  80. } : data
  81. .bss ALIGN (CPU_DATA_ALIGN) : AT (BOOT_VTOP (ADDR (.bss)))
  82. {
  83. *(.bss*)
  84. } : data
  85. /*
  86. * Including the dynamic tables (unwind and symbol) last should reliably
  87. * prevent the second link from changing the addresses of the kernel symbols.
  88. *
  89. * In addition, use a program header different from data to make
  90. * sure the linker doesn't include the .bss section in the output file.
  91. */
  92. .unwind ALIGN (PAGE_SIZE) : AT (BOOT_VTOP (ADDR (.unwind)))
  93. {
  94. *(.unwind*)
  95. } : unwind
  96. #ifdef CONFIG_SYMTAB
  97. .symbol ALIGN (PAGE_SIZE) : AT (BOOT_VTOP (ADDR (.symbol)))
  98. {
  99. *(.symbol*)
  100. } : symbol
  101. #endif
  102. . = ALIGN (PAGE_SIZE);
  103. _end = .;
  104. /DISCARD/ :
  105. {
  106. *(.note*)
  107. }
  108. }