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 10#ifdef CONFIG_32BIT 11#define PHYSADDR_MASK 0x1fffffff /* 29-bit */ 12#else 13#define PHYSADDR_MASK 0xffffffffffff /* 48-bit */ 14#endif 15 16/* 17 * Put .bss..swapper_pg_dir as the first thing in .bss. This will 18 * ensure that it has .bss alignment (64K). 19 */ 20#define BSS_FIRST_SECTIONS *(.bss..swapper_pg_dir) 21 22#include <asm-generic/vmlinux.lds.h> 23#include "image-vars.h" 24 25/* 26 * Max avaliable Page Size is 64K, so we set SectionAlignment 27 * field of EFI application to 64K. 28 */ 29PECOFF_FILE_ALIGN = 0x200; 30PECOFF_SEGMENT_ALIGN = 0x10000; 31 32OUTPUT_ARCH(loongarch) 33ENTRY(kernel_entry) 34PHDRS { 35 text PT_LOAD FLAGS(7); /* RWX */ 36 note PT_NOTE FLAGS(4); /* R__ */ 37} 38 39jiffies = jiffies_64; 40 41SECTIONS 42{ 43 . = VMLINUX_LOAD_ADDRESS; 44 45 _text = .; 46 HEAD_TEXT_SECTION 47 48 . = ALIGN(PECOFF_SEGMENT_ALIGN); 49 _stext = .; 50 .text : { 51 TEXT_TEXT 52 SCHED_TEXT 53 LOCK_TEXT 54 KPROBES_TEXT 55 IRQENTRY_TEXT 56 SOFTIRQENTRY_TEXT 57 *(.fixup) 58 *(.gnu.warning) 59 } :text = 0 60 . = ALIGN(PECOFF_SEGMENT_ALIGN); 61 _etext = .; 62 63 . = ALIGN(PECOFF_SEGMENT_ALIGN); 64 __init_begin = .; 65 __inittext_begin = .; 66 67 INIT_TEXT_SECTION(PAGE_SIZE) 68 .exit.text : { 69 EXIT_TEXT 70 } 71 72 . = ALIGN(PECOFF_SEGMENT_ALIGN); 73 __inittext_end = .; 74 75 __initdata_begin = .; 76 77 /* 78 * struct alt_inst entries. From the header (alternative.h): 79 * "Alternative instructions for different CPU types or capabilities" 80 * Think locking instructions on spinlocks. 81 */ 82 . = ALIGN(4); 83 .altinstructions : AT(ADDR(.altinstructions) - LOAD_OFFSET) { 84 __alt_instructions = .; 85 *(.altinstructions) 86 __alt_instructions_end = .; 87 } 88 89 INIT_DATA_SECTION(16) 90 .exit.data : { 91 EXIT_DATA 92 } 93 94#ifdef CONFIG_SMP 95 PERCPU_SECTION(1 << CONFIG_L1_CACHE_SHIFT) 96#endif 97 98 .init.bss : { 99 *(.init.bss) 100 } 101 . = ALIGN(PECOFF_SEGMENT_ALIGN); 102 __initdata_end = .; 103 104 __init_end = .; 105 106 _sdata = .; 107 RO_DATA(4096) 108 109 .got : ALIGN(16) { *(.got) } 110 .plt : ALIGN(16) { *(.plt) } 111 .got.plt : ALIGN(16) { *(.got.plt) } 112 113 RW_DATA(1 << CONFIG_L1_CACHE_SHIFT, PAGE_SIZE, THREAD_SIZE) 114 115 .rela.dyn : ALIGN(8) { 116 __rela_dyn_begin = .; 117 *(.rela.dyn) *(.rela*) 118 __rela_dyn_end = .; 119 } 120 121#ifdef CONFIG_RELR 122 .relr.dyn : ALIGN(8) { 123 __relr_dyn_begin = .; 124 *(.relr.dyn) 125 __relr_dyn_end = .; 126 } 127#endif 128 129 .data.rel : { *(.data.rel*) } 130 131#ifdef CONFIG_RELOCATABLE 132 . = ALIGN(8); 133 .la_abs : AT(ADDR(.la_abs) - LOAD_OFFSET) { 134 __la_abs_begin = .; 135 *(.la_abs) 136 __la_abs_end = .; 137 } 138#endif 139 140 ORC_UNWIND_TABLE 141 142 .sdata : { 143 *(.sdata) 144 } 145 .edata_padding : { BYTE(0); . = ALIGN(PECOFF_FILE_ALIGN); } 146 _edata = .; 147 148 BSS_SECTION(0, SZ_64K, 8) 149 . = ALIGN(PECOFF_SEGMENT_ALIGN); 150 151 _end = .; 152 153 STABS_DEBUG 154 DWARF_DEBUG 155 MODINFO 156 ELF_DETAILS 157 158#ifdef CONFIG_EFI_STUB 159 /* header symbols */ 160 _kernel_entry = ABSOLUTE(kernel_entry & PHYSADDR_MASK); 161 _kernel_asize = ABSOLUTE(_end - _text); 162 _kernel_fsize = ABSOLUTE(_edata - _text); 163 _kernel_vsize = ABSOLUTE(_end - __initdata_begin); 164 _kernel_rsize = ABSOLUTE(_edata - __initdata_begin); 165#endif 166 167 .gptab.sdata : { 168 *(.gptab.data) 169 *(.gptab.sdata) 170 } 171 .gptab.sbss : { 172 *(.gptab.bss) 173 *(.gptab.sbss) 174 } 175 176 DISCARDS 177 /DISCARD/ : { 178 *(.dynamic .dynsym .dynstr .hash .gnu.hash) 179 *(.gnu.attributes) 180 *(.options) 181 *(.eh_frame) 182 } 183} 184