xref: /linux/arch/loongarch/kernel/vmlinux.lds.S (revision d6296cb65320be16dbf20f2fd584ddc25f3437cd)
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		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	/*
57	 * struct alt_inst entries. From the header (alternative.h):
58	 * "Alternative instructions for different CPU types or capabilities"
59	 * Think locking instructions on spinlocks.
60	 */
61	. = ALIGN(4);
62	.altinstructions : AT(ADDR(.altinstructions) - LOAD_OFFSET) {
63		__alt_instructions = .;
64		*(.altinstructions)
65		__alt_instructions_end = .;
66	}
67
68	.got : ALIGN(16) { *(.got) }
69	.plt : ALIGN(16) { *(.plt) }
70	.got.plt : ALIGN(16) { *(.got.plt) }
71
72	. = ALIGN(PECOFF_SEGMENT_ALIGN);
73	__init_begin = .;
74	__inittext_begin = .;
75
76	INIT_TEXT_SECTION(PAGE_SIZE)
77	.exit.text : {
78		EXIT_TEXT
79	}
80
81	. = ALIGN(PECOFF_SEGMENT_ALIGN);
82	__inittext_end = .;
83
84	__initdata_begin = .;
85
86	INIT_DATA_SECTION(16)
87	.exit.data : {
88		EXIT_DATA
89	}
90
91#ifdef CONFIG_SMP
92	PERCPU_SECTION(1 << CONFIG_L1_CACHE_SHIFT)
93#endif
94
95	.rela.dyn : ALIGN(8) { *(.rela.dyn) *(.rela*) }
96
97	.init.bss : {
98		*(.init.bss)
99	}
100	. = ALIGN(PECOFF_SEGMENT_ALIGN);
101	__initdata_end = .;
102
103	__init_end = .;
104
105	_sdata = .;
106	RO_DATA(4096)
107	RW_DATA(1 << CONFIG_L1_CACHE_SHIFT, PAGE_SIZE, THREAD_SIZE)
108
109	.sdata : {
110		*(.sdata)
111	}
112	.edata_padding : { BYTE(0); . = ALIGN(PECOFF_FILE_ALIGN); }
113	_edata =  .;
114
115	BSS_SECTION(0, SZ_64K, 8)
116	. = ALIGN(PECOFF_SEGMENT_ALIGN);
117
118	_end = .;
119
120	STABS_DEBUG
121	DWARF_DEBUG
122	ELF_DETAILS
123
124	.gptab.sdata : {
125		*(.gptab.data)
126		*(.gptab.sdata)
127	}
128	.gptab.sbss : {
129		*(.gptab.bss)
130		*(.gptab.sbss)
131	}
132
133	DISCARDS
134	/DISCARD/ : {
135		*(.gnu.attributes)
136		*(.options)
137		*(.eh_frame)
138	}
139}
140