vmlinux.lds.S 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /*
  2. * ld script for the x86 kernel
  3. *
  4. * Historic 32-bit version written by Martin Mares <mj@atrey.karlin.mff.cuni.cz>
  5. *
  6. * Modernisation and unification done by Sam Ravnborg <sam@ravnborg.org>
  7. *
  8. *
  9. * Don't define absolute symbols until and unless you know that symbol
  10. * value is should remain constant even if kernel image is relocated
  11. * at run time. Absolute symbols are not relocated. If symbol value should
  12. * change if kernel is relocated, make the symbol section relative and
  13. * put it inside the section definition.
  14. */
  15. #ifdef CONFIG_X86_32
  16. #define LOAD_OFFSET __PAGE_OFFSET
  17. #else
  18. #define LOAD_OFFSET __START_KERNEL_map
  19. #endif
  20. #include <asm-generic/vmlinux.lds.h>
  21. #include <asm/asm-offsets.h>
  22. #include <asm/thread_info.h>
  23. #include <asm/page_types.h>
  24. #include <asm/cache.h>
  25. #include <asm/boot.h>
  26. #undef i386 /* in case the preprocessor is a 32bit one */
  27. OUTPUT_FORMAT(CONFIG_OUTPUT_FORMAT, CONFIG_OUTPUT_FORMAT, CONFIG_OUTPUT_FORMAT)
  28. #ifdef CONFIG_X86_32
  29. OUTPUT_ARCH(i386)
  30. ENTRY(phys_startup_32)
  31. jiffies = jiffies_64;
  32. #else
  33. OUTPUT_ARCH(i386:x86-64)
  34. ENTRY(phys_startup_64)
  35. jiffies_64 = jiffies;
  36. #endif
  37. PHDRS {
  38. text PT_LOAD FLAGS(5); /* R_E */
  39. data PT_LOAD FLAGS(7); /* RWE */
  40. #ifdef CONFIG_X86_64
  41. user PT_LOAD FLAGS(7); /* RWE */
  42. data.init PT_LOAD FLAGS(7); /* RWE */
  43. #ifdef CONFIG_SMP
  44. percpu PT_LOAD FLAGS(7); /* RWE */
  45. #endif
  46. data.init2 PT_LOAD FLAGS(7); /* RWE */
  47. #endif
  48. note PT_NOTE FLAGS(0); /* ___ */
  49. }
  50. SECTIONS
  51. {
  52. #ifdef CONFIG_X86_32
  53. . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
  54. phys_startup_32 = startup_32 - LOAD_OFFSET;
  55. #else
  56. . = __START_KERNEL;
  57. phys_startup_64 = startup_64 - LOAD_OFFSET;
  58. #endif
  59. /* Text and read-only data */
  60. /* bootstrapping code */
  61. .text.head : AT(ADDR(.text.head) - LOAD_OFFSET) {
  62. _text = .;
  63. *(.text.head)
  64. } :text = 0x9090
  65. /* The rest of the text */
  66. .text : AT(ADDR(.text) - LOAD_OFFSET) {
  67. #ifdef CONFIG_X86_32
  68. /* not really needed, already page aligned */
  69. . = ALIGN(PAGE_SIZE);
  70. *(.text.page_aligned)
  71. #endif
  72. . = ALIGN(8);
  73. _stext = .;
  74. TEXT_TEXT
  75. SCHED_TEXT
  76. LOCK_TEXT
  77. KPROBES_TEXT
  78. IRQENTRY_TEXT
  79. *(.fixup)
  80. *(.gnu.warning)
  81. /* End of text section */
  82. _etext = .;
  83. } :text = 0x9090
  84. NOTES :text :note
  85. /* Exception table */
  86. . = ALIGN(16);
  87. __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {
  88. __start___ex_table = .;
  89. *(__ex_table)
  90. __stop___ex_table = .;
  91. } :text = 0x9090
  92. RODATA
  93. #ifdef CONFIG_X86_32
  94. # include "vmlinux_32.lds.S"
  95. #else
  96. # include "vmlinux_64.lds.S"
  97. #endif
  98. STABS_DEBUG
  99. DWARF_DEBUG
  100. }
  101. #ifdef CONFIG_X86_32
  102. ASSERT((_end - LOAD_OFFSET <= KERNEL_IMAGE_SIZE),
  103. "kernel image bigger than KERNEL_IMAGE_SIZE")
  104. #else
  105. /*
  106. * Per-cpu symbols which need to be offset from __per_cpu_load
  107. * for the boot processor.
  108. */
  109. #define INIT_PER_CPU(x) init_per_cpu__##x = per_cpu__##x + __per_cpu_load
  110. INIT_PER_CPU(gdt_page);
  111. INIT_PER_CPU(irq_stack_union);
  112. /*
  113. * Build-time check on the image size:
  114. */
  115. ASSERT((_end - _text <= KERNEL_IMAGE_SIZE),
  116. "kernel image bigger than KERNEL_IMAGE_SIZE")
  117. #ifdef CONFIG_SMP
  118. ASSERT((per_cpu__irq_stack_union == 0),
  119. "irq_stack_union is not at start of per-cpu area");
  120. #endif
  121. #endif /* CONFIG_X86_32 */
  122. #ifdef CONFIG_KEXEC
  123. #include <asm/kexec.h>
  124. ASSERT(kexec_control_code_size <= KEXEC_CONTROL_CODE_MAX_SIZE,
  125. "kexec control code size is too big")
  126. #endif