riscv: Check if the code to patch lies in the exit section
[linux-2.6-block.git] / arch / riscv / kernel / vmlinux.lds.S
CommitLineData
50acfb2b 1/* SPDX-License-Identifier: GPL-2.0-only */
fbe934d6
PD
2/*
3 * Copyright (C) 2012 Regents of the University of California
4 * Copyright (C) 2017 SiFive
fbe934d6
PD
5 */
6
2bf847db 7#define RO_EXCEPTION_TABLE_ALIGN 4
7e92586c 8#define RUNTIME_DISCARD_EXIT
6f55ab36 9
44c92257
VW
10#ifdef CONFIG_XIP_KERNEL
11#include "vmlinux-xip.lds.S"
12#else
13
2bfc6cd8
AG
14#include <asm/pgtable.h>
15#define LOAD_OFFSET KERNEL_LINK_ADDR
44c92257 16
fbe934d6
PD
17#include <asm/vmlinux.lds.h>
18#include <asm/page.h>
19#include <asm/cache.h>
20#include <asm/thread_info.h>
00cb41d5 21#include <asm/set_memory.h>
cb7d2dd5 22#include "image-vars.h"
fbe934d6 23
e011995e 24#include <linux/sizes.h>
fbe934d6
PD
25OUTPUT_ARCH(riscv)
26ENTRY(_start)
27
28jiffies = jiffies_64;
29
30SECTIONS
31{
32 /* Beginning of code and text segment */
33 . = LOAD_OFFSET;
34 _start = .;
fbe934d6 35 HEAD_TEXT_SECTION
e011995e
AP
36 . = ALIGN(PAGE_SIZE);
37
19a00869
AP
38 .text : {
39 _text = .;
40 _stext = .;
41 TEXT_TEXT
42 SCHED_TEXT
19a00869
AP
43 LOCK_TEXT
44 KPROBES_TEXT
45 ENTRY_TEXT
46 IRQENTRY_TEXT
47 SOFTIRQENTRY_TEXT
19a00869
AP
48 _etext = .;
49 }
50
51 . = ALIGN(SECTION_ALIGN);
e011995e 52 __init_begin = .;
b6566dc1
AP
53 __init_text_begin = .;
54 .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) ALIGN(SECTION_ALIGN) { \
55 _sinittext = .; \
56 INIT_TEXT \
57 _einittext = .; \
58 }
59
335b1390
DLM
60 . = ALIGN(8);
61 __soc_early_init_table : {
62 __soc_early_init_table_start = .;
63 KEEP(*(__soc_early_init_table))
64 __soc_early_init_table_end = .;
65 }
2d268251
PD
66 __soc_builtin_dtb_table : {
67 __soc_builtin_dtb_table_start = .;
68 KEEP(*(__soc_builtin_dtb_table))
69 __soc_builtin_dtb_table_end = .;
70 }
fbe934d6 71 /* we have to discard exit text and such at runtime, not link time */
420370f3 72 __exittext_begin = .;
fbe934d6
PD
73 .exit.text :
74 {
75 EXIT_TEXT
76 }
420370f3 77 __exittext_end = .;
fbe934d6 78
19a00869 79 __init_text_end = .;
00cb41d5 80 . = ALIGN(SECTION_ALIGN);
cb7d2dd5
AP
81#ifdef CONFIG_EFI
82 . = ALIGN(PECOFF_SECTION_ALIGNMENT);
83 __pecoff_text_end = .;
84#endif
19a00869
AP
85 /* Start of init data section */
86 __init_data_begin = .;
84814460 87 INIT_DATA_SECTION(16)
26e7aacb 88
3b90b09a 89 .init.pi : {
c828856b 90 KEEP(*(.init.pi*))
26e7aacb
AG
91 }
92
0ed0031b 93 .init.bss : {
c828856b 94 KEEP(*(.init.bss*)) /* from the EFI stub */
0ed0031b 95 }
19a00869
AP
96 .exit.data :
97 {
98 EXIT_DATA
99 }
100 PERCPU_SECTION(L1_CACHE_BYTES)
101
b5b11a8a
AP
102 .rel.dyn : {
103 *(.rel.dyn*)
104 }
105
4db9e253
AG
106 .rela.dyn : ALIGN(8) {
107 __rela_dyn_start = .;
108 *(.rela .rela*)
109 __rela_dyn_end = .;
110 }
111
19a00869 112 __init_data_end = .;
6f4eea90
VC
113
114 . = ALIGN(8);
115 .alternative : {
116 __alt_start = .;
c828856b 117 KEEP(*(.alternative))
6f4eea90
VC
118 __alt_end = .;
119 }
19a00869 120 __init_end = .;
84814460 121
fbe934d6
PD
122 /* Start of data section */
123 _sdata = .;
00cb41d5 124 RO_DATA(SECTION_ALIGN)
fbe934d6
PD
125 .srodata : {
126 *(.srodata*)
127 }
128
00cb41d5 129 . = ALIGN(SECTION_ALIGN);
bd3d914d
ZL
130 _data = .;
131
31da94c2 132 RW_DATA(L1_CACHE_BYTES, PAGE_SIZE, THREAD_ALIGN)
fbe934d6
PD
133 .sdata : {
134 __global_pointer$ = . + 0x800;
135 *(.sdata*)
fbe934d6
PD
136 }
137
26e7aacb
AG
138 .got : { *(.got*) }
139
39b33072
AG
140#ifdef CONFIG_RELOCATABLE
141 .data.rel : { *(.data.rel*) }
39b33072
AG
142 .plt : { *(.plt) }
143 .dynamic : { *(.dynamic) }
144 .dynsym : { *(.dynsym) }
145 .dynstr : { *(.dynstr) }
146 .hash : { *(.hash) }
147 .gnu.hash : { *(.gnu.hash) }
148#endif
149
cb7d2dd5
AP
150#ifdef CONFIG_EFI
151 .pecoff_edata_padding : { BYTE(0); . = ALIGN(PECOFF_FILE_ALIGNMENT); }
152 __pecoff_data_raw_size = ABSOLUTE(. - __pecoff_text_end);
55de1e4a 153 __pecoff_data_raw_end = ABSOLUTE(.);
cb7d2dd5
AP
154#endif
155
156 /* End of data section */
157 _edata = .;
158
41fb9d54
PD
159 BSS_SECTION(PAGE_SIZE, PAGE_SIZE, 0)
160
cb7d2dd5
AP
161#ifdef CONFIG_EFI
162 . = ALIGN(PECOFF_SECTION_ALIGNMENT);
163 __pecoff_data_virt_size = ABSOLUTE(. - __pecoff_text_end);
55de1e4a 164 __pecoff_data_virt_end = ABSOLUTE(.);
cb7d2dd5 165#endif
fbe934d6
PD
166 _end = .;
167
168 STABS_DEBUG
169 DWARF_DEBUG
c604abc3 170 ELF_DETAILS
b13e64d9 171 .riscv.attributes 0 : { *(.riscv.attributes) }
fbe934d6
PD
172
173 DISCARDS
174}
44c92257 175#endif /* CONFIG_XIP_KERNEL */