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
6#define PAGE_SIZE _PAGE_SIZE
7#define RO_EXCEPTION_TABLE_ALIGN	4
8
9/*
10 * Put .bss..swapper_pg_dir as the first thing in .bss. This will
11 * ensure that it has .bss alignment (64K).
12 */
13#define BSS_FIRST_SECTIONS *(.bss..swapper_pg_dir)
14
15#include <asm-generic/vmlinux.lds.h>
16#include "image-vars.h"
17
18/*
19 * Max avaliable Page Size is 64K, so we set SectionAlignment
20 * field of EFI application to 64K.
21 */
22PECOFF_FILE_ALIGN = 0x200;
23PECOFF_SEGMENT_ALIGN = 0x10000;
24
25OUTPUT_ARCH(loongarch)
26ENTRY(kernel_entry)
27PHDRS {
28	text PT_LOAD FLAGS(7);	/* RWX */
29	note PT_NOTE FLAGS(4);	/* R__ */
30}
31
32jiffies	 = jiffies_64;
33
34SECTIONS
35{
36	. = VMLINUX_LOAD_ADDRESS;
37
38	_text = .;
39	HEAD_TEXT_SECTION
40
41	. = ALIGN(PECOFF_SEGMENT_ALIGN);
42	_stext = .;
43	.text : {
44		TEXT_TEXT
45		SCHED_TEXT
46		CPUIDLE_TEXT
47		LOCK_TEXT
48		KPROBES_TEXT
49		IRQENTRY_TEXT
50		SOFTIRQENTRY_TEXT
51		*(.fixup)
52		*(.gnu.warning)
53	} :text = 0
54	. = ALIGN(PECOFF_SEGMENT_ALIGN);
55	_etext = .;
56
57	/*
58	 * struct alt_inst entries. From the header (alternative.h):
59	 * "Alternative instructions for different CPU types or capabilities"
60	 * Think locking instructions on spinlocks.
61	 */
62	. = ALIGN(4);
63	.altinstructions : AT(ADDR(.altinstructions) - LOAD_OFFSET) {
64		__alt_instructions = .;
65		*(.altinstructions)
66		__alt_instructions_end = .;
67	}
68
69	.got : ALIGN(16) { *(.got) }
70	.plt : ALIGN(16) { *(.plt) }
71	.got.plt : ALIGN(16) { *(.got.plt) }
72
73	. = ALIGN(PECOFF_SEGMENT_ALIGN);
74	__init_begin = .;
75	__inittext_begin = .;
76
77	INIT_TEXT_SECTION(PAGE_SIZE)
78	.exit.text : {
79		EXIT_TEXT
80	}
81
82	. = ALIGN(PECOFF_SEGMENT_ALIGN);
83	__inittext_end = .;
84
85	__initdata_begin = .;
86
87	INIT_DATA_SECTION(16)
88	.exit.data : {
89		EXIT_DATA
90	}
91
92#ifdef CONFIG_SMP
93	PERCPU_SECTION(1 << CONFIG_L1_CACHE_SHIFT)
94#endif
95
96	.rela.dyn : ALIGN(8) { *(.rela.dyn) *(.rela*) }
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	RW_DATA(1 << CONFIG_L1_CACHE_SHIFT, PAGE_SIZE, THREAD_SIZE)
109
110	.sdata : {
111		*(.sdata)
112	}
113	.edata_padding : { BYTE(0); . = ALIGN(PECOFF_FILE_ALIGN); }
114	_edata =  .;
115
116	BSS_SECTION(0, SZ_64K, 8)
117	. = ALIGN(PECOFF_SEGMENT_ALIGN);
118
119	_end = .;
120
121	STABS_DEBUG
122	DWARF_DEBUG
123	ELF_DETAILS
124
125	.gptab.sdata : {
126		*(.gptab.data)
127		*(.gptab.sdata)
128	}
129	.gptab.sbss : {
130		*(.gptab.bss)
131		*(.gptab.sbss)
132	}
133
134	DISCARDS
135	/DISCARD/ : {
136		*(.gnu.attributes)
137		*(.options)
138		*(.eh_frame)
139	}
140}
141