vmlinux.lds.S 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (C) 2012 Regents of the University of California
  4. * Copyright (C) 2017 SiFive
  5. */
  6. #define RO_EXCEPTION_TABLE_ALIGN 4
  7. #define RUNTIME_DISCARD_EXIT
  8. #ifdef CONFIG_XIP_KERNEL
  9. #include "vmlinux-xip.lds.S"
  10. #else
  11. #include <asm/pgtable.h>
  12. #define LOAD_OFFSET KERNEL_LINK_ADDR
  13. #include <asm/vmlinux.lds.h>
  14. #include <asm/page.h>
  15. #include <asm/cache.h>
  16. #include <asm/thread_info.h>
  17. #include <asm/set_memory.h>
  18. #include "image-vars.h"
  19. #include <linux/sizes.h>
  20. OUTPUT_ARCH(riscv)
  21. ENTRY(_start)
  22. jiffies = jiffies_64;
  23. SECTIONS
  24. {
  25. /* Beginning of code and text segment */
  26. . = LOAD_OFFSET;
  27. _start = .;
  28. HEAD_TEXT_SECTION
  29. . = ALIGN(PAGE_SIZE);
  30. .text : {
  31. _text = .;
  32. _stext = .;
  33. TEXT_TEXT
  34. SCHED_TEXT
  35. LOCK_TEXT
  36. KPROBES_TEXT
  37. ENTRY_TEXT
  38. IRQENTRY_TEXT
  39. SOFTIRQENTRY_TEXT
  40. _etext = .;
  41. }
  42. . = ALIGN(SECTION_ALIGN);
  43. __init_begin = .;
  44. __init_text_begin = .;
  45. .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) ALIGN(SECTION_ALIGN) { \
  46. _sinittext = .; \
  47. INIT_TEXT \
  48. _einittext = .; \
  49. }
  50. . = ALIGN(8);
  51. __soc_early_init_table : {
  52. __soc_early_init_table_start = .;
  53. KEEP(*(__soc_early_init_table))
  54. __soc_early_init_table_end = .;
  55. }
  56. __soc_builtin_dtb_table : {
  57. __soc_builtin_dtb_table_start = .;
  58. KEEP(*(__soc_builtin_dtb_table))
  59. __soc_builtin_dtb_table_end = .;
  60. }
  61. /* we have to discard exit text and such at runtime, not link time */
  62. __exittext_begin = .;
  63. .exit.text :
  64. {
  65. EXIT_TEXT
  66. }
  67. __exittext_end = .;
  68. __init_text_end = .;
  69. . = ALIGN(SECTION_ALIGN);
  70. #ifdef CONFIG_EFI
  71. . = ALIGN(PECOFF_SECTION_ALIGNMENT);
  72. __pecoff_text_end = .;
  73. #endif
  74. /* Start of init data section */
  75. __init_data_begin = .;
  76. INIT_DATA_SECTION(16)
  77. .init.pi : {
  78. KEEP(*(.init.pi*))
  79. }
  80. .init.bss : {
  81. KEEP(*(.init.bss*)) /* from the EFI stub */
  82. }
  83. .exit.data :
  84. {
  85. EXIT_DATA
  86. }
  87. PERCPU_SECTION(L1_CACHE_BYTES)
  88. .rel.dyn : {
  89. *(.rel.dyn*)
  90. }
  91. .rela.dyn : ALIGN(8) {
  92. __rela_dyn_start = .;
  93. *(.rela .rela*)
  94. __rela_dyn_end = .;
  95. }
  96. __init_data_end = .;
  97. . = ALIGN(8);
  98. .alternative : {
  99. __alt_start = .;
  100. KEEP(*(.alternative))
  101. __alt_end = .;
  102. }
  103. __init_end = .;
  104. /* Start of data section */
  105. _sdata = .;
  106. RO_DATA(SECTION_ALIGN)
  107. .srodata : {
  108. *(.srodata*)
  109. }
  110. . = ALIGN(SECTION_ALIGN);
  111. _data = .;
  112. RW_DATA(L1_CACHE_BYTES, PAGE_SIZE, THREAD_ALIGN)
  113. .sdata : {
  114. __global_pointer$ = . + 0x800;
  115. *(.sdata*)
  116. }
  117. .got : { *(.got*) }
  118. #ifdef CONFIG_RELOCATABLE
  119. .data.rel : { *(.data.rel*) }
  120. .plt : { *(.plt) }
  121. .dynamic : { *(.dynamic) }
  122. .dynsym : { *(.dynsym) }
  123. .dynstr : { *(.dynstr) }
  124. .hash : { *(.hash) }
  125. .gnu.hash : { *(.gnu.hash) }
  126. #endif
  127. #ifdef CONFIG_EFI
  128. .pecoff_edata_padding : { BYTE(0); . = ALIGN(PECOFF_FILE_ALIGNMENT); }
  129. __pecoff_data_raw_size = ABSOLUTE(. - __pecoff_text_end);
  130. __pecoff_data_raw_end = ABSOLUTE(.);
  131. #endif
  132. /* End of data section */
  133. _edata = .;
  134. BSS_SECTION(PAGE_SIZE, PAGE_SIZE, 0)
  135. #ifdef CONFIG_EFI
  136. . = ALIGN(PECOFF_SECTION_ALIGNMENT);
  137. __pecoff_data_virt_size = ABSOLUTE(. - __pecoff_text_end);
  138. __pecoff_data_virt_end = ABSOLUTE(.);
  139. #endif
  140. _end = .;
  141. STABS_DEBUG
  142. DWARF_DEBUG
  143. ELF_DETAILS
  144. .riscv.attributes 0 : { *(.riscv.attributes) }
  145. DISCARDS
  146. }
  147. #endif /* CONFIG_XIP_KERNEL */