1/* SPDX-License-Identifier: GPL-2.0 */ 2#include <linux/sizes.h> 3#include <asm/asm-offsets.h> 4#include <asm/thread_info.h> 5#include <asm/orc_lookup.h> 6 7#define PAGE_SIZE _PAGE_SIZE 8#define RO_EXCEPTION_TABLE_ALIGN 4 9#define RUNTIME_DISCARD_EXIT 10 11/* 12 * Put .bss..swapper_pg_dir as the first thing in .bss. This will 13 * ensure that it has .bss alignment (64K). 14 */ 15#define BSS_FIRST_SECTIONS *(.bss..swapper_pg_dir) 16 17#include <asm-generic/vmlinux.lds.h> 18 19OUTPUT_ARCH(loongarch) 20ENTRY(kernel_entry) 21PHDRS { 22 text PT_LOAD FLAGS(7); /* RWX */ 23 note PT_NOTE FLAGS(4); /* R__ */ 24} 25 26jiffies = jiffies_64; 27 28SECTIONS 29{ 30 . = VMLINUX_LOAD_ADDRESS; 31 /* Read-only */ 32 _text = .; /* Text and read-only data */ 33 .text : { 34 TEXT_TEXT 35 SCHED_TEXT 36 CPUIDLE_TEXT 37 LOCK_TEXT 38 KPROBES_TEXT 39 IRQENTRY_TEXT 40 SOFTIRQENTRY_TEXT 41 *(.fixup) 42 *(.gnu.warning) 43 } :text = 0 44 _etext = .; /* End of text section */ 45 46 /* 47 * struct alt_inst entries. From the header (alternative.h): 48 * "Alternative instructions for different CPU types or capabilities" 49 * Think locking instructions on spinlocks. 50 */ 51 . = ALIGN(4); 52 .altinstructions : AT(ADDR(.altinstructions) - LOAD_OFFSET) { 53 __alt_instructions = .; 54 *(.altinstructions) 55 __alt_instructions_end = .; 56 } 57 58 .got : ALIGN(16) { *(.got) } 59 .plt : ALIGN(16) { *(.plt) } 60 .got.plt : ALIGN(16) { *(.got.plt) } 61 62 _sdata = .; /* Start of data section */ 63 RO_DATA(4096) 64 RW_DATA(1 << CONFIG_L1_CACHE_SHIFT, PAGE_SIZE, THREAD_SIZE) 65 66 ORC_UNWIND_TABLE 67 68 /* We want the small data sections together, so single-instruction offsets 69 can access them all, and initialized data all before uninitialized, so 70 we can shorten the on-disk segment size. */ 71 .sdata : { 72 *(.sdata) 73 } 74 _edata = .; /* End of data section */ 75 76 /* Will be freed after init */ 77 . = ALIGN(PAGE_SIZE); /* Init code and data */ 78 __init_begin = .; 79 INIT_TEXT_SECTION(PAGE_SIZE) 80 INIT_DATA_SECTION(16) 81 82 . = ALIGN(4); 83 84 /* .exit.text is discarded at runtime, not link time, to deal with 85 * references from .rodata 86 */ 87 .exit.text : { 88 EXIT_TEXT 89 } 90 .exit.data : { 91 EXIT_DATA 92 } 93#ifdef CONFIG_SMP 94 PERCPU_SECTION(1 << CONFIG_L1_CACHE_SHIFT) 95#endif 96 97 .rela.dyn : ALIGN(8) { *(.rela.dyn) *(.rela*) } 98 99#ifdef CONFIG_RELOCATABLE 100 . = ALIGN(4); 101 102 .data.reloc : { 103 _relocation_start = .; 104 /* 105 * Space for relocation table 106 * This needs to be filled so that the 107 * relocs tool can overwrite the content. 108 * An invalid value is left at the start of the 109 * section to abort relocation if the table 110 * has not been filled in. 111 */ 112 LONG(0xFFFFFFFF); 113 FILL(0); 114 . += CONFIG_RELOCATION_TABLE_SIZE - 4; 115 _relocation_end = .; 116 } 117#endif 118 119 /* 120 * Align to 64K in attempt to eliminate holes before the 121 * .bss..swapper_pg_dir section at the start of .bss. This 122 * also satisfies PAGE_SIZE alignment as the largest page size 123 * allowed is 64K. 124 */ 125 . = ALIGN(0x10000); 126 __init_end = .; 127 /* freed after init ends here */ 128 129 /* 130 * Force .bss to 64K alignment so that .bss..swapper_pg_dir 131 * gets that alignment. .sbss should be empty, so there will be 132 * no holes after __init_end. */ 133 BSS_SECTION(0, 0x10000, 8) 134 135 _end = . ; 136 137 STABS_DEBUG 138 DWARF_DEBUG 139 ELF_DETAILS 140 141 /* These must appear regardless of . */ 142 .gptab.sdata : { 143 *(.gptab.data) 144 *(.gptab.sdata) 145 } 146 .gptab.sbss : { 147 *(.gptab.bss) 148 *(.gptab.sbss) 149 } 150 151 /* Sections to be discarded */ 152 DISCARDS 153 /DISCARD/ : { 154 *(.gnu.attributes) 155 *(.options) 156 *(.eh_frame) 157 } 158} 159