vmlinux.lds.S 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* ld script to make s390 Linux kernel
  3. * Written by Martin Schwidefsky (schwidefsky@de.ibm.com)
  4. */
  5. #include <asm/thread_info.h>
  6. #include <asm/page.h>
  7. #include <asm/ftrace.lds.h>
  8. /*
  9. * Put .bss..swapper_pg_dir as the first thing in .bss. This will
  10. * make sure it has 16k alignment.
  11. */
  12. #define BSS_FIRST_SECTIONS *(.bss..swapper_pg_dir) \
  13. *(.bss..invalid_pg_dir)
  14. #define RO_EXCEPTION_TABLE_ALIGN 16
  15. /* Handle ro_after_init data on our own. */
  16. #define RO_AFTER_INIT_DATA
  17. #define RUNTIME_DISCARD_EXIT
  18. #define EMITS_PT_NOTE
  19. #include <asm-generic/vmlinux.lds.h>
  20. #include <asm/vmlinux.lds.h>
  21. OUTPUT_FORMAT("elf64-s390", "elf64-s390", "elf64-s390")
  22. OUTPUT_ARCH(s390:64-bit)
  23. ENTRY(startup_continue)
  24. jiffies = jiffies_64;
  25. PHDRS {
  26. text PT_LOAD FLAGS(5); /* R_E */
  27. data PT_LOAD FLAGS(7); /* RWE */
  28. note PT_NOTE FLAGS(0); /* ___ */
  29. }
  30. SECTIONS
  31. {
  32. . = TEXT_OFFSET;
  33. .text : {
  34. _stext = .; /* Start of text section */
  35. _text = .; /* Text and read-only data */
  36. HEAD_TEXT
  37. TEXT_TEXT
  38. SCHED_TEXT
  39. LOCK_TEXT
  40. KPROBES_TEXT
  41. IRQENTRY_TEXT
  42. SOFTIRQENTRY_TEXT
  43. FTRACE_HOTPATCH_TRAMPOLINES_TEXT
  44. *(.text.*_indirect_*)
  45. *(.gnu.warning)
  46. . = ALIGN(PAGE_SIZE);
  47. _etext = .; /* End of text section */
  48. } :text = 0x0700
  49. RO_DATA(PAGE_SIZE)
  50. . = ALIGN(PAGE_SIZE);
  51. _sdata = .; /* Start of data section */
  52. . = ALIGN(PAGE_SIZE);
  53. __start_ro_after_init = .;
  54. .data..ro_after_init : {
  55. *(.data..ro_after_init)
  56. JUMP_TABLE_DATA
  57. } :data
  58. . = ALIGN(PAGE_SIZE);
  59. __end_ro_after_init = .;
  60. .data.rel.ro : {
  61. *(.data.rel.ro .data.rel.ro.*)
  62. }
  63. .got : {
  64. __got_start = .;
  65. *(.got)
  66. __got_end = .;
  67. }
  68. RW_DATA(0x100, PAGE_SIZE, THREAD_SIZE)
  69. .data.rel : {
  70. *(.data.rel*)
  71. }
  72. BOOT_DATA_PRESERVED
  73. . = ALIGN(8);
  74. .amode31.refs : {
  75. _start_amode31_refs = .;
  76. *(.amode31.refs)
  77. _end_amode31_refs = .;
  78. }
  79. . = ALIGN(PAGE_SIZE);
  80. _edata = .; /* End of data section */
  81. /* will be freed after init */
  82. . = ALIGN(PAGE_SIZE); /* Init code and data */
  83. __init_begin = .;
  84. . = ALIGN(PAGE_SIZE);
  85. .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) {
  86. _sinittext = .;
  87. INIT_TEXT
  88. . = ALIGN(PAGE_SIZE);
  89. _einittext = .;
  90. }
  91. /*
  92. * .exit.text is discarded at runtime, not link time,
  93. * to deal with references from __bug_table
  94. */
  95. .exit.text : {
  96. EXIT_TEXT
  97. }
  98. .exit.data : {
  99. EXIT_DATA
  100. }
  101. /*
  102. * struct alt_inst entries. From the header (alternative.h):
  103. * "Alternative instructions for different CPU types or capabilities"
  104. * Think locking instructions on spinlocks.
  105. * Note, that it is a part of __init region.
  106. */
  107. . = ALIGN(8);
  108. .altinstructions : {
  109. __alt_instructions = .;
  110. *(.altinstructions)
  111. __alt_instructions_end = .;
  112. }
  113. /*
  114. * And here are the replacement instructions. The linker sticks
  115. * them as binary blobs. The .altinstructions has enough data to
  116. * get the address and the length of them to patch the kernel safely.
  117. * Note, that it is a part of __init region.
  118. */
  119. .altinstr_replacement : {
  120. *(.altinstr_replacement)
  121. }
  122. /*
  123. * Table with the patch locations to undo expolines
  124. */
  125. . = ALIGN(4);
  126. .nospec_call_table : {
  127. __nospec_call_start = . ;
  128. *(.s390_indirect*)
  129. __nospec_call_end = . ;
  130. }
  131. .nospec_return_table : {
  132. __nospec_return_start = . ;
  133. *(.s390_return*)
  134. __nospec_return_end = . ;
  135. }
  136. BOOT_DATA
  137. /*
  138. * .amode31 section for code, data, ex_table that need to stay
  139. * below 2 GB, even when the kernel is relocated above 2 GB.
  140. */
  141. . = ALIGN(PAGE_SIZE);
  142. _samode31 = .;
  143. .amode31.text : {
  144. _stext_amode31 = .;
  145. *(.amode31.text)
  146. *(.amode31.text.*_indirect_*)
  147. . = ALIGN(PAGE_SIZE);
  148. _etext_amode31 = .;
  149. }
  150. . = ALIGN(16);
  151. .amode31.ex_table : {
  152. _start_amode31_ex_table = .;
  153. KEEP(*(.amode31.ex_table))
  154. _stop_amode31_ex_table = .;
  155. }
  156. . = ALIGN(PAGE_SIZE);
  157. .amode31.data : {
  158. *(.amode31.data)
  159. }
  160. . = _samode31 + AMODE31_SIZE;
  161. _eamode31 = .;
  162. /* early.c uses stsi, which requires page aligned data. */
  163. . = ALIGN(PAGE_SIZE);
  164. INIT_DATA_SECTION(0x100)
  165. RUNTIME_CONST_VARIABLES
  166. PERCPU_SECTION(0x100)
  167. . = ALIGN(PAGE_SIZE);
  168. __init_end = .; /* freed after init ends here */
  169. BSS_SECTION(PAGE_SIZE, 4 * PAGE_SIZE, PAGE_SIZE)
  170. . = ALIGN(PAGE_SIZE);
  171. _end = . ;
  172. /* Debugging sections. */
  173. STABS_DEBUG
  174. DWARF_DEBUG
  175. ELF_DETAILS
  176. /*
  177. * Make sure that the .got.plt is either completely empty or it
  178. * contains only the three reserved double words.
  179. */
  180. .got.plt : {
  181. *(.got.plt)
  182. }
  183. ASSERT(SIZEOF(.got.plt) == 0 || SIZEOF(.got.plt) == 0x18, "Unexpected GOT/PLT entries detected!")
  184. /*
  185. * Sections that should stay zero sized, which is safer to
  186. * explicitly check instead of blindly discarding.
  187. */
  188. .plt : {
  189. *(.plt) *(.plt.*) *(.iplt) *(.igot .igot.plt)
  190. }
  191. ASSERT(SIZEOF(.plt) == 0, "Unexpected run-time procedure linkages detected!")
  192. .rela.dyn : {
  193. *(.rela.*) *(.rela_*)
  194. }
  195. ASSERT(SIZEOF(.rela.dyn) == 0, "Unexpected run-time relocations (.rela) detected!")
  196. /*
  197. * uncompressed image info used by the decompressor
  198. * it should match struct vmlinux_info
  199. */
  200. .vmlinux.info 0 (INFO) : {
  201. QUAD(startup_continue) /* entry */
  202. QUAD(__bss_start - _stext) /* image_size */
  203. QUAD(__bss_stop - __bss_start) /* bss_size */
  204. QUAD(__boot_data_start) /* bootdata_off */
  205. QUAD(__boot_data_end - __boot_data_start) /* bootdata_size */
  206. QUAD(__boot_data_preserved_start) /* bootdata_preserved_off */
  207. QUAD(__boot_data_preserved_end -
  208. __boot_data_preserved_start) /* bootdata_preserved_size */
  209. QUAD(__got_start) /* got_start */
  210. QUAD(__got_end) /* got_end */
  211. QUAD(_eamode31 - _samode31) /* amode31_size */
  212. QUAD(init_mm)
  213. QUAD(swapper_pg_dir)
  214. QUAD(invalid_pg_dir)
  215. QUAD(__alt_instructions)
  216. QUAD(__alt_instructions_end)
  217. #ifdef CONFIG_KASAN
  218. QUAD(kasan_early_shadow_page)
  219. QUAD(kasan_early_shadow_pte)
  220. QUAD(kasan_early_shadow_pmd)
  221. QUAD(kasan_early_shadow_pud)
  222. QUAD(kasan_early_shadow_p4d)
  223. #endif
  224. } :NONE
  225. /* Sections to be discarded */
  226. DISCARDS
  227. /DISCARD/ : {
  228. *(.eh_frame)
  229. *(.interp)
  230. }
  231. }