1 /* SPDX-License-Identifier: GPL-2.0 */ 1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* !! 2 #include <asm/asm-offsets.h> 3 * ld script to make ARM Linux kernel !! 3 #include <asm/thread_info.h> 4 * taken from the i386 version by Russell King << 5 * Written by Martin Mares <mj@atrey.karlin.mff << 6 */ << 7 4 8 #include <asm/hyp_image.h> !! 5 #define PAGE_SIZE _PAGE_SIZE 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 6 45 /* 7 /* 46 * We require that __hyp_bss_start and __bss_s !! 8 * Put .bss..swapper_pg_dir as the first thing in .bss. This will 47 * with an assertion. But the BSS_SECTION macr !! 9 * ensure that it has .bss alignment (64K). 48 * between them, which can in some cases cause << 49 * work around the issue, force a page alignme << 50 */ 10 */ 51 #define SBSS_ALIGN PAGE_S !! 11 #define BSS_FIRST_SECTIONS *(.bss..swapper_pg_dir) 52 #else /* CONFIG_KVM */ !! 12 53 #define HYPERVISOR_EXTABLE !! 13 /* Cavium Octeon should not have a separate PT_NOTE Program Header. */ 54 #define HYPERVISOR_DATA_SECTIONS !! 14 #ifndef CONFIG_CAVIUM_OCTEON_SOC 55 #define HYPERVISOR_PERCPU_SECTION !! 15 #define EMITS_PT_NOTE 56 #define HYPERVISOR_RELOC_SECTION << 57 #define SBSS_ALIGN 0 << 58 #endif 16 #endif 59 17 60 #define RO_EXCEPTION_TABLE_ALIGN 4 << 61 #define RUNTIME_DISCARD_EXIT 18 #define RUNTIME_DISCARD_EXIT 62 19 63 #include <asm-generic/vmlinux.lds.h> 20 #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 21 137 /* !! 22 #undef mips 138 * The size of the PE/COFF section that covers !! 23 #define mips mips 139 * runs from _stext to _edata, must be a round !! 24 OUTPUT_ARCH(mips) 140 * FileAlignment, which we set to its minimum !! 25 ENTRY(kernel_entry) 141 * itself is 4 KB aligned, so padding out _eda !! 26 PHDRS { 142 * boundary should be sufficient. !! 27 text PT_LOAD FLAGS(7); /* RWX */ 143 */ !! 28 #ifndef CONFIG_CAVIUM_OCTEON_SOC 144 PECOFF_FILE_ALIGNMENT = 0x200; !! 29 note PT_NOTE FLAGS(4); /* R__ */ >> 30 #endif /* CAVIUM_OCTEON_SOC */ >> 31 } 145 32 146 #ifdef CONFIG_EFI !! 33 #ifdef CONFIG_32BIT 147 #define PECOFF_EDATA_PADDING \ !! 34 #ifdef CONFIG_CPU_LITTLE_ENDIAN 148 .pecoff_edata_padding : { BYTE(0); . = !! 35 jiffies = jiffies_64; >> 36 #else >> 37 jiffies = jiffies_64 + 4; >> 38 #endif 149 #else 39 #else 150 #define PECOFF_EDATA_PADDING !! 40 jiffies = jiffies_64; 151 #endif 41 #endif 152 42 153 SECTIONS 43 SECTIONS 154 { 44 { 155 /* !! 45 #ifdef CONFIG_BOOT_ELF64 156 * XXX: The linker does not define how !! 46 /* Read-only sections, merged into text segment: */ 157 * assigned to input sections when the !! 47 /* . = 0xc000000000000000; */ 158 * matching the same input section nam !! 48 159 * order of matching. !! 49 /* This is the value for an Origin kernel, taken from an IRIX kernel. */ >> 50 /* . = 0xc00000000001c000; */ >> 51 >> 52 /* Set the vaddr for the text segment to a value >> 53 * >= 0xa800 0000 0001 9000 if no symmon is going to configured >> 54 * >= 0xa800 0000 0030 0000 otherwise 160 */ 55 */ 161 DISCARDS << 162 /DISCARD/ : { << 163 *(.interp .dynamic) << 164 *(.dynsym .dynstr .hash .gnu.h << 165 } << 166 << 167 . = KIMAGE_VADDR; << 168 << 169 .head.text : { << 170 _text = .; << 171 HEAD_TEXT << 172 } << 173 .text : ALIGN(SEGMENT_ALIGN) { /* Rea << 174 _stext = .; /* Tex << 175 IRQENTRY_TEXT << 176 SOFTIRQENTRY_TEXT << 177 ENTRY_TEXT << 178 TEXT_TEXT << 179 SCHED_TEXT << 180 LOCK_TEXT << 181 KPROBES_TEXT << 182 HYPERVISOR_TEXT << 183 *(.gnu.warning) << 184 } << 185 << 186 . = ALIGN(SEGMENT_ALIGN); << 187 _etext = .; /* End << 188 << 189 /* everything from this point to __ini << 190 RO_DATA(PAGE_SIZE) << 191 56 192 HYPERVISOR_DATA_SECTIONS !! 57 /* . = 0xa800000000300000; */ 193 !! 58 . = 0xffffffff80300000; 194 .got : { *(.got) } << 195 /* << 196 * Make sure that the .got.plt is eith << 197 * contains only the lazy dispatch ent << 198 */ << 199 .got.plt : { *(.got.plt) } << 200 ASSERT(SIZEOF(.got.plt) == 0 || SIZEOF << 201 "Unexpected GOT/PLT entries det << 202 << 203 /* code sections that are never execut << 204 .rodata.text : { << 205 TRAMP_TEXT << 206 HIBERNATE_TEXT << 207 KEXEC_TEXT << 208 IDMAP_TEXT << 209 . = ALIGN(PAGE_SIZE); << 210 } << 211 << 212 idmap_pg_dir = .; << 213 . += PAGE_SIZE; << 214 << 215 #ifdef CONFIG_UNMAP_KERNEL_AT_EL0 << 216 tramp_pg_dir = .; << 217 . += PAGE_SIZE; << 218 #endif 59 #endif >> 60 . = LINKER_LOAD_ADDRESS; >> 61 /* read-only */ >> 62 _text = .; /* Text and read-only data */ >> 63 .text : { >> 64 TEXT_TEXT >> 65 SCHED_TEXT >> 66 LOCK_TEXT >> 67 KPROBES_TEXT >> 68 IRQENTRY_TEXT >> 69 SOFTIRQENTRY_TEXT >> 70 *(.fixup) >> 71 *(.gnu.warning) >> 72 . = ALIGN(16); >> 73 *(.got) /* Global offset table */ >> 74 } :text = 0 >> 75 _etext = .; /* End of text section */ >> 76 >> 77 EXCEPTION_TABLE(16) >> 78 >> 79 /* Exception table for data bus errors */ >> 80 __dbe_table : { >> 81 __start___dbe_table = .; >> 82 KEEP(*(__dbe_table)) >> 83 __stop___dbe_table = .; >> 84 } >> 85 >> 86 _sdata = .; /* Start of data section */ >> 87 RO_DATA(4096) >> 88 >> 89 /* writeable */ >> 90 .data : { /* Data */ >> 91 . = . + DATAOFFSET; /* for CONFIG_MAPPED_KERNEL */ >> 92 >> 93 INIT_TASK_DATA(THREAD_SIZE) >> 94 NOSAVE_DATA >> 95 PAGE_ALIGNED_DATA(PAGE_SIZE) >> 96 CACHELINE_ALIGNED_DATA(1 << CONFIG_MIPS_L1_CACHE_SHIFT) >> 97 READ_MOSTLY_DATA(1 << CONFIG_MIPS_L1_CACHE_SHIFT) >> 98 DATA_DATA >> 99 CONSTRUCTORS >> 100 } >> 101 BUG_TABLE >> 102 _gp = . + 0x8000; >> 103 .lit8 : { >> 104 *(.lit8) >> 105 } >> 106 .lit4 : { >> 107 *(.lit4) >> 108 } >> 109 /* We want the small data sections together, so single-instruction offsets >> 110 can access them all, and initialized data all before uninitialized, so >> 111 we can shorten the on-disk segment size. */ >> 112 .sdata : { >> 113 *(.sdata) >> 114 } >> 115 _edata = .; /* End of data section */ 219 116 220 reserved_pg_dir = .; !! 117 /* will be freed after init */ 221 . += PAGE_SIZE; !! 118 . = ALIGN(PAGE_SIZE); /* Init code and data */ 222 << 223 swapper_pg_dir = .; << 224 . += PAGE_SIZE; << 225 << 226 . = ALIGN(SEGMENT_ALIGN); << 227 __init_begin = .; 119 __init_begin = .; 228 __inittext_begin = .; !! 120 INIT_TEXT_SECTION(PAGE_SIZE) >> 121 INIT_DATA_SECTION(16) 229 122 230 INIT_TEXT_SECTION(8) !! 123 . = ALIGN(4); >> 124 .mips.machines.init : AT(ADDR(.mips.machines.init) - LOAD_OFFSET) { >> 125 __mips_machines_start = .; >> 126 KEEP(*(.mips.machines.init)) >> 127 __mips_machines_end = .; >> 128 } 231 129 232 __exittext_begin = .; !! 130 /* .exit.text is discarded at runtime, not link time, to deal with >> 131 * references from .rodata >> 132 */ 233 .exit.text : { 133 .exit.text : { 234 EXIT_TEXT 134 EXIT_TEXT 235 } 135 } 236 __exittext_end = .; << 237 << 238 . = ALIGN(4); << 239 .altinstructions : { << 240 __alt_instructions = .; << 241 *(.altinstructions) << 242 __alt_instructions_end = .; << 243 } << 244 << 245 UNWIND_DATA_SECTIONS << 246 << 247 . = ALIGN(SEGMENT_ALIGN); << 248 __inittext_end = .; << 249 __initdata_begin = .; << 250 << 251 init_idmap_pg_dir = .; << 252 . += INIT_IDMAP_DIR_SIZE; << 253 init_idmap_pg_end = .; << 254 << 255 .init.data : { << 256 INIT_DATA << 257 INIT_SETUP(16) << 258 INIT_CALLS << 259 CON_INITCALL << 260 INIT_RAM_FS << 261 *(.init.altinstructions .init. << 262 } << 263 .exit.data : { 136 .exit.data : { 264 EXIT_DATA 137 EXIT_DATA 265 } 138 } >> 139 #ifdef CONFIG_SMP >> 140 PERCPU_SECTION(1 << CONFIG_MIPS_L1_CACHE_SHIFT) >> 141 #endif 266 142 267 RUNTIME_CONST_VARIABLES !! 143 .rel.dyn : ALIGN(8) { 268 !! 144 *(.rel) 269 PERCPU_SECTION(L1_CACHE_BYTES) !! 145 *(.rel*) 270 HYPERVISOR_PERCPU_SECTION << 271 << 272 HYPERVISOR_RELOC_SECTION << 273 << 274 .rela.dyn : ALIGN(8) { << 275 __pi_rela_start = .; << 276 *(.rela .rela*) << 277 __pi_rela_end = .; << 278 } 146 } 279 147 280 .relr.dyn : ALIGN(8) { !! 148 #ifdef CONFIG_MIPS_ELF_APPENDED_DTB 281 __pi_relr_start = .; !! 149 STRUCT_ALIGN(); 282 *(.relr.dyn) !! 150 .appended_dtb : AT(ADDR(.appended_dtb) - LOAD_OFFSET) { 283 __pi_relr_end = .; !! 151 *(.appended_dtb) >> 152 KEEP(*(.appended_dtb)) 284 } 153 } >> 154 #endif 285 155 286 . = ALIGN(SEGMENT_ALIGN); !! 156 #ifdef CONFIG_RELOCATABLE 287 __initdata_end = .; !! 157 . = ALIGN(4); 288 __init_end = .; << 289 158 290 _data = .; !! 159 .data.reloc : { 291 _sdata = .; !! 160 _relocation_start = .; 292 RW_DATA(L1_CACHE_BYTES, PAGE_SIZE, THR !! 161 /* >> 162 * Space for relocation table >> 163 * This needs to be filled so that the >> 164 * relocs tool can overwrite the content. >> 165 * An invalid value is left at the start of the >> 166 * section to abort relocation if the table >> 167 * has not been filled in. >> 168 */ >> 169 LONG(0xFFFFFFFF); >> 170 FILL(0); >> 171 . += CONFIG_RELOCATION_TABLE_SIZE - 4; >> 172 _relocation_end = .; >> 173 } >> 174 #endif 293 175 >> 176 #ifdef CONFIG_MIPS_RAW_APPENDED_DTB >> 177 .fill : { >> 178 FILL(0); >> 179 BYTE(0); >> 180 STRUCT_ALIGN(); >> 181 } >> 182 __appended_dtb = .; >> 183 /* leave space for appended DTB */ >> 184 . += 0x100000; >> 185 #endif 294 /* 186 /* 295 * Data written with the MMU off but r !! 187 * Align to 64K in attempt to eliminate holes before the 296 * cache lines to be invalidated, disc !! 188 * .bss..swapper_pg_dir section at the start of .bss. This 297 * Granule (CWG) of data from the cach !! 189 * also satisfies PAGE_SIZE alignment as the largest page size 298 * requires this type of maintenance t !! 190 * allowed is 64K. 299 * Granule (CWG) area so the cache mai << 300 * interfere with adjacent data. << 301 */ 191 */ 302 .mmuoff.data.write : ALIGN(SZ_2K) { !! 192 . = ALIGN(0x10000); 303 __mmuoff_data_start = .; !! 193 __init_end = .; 304 *(.mmuoff.data.write) !! 194 /* freed after init ends here */ 305 } << 306 . = ALIGN(SZ_2K); << 307 .mmuoff.data.read : { << 308 *(.mmuoff.data.read) << 309 __mmuoff_data_end = .; << 310 } << 311 << 312 PECOFF_EDATA_PADDING << 313 __pecoff_data_rawsize = ABSOLUTE(. - _ << 314 _edata = .; << 315 << 316 /* start of zero-init region */ << 317 BSS_SECTION(SBSS_ALIGN, 0, 0) << 318 << 319 . = ALIGN(PAGE_SIZE); << 320 init_pg_dir = .; << 321 . += INIT_DIR_SIZE; << 322 init_pg_end = .; << 323 /* end of zero-init region */ << 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 195 338 /* 196 /* 339 * Sections that should stay zero size !! 197 * Force .bss to 64K alignment so that .bss..swapper_pg_dir 340 * explicitly check instead of blindly !! 198 * gets that alignment. .sbss should be empty, so there will be 341 */ !! 199 * no holes after __init_end. */ 342 .plt : { !! 200 BSS_SECTION(0, 0x10000, 8) 343 *(.plt) *(.plt.*) *(.iplt) *(. << 344 } << 345 ASSERT(SIZEOF(.plt) == 0, "Unexpected << 346 201 347 .data.rel.ro : { *(.data.rel.ro) } !! 202 _end = . ; 348 ASSERT(SIZEOF(.data.rel.ro) == 0, "Une << 349 } << 350 203 351 #include "image-vars.h" !! 204 /* These mark the ABI of the kernel for debuggers. */ >> 205 .mdebug.abi32 : { >> 206 KEEP(*(.mdebug.abi32)) >> 207 } >> 208 .mdebug.abi64 : { >> 209 KEEP(*(.mdebug.abi64)) >> 210 } 352 211 353 /* !! 212 /* This is the MIPS specific mdebug section. */ 354 * The HYP init code and ID map text can't be !! 213 .mdebug : { 355 * former is page-aligned, but the latter may !! 214 *(.mdebug) 356 * it should also not cross a page boundary. !! 215 } 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 216 380 ASSERT(swapper_pg_dir - reserved_pg_dir == RES !! 217 STABS_DEBUG 381 "RESERVED_SWAPPER_OFFSET is wrong!") !! 218 DWARF_DEBUG >> 219 ELF_DETAILS 382 220 383 #ifdef CONFIG_UNMAP_KERNEL_AT_EL0 !! 221 /* These must appear regardless of . */ 384 ASSERT(swapper_pg_dir - tramp_pg_dir == TRAMP_ !! 222 .gptab.sdata : { 385 "TRAMP_SWAPPER_OFFSET is wrong!") !! 223 *(.gptab.data) 386 #endif !! 224 *(.gptab.sdata) >> 225 } >> 226 .gptab.sbss : { >> 227 *(.gptab.bss) >> 228 *(.gptab.sbss) >> 229 } 387 230 388 #ifdef CONFIG_KEXEC_CORE !! 231 /* Sections to be discarded */ 389 /* kexec relocation code should fit into one K !! 232 DISCARDS 390 ASSERT(__relocate_new_kernel_end - __relocate_ !! 233 /DISCARD/ : { 391 "kexec relocation code is bigger than 4 !! 234 /* ABI crap starts here */ 392 ASSERT(KEXEC_CONTROL_PAGE_SIZE >= SZ_4K, "KEXE !! 235 *(.MIPS.abiflags) 393 ASSERT(__relocate_new_kernel_start == arm64_re !! 236 *(.MIPS.options) 394 "kexec control page does not start with !! 237 *(.gnu.attributes) 395 #endif !! 238 *(.options) >> 239 *(.pdr) >> 240 *(.reginfo) >> 241 } >> 242 }
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.