xref: /linux/arch/loongarch/kernel/vmlinux.lds.S (revision 6d9b262afe0ec1d6e0ef99321ca9d6b921310471)
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/*
11 * Put .bss..swapper_pg_dir as the first thing in .bss. This will
12 * ensure that it has .bss alignment (64K).
13 */
14#define BSS_FIRST_SECTIONS *(.bss..swapper_pg_dir)
15
16#include <asm-generic/vmlinux.lds.h>
17#include "image-vars.h"
18
19/*
20 * Max avaliable Page Size is 64K, so we set SectionAlignment
21 * field of EFI application to 64K.
22 */
23PECOFF_FILE_ALIGN = 0x200;
24PECOFF_SEGMENT_ALIGN = 0x10000;
25
26OUTPUT_ARCH(loongarch)
27ENTRY(kernel_entry)
28PHDRS {
29	text PT_LOAD FLAGS(7);	/* RWX */
30	note PT_NOTE FLAGS(4);	/* R__ */
31}
32
33jiffies	 = jiffies_64;
34
35SECTIONS
36{
37	. = VMLINUX_LOAD_ADDRESS;
38
39	_text = .;
40	HEAD_TEXT_SECTION
41
42	. = ALIGN(PECOFF_SEGMENT_ALIGN);
43	_stext = .;
44	.text : {
45		TEXT_TEXT
46		SCHED_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	. = 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	/*
72	 * struct alt_inst entries. From the header (alternative.h):
73	 * "Alternative instructions for different CPU types or capabilities"
74	 * Think locking instructions on spinlocks.
75	 */
76	. = ALIGN(4);
77	.altinstructions : AT(ADDR(.altinstructions) - LOAD_OFFSET) {
78		__alt_instructions = .;
79		*(.altinstructions)
80		__alt_instructions_end = .;
81	}
82
83	INIT_DATA_SECTION(16)
84	.exit.data : {
85		EXIT_DATA
86	}
87
88#ifdef CONFIG_SMP
89	PERCPU_SECTION(1 << CONFIG_L1_CACHE_SHIFT)
90#endif
91
92	.init.bss : {
93		*(.init.bss)
94	}
95	. = ALIGN(PECOFF_SEGMENT_ALIGN);
96	__initdata_end = .;
97
98	__init_end = .;
99
100	_sdata = .;
101	RO_DATA(4096)
102
103	.got : ALIGN(16) { *(.got) }
104	.plt : ALIGN(16) { *(.plt) }
105	.got.plt : ALIGN(16) { *(.got.plt) }
106
107	RW_DATA(1 << CONFIG_L1_CACHE_SHIFT, PAGE_SIZE, THREAD_SIZE)
108
109	.rela.dyn : ALIGN(8) {
110		__rela_dyn_begin = .;
111		 *(.rela.dyn) *(.rela*)
112		__rela_dyn_end = .;
113	}
114
115	.data.rel : { *(.data.rel*) }
116
117#ifdef CONFIG_RELOCATABLE
118	. = ALIGN(8);
119	.la_abs : AT(ADDR(.la_abs) - LOAD_OFFSET) {
120		__la_abs_begin = .;
121		*(.la_abs)
122		__la_abs_end = .;
123	}
124#endif
125
126	ORC_UNWIND_TABLE
127
128	.sdata : {
129		*(.sdata)
130	}
131	.edata_padding : { BYTE(0); . = ALIGN(PECOFF_FILE_ALIGN); }
132	_edata =  .;
133
134	BSS_SECTION(0, SZ_64K, 8)
135	. = ALIGN(PECOFF_SEGMENT_ALIGN);
136
137	_end = .;
138
139	STABS_DEBUG
140	DWARF_DEBUG
141	ELF_DETAILS
142
143#ifdef CONFIG_EFI_STUB
144	/* header symbols */
145	_kernel_asize = _end - _text;
146	_kernel_fsize = _edata - _text;
147	_kernel_vsize = _end - __initdata_begin;
148	_kernel_rsize = _edata - __initdata_begin;
149#endif
150
151	.gptab.sdata : {
152		*(.gptab.data)
153		*(.gptab.sdata)
154	}
155	.gptab.sbss : {
156		*(.gptab.bss)
157		*(.gptab.sbss)
158	}
159
160	DISCARDS
161	/DISCARD/ : {
162		*(.dynamic .dynsym .dynstr .hash .gnu.hash)
163		*(.gnu.attributes)
164		*(.options)
165		*(.eh_frame)
166	}
167}
168