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
8/*
9 * Put .bss..swapper_pg_dir as the first thing in .bss. This will
10 * ensure that it has .bss alignment (64K).
11 */
12#define BSS_FIRST_SECTIONS *(.bss..swapper_pg_dir)
13
14#include <asm-generic/vmlinux.lds.h>
15
16/*
17 * Max avaliable Page Size is 64K, so we set SectionAlignment
18 * field of EFI application to 64K.
19 */
20PECOFF_FILE_ALIGN = 0x200;
21PECOFF_SEGMENT_ALIGN = 0x10000;
22
23OUTPUT_ARCH(loongarch)
24ENTRY(kernel_entry)
25PHDRS {
26	text PT_LOAD FLAGS(7);	/* RWX */
27	note PT_NOTE FLAGS(4);	/* R__ */
28}
29
30jiffies	 = jiffies_64;
31
32SECTIONS
33{
34	. = VMLINUX_LOAD_ADDRESS;
35
36	_text = .;
37	HEAD_TEXT_SECTION
38
39	. = ALIGN(PECOFF_SEGMENT_ALIGN);
40	_stext = .;
41	.text : {
42		TEXT_TEXT
43		SCHED_TEXT
44		CPUIDLE_TEXT
45		LOCK_TEXT
46		KPROBES_TEXT
47		IRQENTRY_TEXT
48		SOFTIRQENTRY_TEXT
49		*(.fixup)
50		*(.gnu.warning)
51	} :text = 0
52	. = ALIGN(PECOFF_SEGMENT_ALIGN);
53	_etext = .;
54
55	EXCEPTION_TABLE(16)
56
57	. = ALIGN(PECOFF_SEGMENT_ALIGN);
58	__init_begin = .;
59	__inittext_begin = .;
60
61	INIT_TEXT_SECTION(PAGE_SIZE)
62	.exit.text : {
63		EXIT_TEXT
64	}
65
66	. = ALIGN(PECOFF_SEGMENT_ALIGN);
67	__inittext_end = .;
68
69	__initdata_begin = .;
70
71	INIT_DATA_SECTION(16)
72	.exit.data : {
73		EXIT_DATA
74	}
75
76#ifdef CONFIG_SMP
77	PERCPU_SECTION(1 << CONFIG_L1_CACHE_SHIFT)
78#endif
79
80	.init.bss : {
81		*(.init.bss)
82	}
83	. = ALIGN(PECOFF_SEGMENT_ALIGN);
84	__initdata_end = .;
85
86	__init_end = .;
87
88	_sdata = .;
89	RO_DATA(4096)
90	RW_DATA(1 << CONFIG_L1_CACHE_SHIFT, PAGE_SIZE, THREAD_SIZE)
91
92	.sdata : {
93		*(.sdata)
94	}
95	.edata_padding : { BYTE(0); . = ALIGN(PECOFF_FILE_ALIGN); }
96	_edata =  .;
97
98	BSS_SECTION(0, SZ_64K, 8)
99	. = ALIGN(PECOFF_SEGMENT_ALIGN);
100
101	_end = .;
102
103	STABS_DEBUG
104	DWARF_DEBUG
105	ELF_DETAILS
106
107	.gptab.sdata : {
108		*(.gptab.data)
109		*(.gptab.sdata)
110	}
111	.gptab.sbss : {
112		*(.gptab.bss)
113		*(.gptab.sbss)
114	}
115
116	DISCARDS
117	/DISCARD/ : {
118		*(.gnu.attributes)
119		*(.options)
120		*(.eh_frame)
121	}
122}
123