xref: /linux/arch/loongarch/kernel/vmlinux.lds.S (revision a6484baa3b02b9d71bfd6016e7632dd1c02d5cba)
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#ifdef CONFIG_RELOCATABLE
70	. = ALIGN(8);
71	.la_abs : AT(ADDR(.la_abs) - LOAD_OFFSET) {
72		__la_abs_begin = .;
73		*(.la_abs)
74		__la_abs_end = .;
75	}
76#endif
77
78	.got : ALIGN(16) { *(.got) }
79	.plt : ALIGN(16) { *(.plt) }
80	.got.plt : ALIGN(16) { *(.got.plt) }
81
82	.data.rel : { *(.data.rel*) }
83
84	. = ALIGN(PECOFF_SEGMENT_ALIGN);
85	__init_begin = .;
86	__inittext_begin = .;
87
88	INIT_TEXT_SECTION(PAGE_SIZE)
89	.exit.text : {
90		EXIT_TEXT
91	}
92
93	. = ALIGN(PECOFF_SEGMENT_ALIGN);
94	__inittext_end = .;
95
96	__initdata_begin = .;
97
98	INIT_DATA_SECTION(16)
99	.exit.data : {
100		EXIT_DATA
101	}
102
103#ifdef CONFIG_SMP
104	PERCPU_SECTION(1 << CONFIG_L1_CACHE_SHIFT)
105#endif
106
107	.init.bss : {
108		*(.init.bss)
109	}
110	. = ALIGN(PECOFF_SEGMENT_ALIGN);
111	__initdata_end = .;
112
113	__init_end = .;
114
115	_sdata = .;
116	RO_DATA(4096)
117	RW_DATA(1 << CONFIG_L1_CACHE_SHIFT, PAGE_SIZE, THREAD_SIZE)
118
119	.rela.dyn : ALIGN(8) {
120		__rela_dyn_begin = .;
121		 *(.rela.dyn) *(.rela*)
122		__rela_dyn_end = .;
123	}
124
125	.sdata : {
126		*(.sdata)
127	}
128	.edata_padding : { BYTE(0); . = ALIGN(PECOFF_FILE_ALIGN); }
129	_edata =  .;
130
131	BSS_SECTION(0, SZ_64K, 8)
132	. = ALIGN(PECOFF_SEGMENT_ALIGN);
133
134	_end = .;
135
136	STABS_DEBUG
137	DWARF_DEBUG
138	ELF_DETAILS
139
140	.gptab.sdata : {
141		*(.gptab.data)
142		*(.gptab.sdata)
143	}
144	.gptab.sbss : {
145		*(.gptab.bss)
146		*(.gptab.sbss)
147	}
148
149	DISCARDS
150	/DISCARD/ : {
151		*(.dynamic .dynsym .dynstr .hash .gnu.hash)
152		*(.gnu.attributes)
153		*(.options)
154		*(.eh_frame)
155	}
156}
157