]>
Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
8c2c3df3 CM |
2 | /* |
3 | * ld script to make ARM Linux kernel | |
4 | * taken from the i386 version by Russell King | |
5 | * Written by Martin Mares <mj@atrey.karlin.mff.cuni.cz> | |
6 | */ | |
7 | ||
19f6bc32 KC |
8 | #define RO_EXCEPTION_TABLE_ALIGN 8 |
9 | ||
8c2c3df3 | 10 | #include <asm-generic/vmlinux.lds.h> |
98fb7548 | 11 | #include <asm/cache.h> |
87d1587b | 12 | #include <asm/kernel-pgtable.h> |
8c2c3df3 CM |
13 | #include <asm/thread_info.h> |
14 | #include <asm/memory.h> | |
15 | #include <asm/page.h> | |
16 | ||
a2c1d73b MR |
17 | #include "image.h" |
18 | ||
8c2c3df3 | 19 | OUTPUT_ARCH(aarch64) |
af885f40 | 20 | ENTRY(_text) |
8c2c3df3 CM |
21 | |
22 | jiffies = jiffies_64; | |
23 | ||
2240bbb6 MZ |
24 | #define HYPERVISOR_TEXT \ |
25 | /* \ | |
06f75a1f AB |
26 | * Align to 4 KB so that \ |
27 | * a) the HYP vector table is at its minimum \ | |
28 | * alignment of 2048 bytes \ | |
29 | * b) the HYP init code will not cross a page \ | |
30 | * boundary if its size does not exceed \ | |
31 | * 4 KB (see related ASSERT() below) \ | |
2240bbb6 | 32 | */ \ |
06f75a1f | 33 | . = ALIGN(SZ_4K); \ |
5c636aa0 | 34 | __hyp_idmap_text_start = .; \ |
2240bbb6 | 35 | *(.hyp.idmap.text) \ |
5c636aa0 MY |
36 | __hyp_idmap_text_end = .; \ |
37 | __hyp_text_start = .; \ | |
2240bbb6 | 38 | *(.hyp.text) \ |
5c636aa0 | 39 | __hyp_text_end = .; |
2240bbb6 | 40 | |
5dfe9d7d AB |
41 | #define IDMAP_TEXT \ |
42 | . = ALIGN(SZ_4K); \ | |
5c636aa0 | 43 | __idmap_text_start = .; \ |
5dfe9d7d | 44 | *(.idmap.text) \ |
5c636aa0 | 45 | __idmap_text_end = .; |
5dfe9d7d | 46 | |
82869ac5 JM |
47 | #ifdef CONFIG_HIBERNATION |
48 | #define HIBERNATE_TEXT \ | |
49 | . = ALIGN(SZ_4K); \ | |
5c636aa0 | 50 | __hibernate_exit_text_start = .; \ |
82869ac5 | 51 | *(.hibernate_exit.text) \ |
5c636aa0 | 52 | __hibernate_exit_text_end = .; |
82869ac5 JM |
53 | #else |
54 | #define HIBERNATE_TEXT | |
55 | #endif | |
56 | ||
c7b9adaf WD |
57 | #ifdef CONFIG_UNMAP_KERNEL_AT_EL0 |
58 | #define TRAMP_TEXT \ | |
59 | . = ALIGN(PAGE_SIZE); \ | |
5c636aa0 | 60 | __entry_tramp_text_start = .; \ |
c7b9adaf WD |
61 | *(.entry.tramp.text) \ |
62 | . = ALIGN(PAGE_SIZE); \ | |
5c636aa0 | 63 | __entry_tramp_text_end = .; |
c7b9adaf WD |
64 | #else |
65 | #define TRAMP_TEXT | |
66 | #endif | |
67 | ||
a352ea3e AB |
68 | /* |
69 | * The size of the PE/COFF section that covers the kernel image, which | |
348a625d AB |
70 | * runs from _stext to _edata, must be a round multiple of the PE/COFF |
71 | * FileAlignment, which we set to its minimum value of 0x200. '_stext' | |
a352ea3e AB |
72 | * itself is 4 KB aligned, so padding out _edata to a 0x200 aligned |
73 | * boundary should be sufficient. | |
74 | */ | |
75 | PECOFF_FILE_ALIGNMENT = 0x200; | |
76 | ||
77 | #ifdef CONFIG_EFI | |
78 | #define PECOFF_EDATA_PADDING \ | |
79 | .pecoff_edata_padding : { BYTE(0); . = ALIGN(PECOFF_FILE_ALIGNMENT); } | |
80 | #else | |
81 | #define PECOFF_EDATA_PADDING | |
82 | #endif | |
83 | ||
8c2c3df3 CM |
84 | SECTIONS |
85 | { | |
86 | /* | |
87 | * XXX: The linker does not define how output sections are | |
88 | * assigned to input sections when there are multiple statements | |
89 | * matching the same input section name. There is no documented | |
90 | * order of matching. | |
91 | */ | |
92 | /DISCARD/ : { | |
8c2c3df3 CM |
93 | EXIT_CALL |
94 | *(.discard) | |
95 | *(.discard.*) | |
1e48ef7f | 96 | *(.interp .dynamic) |
3bbd3db8 AB |
97 | *(.dynsym .dynstr .hash .gnu.hash) |
98 | *(.eh_frame) | |
8c2c3df3 CM |
99 | } |
100 | ||
ab893fb9 | 101 | . = KIMAGE_VADDR + TEXT_OFFSET; |
8c2c3df3 CM |
102 | |
103 | .head.text : { | |
104 | _text = .; | |
105 | HEAD_TEXT | |
106 | } | |
107 | .text : { /* Real text segment */ | |
108 | _stext = .; /* Text and read-only data */ | |
8c2c3df3 | 109 | IRQENTRY_TEXT |
be7635e7 | 110 | SOFTIRQENTRY_TEXT |
888b3c87 | 111 | ENTRY_TEXT |
8c2c3df3 CM |
112 | TEXT_TEXT |
113 | SCHED_TEXT | |
6727ad9e | 114 | CPUIDLE_TEXT |
8c2c3df3 | 115 | LOCK_TEXT |
2dd0e8d2 | 116 | KPROBES_TEXT |
2240bbb6 | 117 | HYPERVISOR_TEXT |
5dfe9d7d | 118 | IDMAP_TEXT |
82869ac5 | 119 | HIBERNATE_TEXT |
c7b9adaf | 120 | TRAMP_TEXT |
8c2c3df3 CM |
121 | *(.fixup) |
122 | *(.gnu.warning) | |
123 | . = ALIGN(16); | |
124 | *(.got) /* Global offset table */ | |
125 | } | |
126 | ||
97740051 | 127 | . = ALIGN(SEGMENT_ALIGN); |
9fdc14c5 AB |
128 | _etext = .; /* End of text section */ |
129 | ||
19f6bc32 KC |
130 | /* everything from this point to __init_begin will be marked RO NX */ |
131 | RO_DATA(PAGE_SIZE) | |
8c2c3df3 | 132 | |
8eb7e28d JY |
133 | idmap_pg_dir = .; |
134 | . += IDMAP_DIR_SIZE; | |
9d2d75ed | 135 | idmap_pg_end = .; |
8eb7e28d JY |
136 | |
137 | #ifdef CONFIG_UNMAP_KERNEL_AT_EL0 | |
138 | tramp_pg_dir = .; | |
139 | . += PAGE_SIZE; | |
140 | #endif | |
141 | ||
142 | #ifdef CONFIG_ARM64_SW_TTBR0_PAN | |
143 | reserved_ttbr0 = .; | |
144 | . += RESERVED_TTBR0_SIZE; | |
145 | #endif | |
146 | swapper_pg_dir = .; | |
147 | . += PAGE_SIZE; | |
148 | swapper_pg_end = .; | |
149 | ||
97740051 | 150 | . = ALIGN(SEGMENT_ALIGN); |
8c2c3df3 | 151 | __init_begin = .; |
2ebe088b | 152 | __inittext_begin = .; |
8c2c3df3 CM |
153 | |
154 | INIT_TEXT_SECTION(8) | |
ca2ef4ff MR |
155 | |
156 | __exittext_begin = .; | |
8c2c3df3 | 157 | .exit.text : { |
1eae811d | 158 | EXIT_TEXT |
8c2c3df3 | 159 | } |
ca2ef4ff | 160 | __exittext_end = .; |
da141706 | 161 | |
2ebe088b AB |
162 | . = ALIGN(4); |
163 | .altinstructions : { | |
164 | __alt_instructions = .; | |
165 | *(.altinstructions) | |
166 | __alt_instructions_end = .; | |
167 | } | |
2ebe088b | 168 | |
76085aff | 169 | . = ALIGN(SEGMENT_ALIGN); |
2ebe088b AB |
170 | __inittext_end = .; |
171 | __initdata_begin = .; | |
172 | ||
8c2c3df3 CM |
173 | .init.data : { |
174 | INIT_DATA | |
175 | INIT_SETUP(16) | |
176 | INIT_CALLS | |
177 | CON_INITCALL | |
8c2c3df3 | 178 | INIT_RAM_FS |
1ce99bf4 | 179 | *(.init.rodata.* .init.bss) /* from the EFI stub */ |
8c2c3df3 CM |
180 | } |
181 | .exit.data : { | |
1eae811d | 182 | EXIT_DATA |
8c2c3df3 CM |
183 | } |
184 | ||
98fb7548 | 185 | PERCPU_SECTION(L1_CACHE_BYTES) |
8c2c3df3 | 186 | |
3bbd3db8 | 187 | .rela.dyn : ALIGN(8) { |
1e48ef7f | 188 | *(.rela .rela*) |
1e48ef7f | 189 | } |
e039ee4e | 190 | |
3bbd3db8 AB |
191 | __rela_offset = ABSOLUTE(ADDR(.rela.dyn) - KIMAGE_VADDR); |
192 | __rela_size = SIZEOF(.rela.dyn); | |
0cd3defe | 193 | |
5cf896fb PC |
194 | #ifdef CONFIG_RELR |
195 | .relr.dyn : ALIGN(8) { | |
196 | *(.relr.dyn) | |
197 | } | |
198 | ||
199 | __relr_offset = ABSOLUTE(ADDR(.relr.dyn) - KIMAGE_VADDR); | |
200 | __relr_size = SIZEOF(.relr.dyn); | |
201 | #endif | |
202 | ||
97740051 | 203 | . = ALIGN(SEGMENT_ALIGN); |
2ebe088b | 204 | __initdata_end = .; |
9aa4ec15 MR |
205 | __init_end = .; |
206 | ||
3c620626 | 207 | _data = .; |
3c620626 | 208 | _sdata = .; |
c9174047 | 209 | RW_DATA(L1_CACHE_BYTES, PAGE_SIZE, THREAD_ALIGN) |
b6113038 JM |
210 | |
211 | /* | |
212 | * Data written with the MMU off but read with the MMU on requires | |
213 | * cache lines to be invalidated, discarding up to a Cache Writeback | |
214 | * Granule (CWG) of data from the cache. Keep the section that | |
215 | * requires this type of maintenance to be in its own Cache Writeback | |
216 | * Granule (CWG) area so the cache maintenance operations don't | |
217 | * interfere with adjacent data. | |
218 | */ | |
219 | .mmuoff.data.write : ALIGN(SZ_2K) { | |
220 | __mmuoff_data_start = .; | |
221 | *(.mmuoff.data.write) | |
222 | } | |
223 | . = ALIGN(SZ_2K); | |
224 | .mmuoff.data.read : { | |
225 | *(.mmuoff.data.read) | |
226 | __mmuoff_data_end = .; | |
227 | } | |
228 | ||
a352ea3e | 229 | PECOFF_EDATA_PADDING |
cad27ef2 | 230 | __pecoff_data_rawsize = ABSOLUTE(. - __initdata_begin); |
3c620626 | 231 | _edata = .; |
8c2c3df3 | 232 | |
8c2c3df3 | 233 | BSS_SECTION(0, 0, 0) |
bd00cd5f MR |
234 | |
235 | . = ALIGN(PAGE_SIZE); | |
2b5548b6 JY |
236 | init_pg_dir = .; |
237 | . += INIT_DIR_SIZE; | |
238 | init_pg_end = .; | |
239 | ||
76085aff | 240 | . = ALIGN(SEGMENT_ALIGN); |
cad27ef2 | 241 | __pecoff_data_size = ABSOLUTE(. - __initdata_begin); |
8c2c3df3 CM |
242 | _end = .; |
243 | ||
244 | STABS_DEBUG | |
a2c1d73b MR |
245 | |
246 | HEAD_SYMBOLS | |
8c2c3df3 | 247 | } |
2240bbb6 | 248 | |
90776dd1 KC |
249 | #include "image-vars.h" |
250 | ||
2240bbb6 | 251 | /* |
5dfe9d7d | 252 | * The HYP init code and ID map text can't be longer than a page each, |
06f75a1f | 253 | * and should not cross a page boundary. |
2240bbb6 | 254 | */ |
06f75a1f AB |
255 | ASSERT(__hyp_idmap_text_end - (__hyp_idmap_text_start & ~(SZ_4K - 1)) <= SZ_4K, |
256 | "HYP init code too big or misaligned") | |
5dfe9d7d AB |
257 | ASSERT(__idmap_text_end - (__idmap_text_start & ~(SZ_4K - 1)) <= SZ_4K, |
258 | "ID map text too big or misaligned") | |
82869ac5 JM |
259 | #ifdef CONFIG_HIBERNATION |
260 | ASSERT(__hibernate_exit_text_end - (__hibernate_exit_text_start & ~(SZ_4K - 1)) | |
261 | <= SZ_4K, "Hibernate exit text too big or misaligned") | |
262 | #endif | |
6c27c408 WD |
263 | #ifdef CONFIG_UNMAP_KERNEL_AT_EL0 |
264 | ASSERT((__entry_tramp_text_end - __entry_tramp_text_start) == PAGE_SIZE, | |
265 | "Entry trampoline text too big") | |
266 | #endif | |
da57a369 MR |
267 | /* |
268 | * If padding is applied before .head.text, virt<->phys conversions will fail. | |
269 | */ | |
ab893fb9 | 270 | ASSERT(_text == (KIMAGE_VADDR + TEXT_OFFSET), "HEAD is misaligned") |