1 /* SPDX-License-Identifier: GPL-2.0 */ << 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 << 6 */ << 7 << 8 #include <asm/hyp_image.h> << 9 #ifdef CONFIG_KVM << 10 #define HYPERVISOR_EXTABLE << 11 . = ALIGN(SZ_8); << 12 __start___kvm_ex_table = .; << 13 *(__kvm_ex_table) << 14 __stop___kvm_ex_table = .; << 15 << 16 #define HYPERVISOR_DATA_SECTIONS << 17 HYP_SECTION_NAME(.rodata) : { << 18 . = ALIGN(PAGE_SIZE); << 19 __hyp_rodata_start = .; << 20 *(HYP_SECTION_NAME(.data..ro_a << 21 *(HYP_SECTION_NAME(.rodata)) << 22 . = ALIGN(PAGE_SIZE); << 23 __hyp_rodata_end = .; << 24 } << 25 << 26 #define HYPERVISOR_PERCPU_SECTION << 27 . = ALIGN(PAGE_SIZE); << 28 HYP_SECTION_NAME(.data..percpu) : { << 29 *(HYP_SECTION_NAME(.data..perc << 30 } << 31 << 32 #define HYPERVISOR_RELOC_SECTION << 33 .hyp.reloc : ALIGN(4) { << 34 __hyp_reloc_begin = .; << 35 *(.hyp.reloc) << 36 __hyp_reloc_end = .; << 37 } << 38 << 39 #define BSS_FIRST_SECTIONS << 40 __hyp_bss_start = .; << 41 *(HYP_SECTION_NAME(.bss)) << 42 . = ALIGN(PAGE_SIZE); << 43 __hyp_bss_end = .; << 44 << 45 /* << 46 * We require that __hyp_bss_start and __bss_s << 47 * with an assertion. But the BSS_SECTION macr << 48 * between them, which can in some cases cause << 49 * work around the issue, force a page alignme << 50 */ << 51 #define SBSS_ALIGN PAGE_S << 52 #else /* CONFIG_KVM */ << 53 #define HYPERVISOR_EXTABLE << 54 #define HYPERVISOR_DATA_SECTIONS << 55 #define HYPERVISOR_PERCPU_SECTION << 56 #define HYPERVISOR_RELOC_SECTION << 57 #define SBSS_ALIGN 0 << 58 #endif << 59 << 60 #define RO_EXCEPTION_TABLE_ALIGN 4 << 61 #define RUNTIME_DISCARD_EXIT << 62 << 63 #include <asm-generic/vmlinux.lds.h> 1 #include <asm-generic/vmlinux.lds.h> 64 #include <asm/cache.h> << 65 #include <asm/kernel-pgtable.h> << 66 #include <asm/kexec.h> << 67 #include <asm/memory.h> << 68 #include <asm/page.h> << 69 << 70 #include "image.h" << 71 << 72 OUTPUT_ARCH(aarch64) << 73 ENTRY(_text) << 74 << 75 jiffies = jiffies_64; << 76 << 77 #define HYPERVISOR_TEXT << 78 . = ALIGN(PAGE_SIZE); << 79 __hyp_idmap_text_start = .; << 80 *(.hyp.idmap.text) << 81 __hyp_idmap_text_end = .; << 82 __hyp_text_start = .; << 83 *(.hyp.text) << 84 HYPERVISOR_EXTABLE << 85 . = ALIGN(PAGE_SIZE); << 86 __hyp_text_end = .; << 87 << 88 #define IDMAP_TEXT << 89 . = ALIGN(SZ_4K); << 90 __idmap_text_start = .; << 91 *(.idmap.text) << 92 __idmap_text_end = .; << 93 << 94 #ifdef CONFIG_HIBERNATION << 95 #define HIBERNATE_TEXT << 96 ALIGN_FUNCTION(); << 97 __hibernate_exit_text_start = .; << 98 *(.hibernate_exit.text) << 99 __hibernate_exit_text_end = .; << 100 #else << 101 #define HIBERNATE_TEXT << 102 #endif << 103 << 104 #ifdef CONFIG_KEXEC_CORE << 105 #define KEXEC_TEXT << 106 ALIGN_FUNCTION(); << 107 __relocate_new_kernel_start = .; << 108 *(.kexec_relocate.text) << 109 __relocate_new_kernel_end = .; << 110 #else << 111 #define KEXEC_TEXT << 112 #endif << 113 << 114 #ifdef CONFIG_UNMAP_KERNEL_AT_EL0 << 115 #define TRAMP_TEXT << 116 . = ALIGN(PAGE_SIZE); << 117 __entry_tramp_text_start = .; << 118 *(.entry.tramp.text) << 119 . = ALIGN(PAGE_SIZE); << 120 __entry_tramp_text_end = .; << 121 *(.entry.tramp.rodata) << 122 #else << 123 #define TRAMP_TEXT << 124 #endif << 125 << 126 #ifdef CONFIG_UNWIND_TABLES << 127 #define UNWIND_DATA_SECTIONS << 128 .eh_frame : { << 129 __pi___eh_frame_start = .; << 130 *(.eh_frame) << 131 __pi___eh_frame_end = .; << 132 } << 133 #else << 134 #define UNWIND_DATA_SECTIONS << 135 #endif << 136 << 137 /* << 138 * The size of the PE/COFF section that covers << 139 * runs from _stext to _edata, must be a round << 140 * FileAlignment, which we set to its minimum << 141 * itself is 4 KB aligned, so padding out _eda << 142 * boundary should be sufficient. << 143 */ << 144 PECOFF_FILE_ALIGNMENT = 0x200; << 145 << 146 #ifdef CONFIG_EFI << 147 #define PECOFF_EDATA_PADDING \ << 148 .pecoff_edata_padding : { BYTE(0); . = << 149 #else << 150 #define PECOFF_EDATA_PADDING << 151 #endif << 152 2 >> 3 #undef mips /* CPP really sucks for this job */ >> 4 #define mips mips >> 5 OUTPUT_ARCH(mips) >> 6 ENTRY(kernel_entry) >> 7 jiffies = JIFFIES; 153 SECTIONS 8 SECTIONS 154 { 9 { 155 /* !! 10 #ifdef CONFIG_BOOT_ELF64 156 * XXX: The linker does not define how !! 11 /* Read-only sections, merged into text segment: */ 157 * assigned to input sections when the !! 12 /* . = 0xc000000000000000; */ 158 * matching the same input section nam !! 13 159 * order of matching. !! 14 /* This is the value for an Origin kernel, taken from an IRIX kernel. */ 160 */ !! 15 /* . = 0xc00000000001c000; */ 161 DISCARDS !! 16 162 /DISCARD/ : { !! 17 /* Set the vaddr for the text segment to a value 163 *(.interp .dynamic) !! 18 >= 0xa800 0000 0001 9000 if no symmon is going to configured 164 *(.dynsym .dynstr .hash .gnu.h !! 19 >= 0xa800 0000 0030 0000 otherwise */ 165 } !! 20 166 !! 21 /* . = 0xa800000000300000; */ 167 . = KIMAGE_VADDR; !! 22 /* . = 0xa800000000300000; */ 168 !! 23 . = 0xffffffff80300000; 169 .head.text : { !! 24 #endif 170 _text = .; !! 25 . = LOADADDR; 171 HEAD_TEXT !! 26 /* read-only */ 172 } !! 27 _text = .; /* Text and read-only data */ 173 .text : ALIGN(SEGMENT_ALIGN) { /* Rea !! 28 .text : { 174 _stext = .; /* Tex !! 29 *(.text) 175 IRQENTRY_TEXT !! 30 *(.fixup) 176 SOFTIRQENTRY_TEXT !! 31 *(.gnu.warning) 177 ENTRY_TEXT !! 32 } =0 178 TEXT_TEXT !! 33 179 SCHED_TEXT !! 34 _etext = .; /* End of text section */ 180 LOCK_TEXT !! 35 181 KPROBES_TEXT !! 36 . = ALIGN(16); /* Exception table */ 182 HYPERVISOR_TEXT !! 37 __start___ex_table = .; 183 *(.gnu.warning) !! 38 __ex_table : { *(__ex_table) } 184 } !! 39 __stop___ex_table = .; 185 !! 40 186 . = ALIGN(SEGMENT_ALIGN); !! 41 __start___dbe_table = .; /* Exception table for data bus errors */ 187 _etext = .; /* End !! 42 __dbe_table : { *(__dbe_table) } 188 !! 43 __stop___dbe_table = .; 189 /* everything from this point to __ini !! 44 190 RO_DATA(PAGE_SIZE) !! 45 RODATA 191 !! 46 192 HYPERVISOR_DATA_SECTIONS !! 47 . = ALIGN(64); 193 !! 48 194 .got : { *(.got) } !! 49 /* writeable */ 195 /* !! 50 .data : { /* Data */ 196 * Make sure that the .got.plt is eith !! 51 *(.data) 197 * contains only the lazy dispatch ent !! 52 198 */ !! 53 /* Align the initial ramdisk image (INITRD) on page boundaries. */ 199 .got.plt : { *(.got.plt) } !! 54 . = ALIGN(4096); 200 ASSERT(SIZEOF(.got.plt) == 0 || SIZEOF !! 55 __rd_start = .; 201 "Unexpected GOT/PLT entries det !! 56 *(.initrd) 202 !! 57 . = ALIGN(4096); 203 /* code sections that are never execut !! 58 __rd_end = .; 204 .rodata.text : { !! 59 205 TRAMP_TEXT !! 60 CONSTRUCTORS 206 HIBERNATE_TEXT !! 61 } 207 KEXEC_TEXT !! 62 _gp = . + 0x8000; 208 IDMAP_TEXT !! 63 .lit8 : { *(.lit8) } 209 . = ALIGN(PAGE_SIZE); !! 64 .lit4 : { *(.lit4) } 210 } !! 65 /* We want the small data sections together, so single-instruction offsets 211 !! 66 can access them all, and initialized data all before uninitialized, so 212 idmap_pg_dir = .; !! 67 we can shorten the on-disk segment size. */ 213 . += PAGE_SIZE; !! 68 .sdata : { *(.sdata) } 214 !! 69 215 #ifdef CONFIG_UNMAP_KERNEL_AT_EL0 !! 70 . = ALIGN(4096); 216 tramp_pg_dir = .; !! 71 __nosave_begin = .; 217 . += PAGE_SIZE; !! 72 .data_nosave : { *(.data.nosave) } 218 #endif !! 73 . = ALIGN(4096); 219 !! 74 __nosave_end = .; 220 reserved_pg_dir = .; !! 75 221 . += PAGE_SIZE; !! 76 . = ALIGN(4096); 222 !! 77 .data.page_aligned : { *(.data.idt) } 223 swapper_pg_dir = .; !! 78 224 . += PAGE_SIZE; !! 79 . = ALIGN(32); 225 !! 80 .data.cacheline_aligned : { *(.data.cacheline_aligned) } 226 . = ALIGN(SEGMENT_ALIGN); !! 81 227 __init_begin = .; !! 82 _edata = .; /* End of data section */ 228 __inittext_begin = .; !! 83 229 !! 84 #ifdef CONFIG_MIPS32 230 INIT_TEXT_SECTION(8) !! 85 . = ALIGN(8192); /* init_task */ 231 !! 86 #endif 232 __exittext_begin = .; !! 87 #ifdef CONFIG_MIPS64 233 .exit.text : { !! 88 . = ALIGN(16384); /* init_task */ 234 EXIT_TEXT !! 89 #endif 235 } !! 90 . = . + MAPPED_OFFSET; /* for CONFIG_MAPPED_KERNEL */ 236 __exittext_end = .; !! 91 .data.init_task : { *(.data.init_task) } 237 !! 92 238 . = ALIGN(4); !! 93 /* will be freed after init */ 239 .altinstructions : { !! 94 . = ALIGN(4096); /* Init code and data */ 240 __alt_instructions = .; !! 95 __init_begin = .; 241 *(.altinstructions) !! 96 /* /DISCARD/ doesn't work for .reginfo */ 242 __alt_instructions_end = .; !! 97 .reginfo : { *(.reginfo) } 243 } !! 98 .init.text : { 244 !! 99 _sinittext = .; 245 UNWIND_DATA_SECTIONS !! 100 *(.init.text) 246 !! 101 _einittext = .; 247 . = ALIGN(SEGMENT_ALIGN); !! 102 } 248 __inittext_end = .; !! 103 .init.data : { *(.init.data) } 249 __initdata_begin = .; !! 104 . = ALIGN(16); 250 !! 105 __setup_start = .; 251 init_idmap_pg_dir = .; !! 106 .init.setup : { *(.init.setup) } 252 . += INIT_IDMAP_DIR_SIZE; !! 107 __setup_end = .; 253 init_idmap_pg_end = .; !! 108 __start___param = .; 254 !! 109 __param : { *(__param) } 255 .init.data : { !! 110 __stop___param = .; 256 INIT_DATA !! 111 __initcall_start = .; 257 INIT_SETUP(16) !! 112 .initcall.init : { 258 INIT_CALLS !! 113 *(.initcall1.init) 259 CON_INITCALL !! 114 *(.initcall2.init) 260 INIT_RAM_FS !! 115 *(.initcall3.init) 261 *(.init.altinstructions .init. !! 116 *(.initcall4.init) 262 } !! 117 *(.initcall5.init) 263 .exit.data : { !! 118 *(.initcall6.init) 264 EXIT_DATA !! 119 *(.initcall7.init) 265 } !! 120 } 266 !! 121 __initcall_end = .; 267 RUNTIME_CONST_VARIABLES !! 122 __con_initcall_start = .; 268 !! 123 .con_initcall.init : { *(.con_initcall.init) } 269 PERCPU_SECTION(L1_CACHE_BYTES) !! 124 __con_initcall_end = .; 270 HYPERVISOR_PERCPU_SECTION !! 125 SECURITY_INIT 271 !! 126 . = ALIGN(4096); 272 HYPERVISOR_RELOC_SECTION !! 127 __initramfs_start = .; 273 !! 128 .init.ramfs : { *(.init.ramfs) } 274 .rela.dyn : ALIGN(8) { !! 129 __initramfs_end = .; 275 __pi_rela_start = .; !! 130 . = ALIGN(32); 276 *(.rela .rela*) !! 131 __per_cpu_start = .; 277 __pi_rela_end = .; !! 132 .data.percpu : { *(.data.percpu) } 278 } !! 133 __per_cpu_end = .; 279 !! 134 . = ALIGN(4096); 280 .relr.dyn : ALIGN(8) { !! 135 __init_end = .; 281 __pi_relr_start = .; !! 136 /* freed after init ends here */ 282 *(.relr.dyn) !! 137 283 __pi_relr_end = .; !! 138 __bss_start = .; /* BSS */ 284 } !! 139 .sbss : { 285 !! 140 *(.sbss) 286 . = ALIGN(SEGMENT_ALIGN); !! 141 *(.scommon) 287 __initdata_end = .; !! 142 } 288 __init_end = .; !! 143 .bss : { 289 !! 144 *(.bss) 290 _data = .; !! 145 *(COMMON) 291 _sdata = .; !! 146 } 292 RW_DATA(L1_CACHE_BYTES, PAGE_SIZE, THR !! 147 __bss_stop = .; 293 !! 148 294 /* !! 149 _end = . ; 295 * Data written with the MMU off but r !! 150 296 * cache lines to be invalidated, disc !! 151 /* Sections to be discarded */ 297 * Granule (CWG) of data from the cach !! 152 /DISCARD/ : { 298 * requires this type of maintenance t !! 153 *(.exit.text) 299 * Granule (CWG) area so the cache mai !! 154 *(.exit.data) 300 * interfere with adjacent data. !! 155 *(.exitcall.exit) 301 */ !! 156 } 302 .mmuoff.data.write : ALIGN(SZ_2K) { !! 157 303 __mmuoff_data_start = .; !! 158 /* This is the MIPS specific mdebug section. */ 304 *(.mmuoff.data.write) !! 159 .mdebug : { *(.mdebug) } 305 } !! 160 /* These are needed for ELF backends which have not yet been 306 . = ALIGN(SZ_2K); !! 161 converted to the new style linker. */ 307 .mmuoff.data.read : { !! 162 .stab 0 : { *(.stab) } 308 *(.mmuoff.data.read) !! 163 .stabstr 0 : { *(.stabstr) } 309 __mmuoff_data_end = .; !! 164 /* DWARF debug sections. 310 } !! 165 Symbols in the .debug DWARF section are relative to the beginning of the 311 !! 166 section so we begin .debug at 0. It's not clear yet what needs to happen 312 PECOFF_EDATA_PADDING !! 167 for the others. */ 313 __pecoff_data_rawsize = ABSOLUTE(. - _ !! 168 .debug 0 : { *(.debug) } 314 _edata = .; !! 169 .debug_srcinfo 0 : { *(.debug_srcinfo) } 315 !! 170 .debug_aranges 0 : { *(.debug_aranges) } 316 /* start of zero-init region */ !! 171 .debug_pubnames 0 : { *(.debug_pubnames) } 317 BSS_SECTION(SBSS_ALIGN, 0, 0) !! 172 .debug_sfnames 0 : { *(.debug_sfnames) } 318 !! 173 .line 0 : { *(.line) } 319 . = ALIGN(PAGE_SIZE); !! 174 /* These must appear regardless of . */ 320 init_pg_dir = .; !! 175 .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) } 321 . += INIT_DIR_SIZE; !! 176 .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) } 322 init_pg_end = .; !! 177 .comment : { *(.comment) } 323 /* end of zero-init region */ !! 178 .note : { *(.note) } 324 << 325 . += SZ_4K; /* stack for t << 326 early_init_stack = .; << 327 << 328 . = ALIGN(SEGMENT_ALIGN); << 329 __pecoff_data_size = ABSOLUTE(. - __in << 330 _end = .; << 331 << 332 STABS_DEBUG << 333 DWARF_DEBUG << 334 ELF_DETAILS << 335 << 336 HEAD_SYMBOLS << 337 << 338 /* << 339 * Sections that should stay zero size << 340 * explicitly check instead of blindly << 341 */ << 342 .plt : { << 343 *(.plt) *(.plt.*) *(.iplt) *(. << 344 } << 345 ASSERT(SIZEOF(.plt) == 0, "Unexpected << 346 << 347 .data.rel.ro : { *(.data.rel.ro) } << 348 ASSERT(SIZEOF(.data.rel.ro) == 0, "Une << 349 } 179 } 350 << 351 #include "image-vars.h" << 352 << 353 /* << 354 * The HYP init code and ID map text can't be << 355 * former is page-aligned, but the latter may << 356 * it should also not cross a page boundary. << 357 */ << 358 ASSERT(__hyp_idmap_text_end - __hyp_idmap_text << 359 "HYP init code too big") << 360 ASSERT(__idmap_text_end - (__idmap_text_start << 361 "ID map text too big or misaligned") << 362 #ifdef CONFIG_HIBERNATION << 363 ASSERT(__hibernate_exit_text_end - __hibernate << 364 "Hibernate exit text is bigger than 4 K << 365 ASSERT(__hibernate_exit_text_start == swsusp_a << 366 "Hibernate exit text does not start wit << 367 #endif << 368 #ifdef CONFIG_UNMAP_KERNEL_AT_EL0 << 369 ASSERT((__entry_tramp_text_end - __entry_tramp << 370 "Entry trampoline text too big") << 371 #endif << 372 #ifdef CONFIG_KVM << 373 ASSERT(__hyp_bss_start == __bss_start, "HYP an << 374 #endif << 375 /* << 376 * If padding is applied before .head.text, vi << 377 */ << 378 ASSERT(_text == KIMAGE_VADDR, "HEAD is misalig << 379 << 380 ASSERT(swapper_pg_dir - reserved_pg_dir == RES << 381 "RESERVED_SWAPPER_OFFSET is wrong!") << 382 << 383 #ifdef CONFIG_UNMAP_KERNEL_AT_EL0 << 384 ASSERT(swapper_pg_dir - tramp_pg_dir == TRAMP_ << 385 "TRAMP_SWAPPER_OFFSET is wrong!") << 386 #endif << 387 << 388 #ifdef CONFIG_KEXEC_CORE << 389 /* kexec relocation code should fit into one K << 390 ASSERT(__relocate_new_kernel_end - __relocate_ << 391 "kexec relocation code is bigger than 4 << 392 ASSERT(KEXEC_CONTROL_PAGE_SIZE >= SZ_4K, "KEXE << 393 ASSERT(__relocate_new_kernel_start == arm64_re << 394 "kexec control page does not start with << 395 #endif <<
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.