xref: /openbmc/linux/arch/s390/kernel/vmlinux.lds.S (revision fa8c052b)
1/* SPDX-License-Identifier: GPL-2.0 */
2/* ld script to make s390 Linux kernel
3 * Written by Martin Schwidefsky (schwidefsky@de.ibm.com)
4 */
5
6#include <asm/thread_info.h>
7#include <asm/page.h>
8#include <asm/ftrace.lds.h>
9
10/*
11 * Put .bss..swapper_pg_dir as the first thing in .bss. This will
12 * make sure it has 16k alignment.
13 */
14#define BSS_FIRST_SECTIONS *(.bss..swapper_pg_dir) \
15			   *(.bss..invalid_pg_dir)
16
17/* Handle ro_after_init data on our own. */
18#define RO_AFTER_INIT_DATA
19
20#define RUNTIME_DISCARD_EXIT
21
22#define EMITS_PT_NOTE
23
24#include <asm-generic/vmlinux.lds.h>
25#include <asm/vmlinux.lds.h>
26
27OUTPUT_FORMAT("elf64-s390", "elf64-s390", "elf64-s390")
28OUTPUT_ARCH(s390:64-bit)
29ENTRY(startup_continue)
30jiffies = jiffies_64;
31
32PHDRS {
33	text PT_LOAD FLAGS(5);	/* R_E */
34	data PT_LOAD FLAGS(7);	/* RWE */
35	note PT_NOTE FLAGS(0);	/* ___ */
36}
37
38SECTIONS
39{
40	. = 0x100000;
41	.text : {
42		_stext = .;		/* Start of text section */
43		_text = .;		/* Text and read-only data */
44		HEAD_TEXT
45		TEXT_TEXT
46		SCHED_TEXT
47		LOCK_TEXT
48		KPROBES_TEXT
49		IRQENTRY_TEXT
50		SOFTIRQENTRY_TEXT
51		FTRACE_HOTPATCH_TRAMPOLINES_TEXT
52		*(.text.*_indirect_*)
53		*(.gnu.warning)
54		. = ALIGN(PAGE_SIZE);
55		_etext = .;		/* End of text section */
56	} :text = 0x0700
57
58	RO_DATA(PAGE_SIZE)
59
60	. = ALIGN(PAGE_SIZE);
61	_sdata = .;		/* Start of data section */
62
63	. = ALIGN(PAGE_SIZE);
64	__start_ro_after_init = .;
65	.data..ro_after_init : {
66		 *(.data..ro_after_init)
67		JUMP_TABLE_DATA
68	} :data
69	EXCEPTION_TABLE(16)
70	. = ALIGN(PAGE_SIZE);
71	__end_ro_after_init = .;
72
73	RW_DATA(0x100, PAGE_SIZE, THREAD_SIZE)
74	BOOT_DATA_PRESERVED
75
76	. = ALIGN(8);
77	.amode31.refs : {
78		_start_amode31_refs = .;
79		*(.amode31.refs)
80		_end_amode31_refs = .;
81	}
82
83	. = ALIGN(PAGE_SIZE);
84	_edata = .;		/* End of data section */
85
86	/* will be freed after init */
87	. = ALIGN(PAGE_SIZE);	/* Init code and data */
88	__init_begin = .;
89
90	. = ALIGN(PAGE_SIZE);
91	.init.text : AT(ADDR(.init.text) - LOAD_OFFSET) {
92		_sinittext = .;
93		INIT_TEXT
94		. = ALIGN(PAGE_SIZE);
95		_einittext = .;
96	}
97
98	/*
99	 * .exit.text is discarded at runtime, not link time,
100	 * to deal with references from __bug_table
101	*/
102	.exit.text : {
103		EXIT_TEXT
104	}
105
106	.exit.data : {
107		EXIT_DATA
108	}
109
110	/*
111	 * struct alt_inst entries. From the header (alternative.h):
112	 * "Alternative instructions for different CPU types or capabilities"
113	 * Think locking instructions on spinlocks.
114	 * Note, that it is a part of __init region.
115	 */
116	. = ALIGN(8);
117	.altinstructions : {
118		__alt_instructions = .;
119		*(.altinstructions)
120		__alt_instructions_end = .;
121	}
122
123	/*
124	 * And here are the replacement instructions. The linker sticks
125	 * them as binary blobs. The .altinstructions has enough data to
126	 * get the address and the length of them to patch the kernel safely.
127	 * Note, that it is a part of __init region.
128	 */
129	.altinstr_replacement : {
130		*(.altinstr_replacement)
131	}
132
133	/*
134	 * Table with the patch locations to undo expolines
135	*/
136	. = ALIGN(4);
137	.nospec_call_table : {
138		__nospec_call_start = . ;
139		*(.s390_indirect*)
140		__nospec_call_end = . ;
141	}
142	.nospec_return_table : {
143		__nospec_return_start = . ;
144		*(.s390_return*)
145		__nospec_return_end = . ;
146	}
147
148	BOOT_DATA
149
150	/*
151	 * .amode31 section for code, data, ex_table that need to stay
152	 * below 2 GB, even when the kernel is relocated above 2 GB.
153	 */
154	. = ALIGN(PAGE_SIZE);
155	_samode31 = .;
156	.amode31.text : {
157		_stext_amode31 = .;
158		*(.amode31.text)
159		*(.amode31.text.*_indirect_*)
160		. = ALIGN(PAGE_SIZE);
161		_etext_amode31 = .;
162	}
163	. = ALIGN(16);
164	.amode31.ex_table : {
165		_start_amode31_ex_table = .;
166		KEEP(*(.amode31.ex_table))
167		_stop_amode31_ex_table = .;
168	}
169	. = ALIGN(PAGE_SIZE);
170	.amode31.data : {
171		*(.amode31.data)
172	}
173	. = ALIGN(PAGE_SIZE);
174	_eamode31 = .;
175
176	/* early.c uses stsi, which requires page aligned data. */
177	. = ALIGN(PAGE_SIZE);
178	INIT_DATA_SECTION(0x100)
179
180	PERCPU_SECTION(0x100)
181
182	.dynsym ALIGN(8) : {
183		__dynsym_start = .;
184		*(.dynsym)
185		__dynsym_end = .;
186	}
187	.rela.dyn ALIGN(8) : {
188		__rela_dyn_start = .;
189		*(.rela*)
190		__rela_dyn_end = .;
191	}
192
193	. = ALIGN(PAGE_SIZE);
194	__init_end = .;		/* freed after init ends here */
195
196	BSS_SECTION(PAGE_SIZE, 4 * PAGE_SIZE, PAGE_SIZE)
197
198	. = ALIGN(PAGE_SIZE);
199	_end = . ;
200
201	/*
202	 * uncompressed image info used by the decompressor
203	 * it should match struct vmlinux_info
204	 */
205	.vmlinux.info 0 (INFO) : {
206		QUAD(_stext)					/* default_lma */
207		QUAD(startup_continue)				/* entry */
208		QUAD(__bss_start - _stext)			/* image_size */
209		QUAD(__bss_stop - __bss_start)			/* bss_size */
210		QUAD(__boot_data_start)				/* bootdata_off */
211		QUAD(__boot_data_end - __boot_data_start)	/* bootdata_size */
212		QUAD(__boot_data_preserved_start)		/* bootdata_preserved_off */
213		QUAD(__boot_data_preserved_end -
214		     __boot_data_preserved_start)		/* bootdata_preserved_size */
215		QUAD(__dynsym_start)				/* dynsym_start */
216		QUAD(__rela_dyn_start)				/* rela_dyn_start */
217		QUAD(__rela_dyn_end)				/* rela_dyn_end */
218		QUAD(_eamode31 - _samode31)			/* amode31_size */
219		QUAD(init_mm)
220		QUAD(swapper_pg_dir)
221		QUAD(invalid_pg_dir)
222	} :NONE
223
224	/* Debugging sections.	*/
225	STABS_DEBUG
226	DWARF_DEBUG
227	ELF_DETAILS
228
229	/* Sections to be discarded */
230	DISCARDS
231	/DISCARD/ : {
232		*(.eh_frame)
233		*(.interp)
234	}
235}
236