vmlinux.lds.S 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #include <asm/asm-offsets.h>
  3. #include <asm/thread_info.h>
  4. #define PAGE_SIZE _PAGE_SIZE
  5. /*
  6. * Put .bss..swapper_pg_dir as the first thing in .bss. This will
  7. * ensure that it has .bss alignment (64K).
  8. */
  9. #define BSS_FIRST_SECTIONS *(.bss..swapper_pg_dir)
  10. /* Cavium Octeon should not have a separate PT_NOTE Program Header. */
  11. #ifndef CONFIG_CAVIUM_OCTEON_SOC
  12. #define EMITS_PT_NOTE
  13. #endif
  14. #define RUNTIME_DISCARD_EXIT
  15. #include <asm-generic/vmlinux.lds.h>
  16. #undef mips
  17. #define mips mips
  18. OUTPUT_ARCH(mips)
  19. ENTRY(kernel_entry)
  20. PHDRS {
  21. text PT_LOAD FLAGS(7); /* RWX */
  22. #ifndef CONFIG_CAVIUM_OCTEON_SOC
  23. note PT_NOTE FLAGS(4); /* R__ */
  24. #endif /* CAVIUM_OCTEON_SOC */
  25. }
  26. #ifdef CONFIG_32BIT
  27. #ifdef CONFIG_CPU_LITTLE_ENDIAN
  28. jiffies = jiffies_64;
  29. #else
  30. jiffies = jiffies_64 + 4;
  31. #endif
  32. #else
  33. jiffies = jiffies_64;
  34. #endif
  35. SECTIONS
  36. {
  37. #ifdef CONFIG_BOOT_ELF64
  38. /* Read-only sections, merged into text segment: */
  39. /* . = 0xc000000000000000; */
  40. /* This is the value for an Origin kernel, taken from an IRIX kernel. */
  41. /* . = 0xc00000000001c000; */
  42. /* Set the vaddr for the text segment to a value
  43. * >= 0xa800 0000 0001 9000 if no symmon is going to configured
  44. * >= 0xa800 0000 0030 0000 otherwise
  45. */
  46. /* . = 0xa800000000300000; */
  47. . = 0xffffffff80300000;
  48. #endif
  49. . = LINKER_LOAD_ADDRESS;
  50. /* read-only */
  51. _text = .; /* Text and read-only data */
  52. .text : {
  53. TEXT_TEXT
  54. SCHED_TEXT
  55. CPUIDLE_TEXT
  56. LOCK_TEXT
  57. KPROBES_TEXT
  58. IRQENTRY_TEXT
  59. SOFTIRQENTRY_TEXT
  60. *(.fixup)
  61. *(.gnu.warning)
  62. . = ALIGN(16);
  63. *(.got) /* Global offset table */
  64. } :text = 0
  65. _etext = .; /* End of text section */
  66. EXCEPTION_TABLE(16)
  67. /* Exception table for data bus errors */
  68. __dbe_table : {
  69. __start___dbe_table = .;
  70. KEEP(*(__dbe_table))
  71. __stop___dbe_table = .;
  72. }
  73. _sdata = .; /* Start of data section */
  74. RO_DATA(4096)
  75. /* writeable */
  76. .data : { /* Data */
  77. . = . + DATAOFFSET; /* for CONFIG_MAPPED_KERNEL */
  78. INIT_TASK_DATA(THREAD_SIZE)
  79. NOSAVE_DATA
  80. PAGE_ALIGNED_DATA(PAGE_SIZE)
  81. CACHELINE_ALIGNED_DATA(1 << CONFIG_MIPS_L1_CACHE_SHIFT)
  82. READ_MOSTLY_DATA(1 << CONFIG_MIPS_L1_CACHE_SHIFT)
  83. DATA_DATA
  84. CONSTRUCTORS
  85. }
  86. BUG_TABLE
  87. _gp = . + 0x8000;
  88. .lit8 : {
  89. *(.lit8)
  90. }
  91. .lit4 : {
  92. *(.lit4)
  93. }
  94. /* We want the small data sections together, so single-instruction offsets
  95. can access them all, and initialized data all before uninitialized, so
  96. we can shorten the on-disk segment size. */
  97. .sdata : {
  98. *(.sdata)
  99. }
  100. _edata = .; /* End of data section */
  101. /* will be freed after init */
  102. . = ALIGN(PAGE_SIZE); /* Init code and data */
  103. __init_begin = .;
  104. INIT_TEXT_SECTION(PAGE_SIZE)
  105. INIT_DATA_SECTION(16)
  106. . = ALIGN(4);
  107. .mips.machines.init : AT(ADDR(.mips.machines.init) - LOAD_OFFSET) {
  108. __mips_machines_start = .;
  109. KEEP(*(.mips.machines.init))
  110. __mips_machines_end = .;
  111. }
  112. /* .exit.text is discarded at runtime, not link time, to deal with
  113. * references from .rodata
  114. */
  115. .exit.text : {
  116. EXIT_TEXT
  117. }
  118. .exit.data : {
  119. EXIT_DATA
  120. }
  121. #ifdef CONFIG_SMP
  122. PERCPU_SECTION(1 << CONFIG_MIPS_L1_CACHE_SHIFT)
  123. #endif
  124. .rel.dyn : ALIGN(8) {
  125. *(.rel)
  126. *(.rel*)
  127. }
  128. #ifdef CONFIG_MIPS_ELF_APPENDED_DTB
  129. STRUCT_ALIGN();
  130. .appended_dtb : AT(ADDR(.appended_dtb) - LOAD_OFFSET) {
  131. *(.appended_dtb)
  132. KEEP(*(.appended_dtb))
  133. }
  134. #endif
  135. #ifdef CONFIG_RELOCATABLE
  136. . = ALIGN(4);
  137. .data.reloc : {
  138. _relocation_start = .;
  139. /*
  140. * Space for relocation table
  141. * This needs to be filled so that the
  142. * relocs tool can overwrite the content.
  143. * An invalid value is left at the start of the
  144. * section to abort relocation if the table
  145. * has not been filled in.
  146. */
  147. LONG(0xFFFFFFFF);
  148. FILL(0);
  149. . += CONFIG_RELOCATION_TABLE_SIZE - 4;
  150. _relocation_end = .;
  151. }
  152. #endif
  153. #ifdef CONFIG_MIPS_RAW_APPENDED_DTB
  154. .fill : {
  155. FILL(0);
  156. BYTE(0);
  157. STRUCT_ALIGN();
  158. }
  159. __appended_dtb = .;
  160. /* leave space for appended DTB */
  161. . += 0x100000;
  162. #endif
  163. /*
  164. * Align to 64K in attempt to eliminate holes before the
  165. * .bss..swapper_pg_dir section at the start of .bss. This
  166. * also satisfies PAGE_SIZE alignment as the largest page size
  167. * allowed is 64K.
  168. */
  169. . = ALIGN(0x10000);
  170. __init_end = .;
  171. /* freed after init ends here */
  172. /*
  173. * Force .bss to 64K alignment so that .bss..swapper_pg_dir
  174. * gets that alignment. .sbss should be empty, so there will be
  175. * no holes after __init_end. */
  176. BSS_SECTION(0, 0x10000, 8)
  177. _end = . ;
  178. /* These mark the ABI of the kernel for debuggers. */
  179. .mdebug.abi32 : {
  180. KEEP(*(.mdebug.abi32))
  181. }
  182. .mdebug.abi64 : {
  183. KEEP(*(.mdebug.abi64))
  184. }
  185. /* This is the MIPS specific mdebug section. */
  186. .mdebug : {
  187. *(.mdebug)
  188. }
  189. STABS_DEBUG
  190. DWARF_DEBUG
  191. ELF_DETAILS
  192. /* These must appear regardless of . */
  193. .gptab.sdata : {
  194. *(.gptab.data)
  195. *(.gptab.sdata)
  196. }
  197. .gptab.sbss : {
  198. *(.gptab.bss)
  199. *(.gptab.sbss)
  200. }
  201. /* Sections to be discarded */
  202. DISCARDS
  203. /DISCARD/ : {
  204. /* ABI crap starts here */
  205. *(.MIPS.abiflags)
  206. *(.MIPS.options)
  207. *(.gnu.attributes)
  208. *(.options)
  209. *(.pdr)
  210. *(.reginfo)
  211. }
  212. }