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