vmlinux.lds.S 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  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. LOCK_TEXT
  56. KPROBES_TEXT
  57. IRQENTRY_TEXT
  58. SOFTIRQENTRY_TEXT
  59. *(.fixup)
  60. *(.gnu.warning)
  61. . = ALIGN(16);
  62. *(.got) /* Global offset table */
  63. } :text = 0
  64. _etext = .; /* End of text section */
  65. EXCEPTION_TABLE(16)
  66. /* Exception table for data bus errors */
  67. __dbe_table : {
  68. __start___dbe_table = .;
  69. KEEP(*(__dbe_table))
  70. __stop___dbe_table = .;
  71. }
  72. _sdata = .; /* Start of data section */
  73. RO_DATA(4096)
  74. /* writeable */
  75. .data : { /* Data */
  76. . = . + DATAOFFSET; /* for CONFIG_MAPPED_KERNEL */
  77. INIT_TASK_DATA(THREAD_SIZE)
  78. NOSAVE_DATA
  79. PAGE_ALIGNED_DATA(PAGE_SIZE)
  80. CACHELINE_ALIGNED_DATA(1 << CONFIG_MIPS_L1_CACHE_SHIFT)
  81. READ_MOSTLY_DATA(1 << CONFIG_MIPS_L1_CACHE_SHIFT)
  82. DATA_DATA
  83. CONSTRUCTORS
  84. }
  85. BUG_TABLE
  86. _gp = . + 0x8000;
  87. .lit8 : {
  88. *(.lit8)
  89. }
  90. .lit4 : {
  91. *(.lit4)
  92. }
  93. /* We want the small data sections together, so single-instruction offsets
  94. can access them all, and initialized data all before uninitialized, so
  95. we can shorten the on-disk segment size. */
  96. .sdata : {
  97. *(.sdata)
  98. }
  99. _edata = .; /* End of data section */
  100. /* will be freed after init */
  101. . = ALIGN(PAGE_SIZE); /* Init code and data */
  102. __init_begin = .;
  103. INIT_TEXT_SECTION(PAGE_SIZE)
  104. INIT_DATA_SECTION(16)
  105. . = ALIGN(4);
  106. .mips.machines.init : AT(ADDR(.mips.machines.init) - LOAD_OFFSET) {
  107. __mips_machines_start = .;
  108. KEEP(*(.mips.machines.init))
  109. __mips_machines_end = .;
  110. }
  111. /* .exit.text is discarded at runtime, not link time, to deal with
  112. * references from .rodata
  113. */
  114. .exit.text : {
  115. EXIT_TEXT
  116. }
  117. .exit.data : {
  118. EXIT_DATA
  119. }
  120. #ifdef CONFIG_SMP
  121. PERCPU_SECTION(1 << CONFIG_MIPS_L1_CACHE_SHIFT)
  122. #endif
  123. .rel.dyn : ALIGN(8) {
  124. *(.rel)
  125. *(.rel*)
  126. }
  127. #ifdef CONFIG_MIPS_ELF_APPENDED_DTB
  128. STRUCT_ALIGN();
  129. .appended_dtb : AT(ADDR(.appended_dtb) - LOAD_OFFSET) {
  130. *(.appended_dtb)
  131. KEEP(*(.appended_dtb))
  132. }
  133. #endif
  134. #ifdef CONFIG_RELOCATABLE
  135. . = ALIGN(4);
  136. .data.reloc : {
  137. _relocation_start = .;
  138. /*
  139. * Space for relocation table
  140. * This needs to be filled so that the
  141. * relocs tool can overwrite the content.
  142. * An invalid value is left at the start of the
  143. * section to abort relocation if the table
  144. * has not been filled in.
  145. */
  146. LONG(0xFFFFFFFF);
  147. FILL(0);
  148. . += CONFIG_RELOCATION_TABLE_SIZE - 4;
  149. _relocation_end = .;
  150. }
  151. #endif
  152. #ifdef CONFIG_MIPS_RAW_APPENDED_DTB
  153. .fill : {
  154. FILL(0);
  155. BYTE(0);
  156. STRUCT_ALIGN();
  157. }
  158. __appended_dtb = .;
  159. /* leave space for appended DTB */
  160. . += 0x100000;
  161. #endif
  162. /*
  163. * Align to 64K in attempt to eliminate holes before the
  164. * .bss..swapper_pg_dir section at the start of .bss. This
  165. * also satisfies PAGE_SIZE alignment as the largest page size
  166. * allowed is 64K.
  167. */
  168. . = ALIGN(0x10000);
  169. __init_end = .;
  170. /* freed after init ends here */
  171. /*
  172. * Force .bss to 64K alignment so that .bss..swapper_pg_dir
  173. * gets that alignment. .sbss should be empty, so there will be
  174. * no holes after __init_end. */
  175. BSS_SECTION(0, 0x10000, 8)
  176. _end = . ;
  177. /* These mark the ABI of the kernel for debuggers. */
  178. .mdebug.abi32 : {
  179. KEEP(*(.mdebug.abi32))
  180. }
  181. .mdebug.abi64 : {
  182. KEEP(*(.mdebug.abi64))
  183. }
  184. /* This is the MIPS specific mdebug section. */
  185. .mdebug : {
  186. *(.mdebug)
  187. }
  188. STABS_DEBUG
  189. DWARF_DEBUG
  190. ELF_DETAILS
  191. /* These must appear regardless of . */
  192. .gptab.sdata : {
  193. *(.gptab.data)
  194. *(.gptab.sdata)
  195. }
  196. .gptab.sbss : {
  197. *(.gptab.bss)
  198. *(.gptab.sbss)
  199. }
  200. /* Sections to be discarded */
  201. DISCARDS
  202. /DISCARD/ : {
  203. /* ABI crap starts here */
  204. *(.MIPS.abiflags)
  205. *(.MIPS.options)
  206. *(.gnu.attributes)
  207. *(.options)
  208. *(.pdr)
  209. *(.reginfo)
  210. }
  211. }