1/* SPDX-License-Identifier: GPL-2.0 */
2#include <asm-generic/vmlinux.lds.h>
3#include <asm/vmlinux.lds.h>
4#include <asm/thread_info.h>
5#include <asm/page.h>
6#include <asm/sclp.h>
7#include "boot.h"
8
9OUTPUT_FORMAT("elf64-s390", "elf64-s390", "elf64-s390")
10OUTPUT_ARCH(s390:64-bit)
11
12ENTRY(startup)
13
14SECTIONS
15{
16	. = 0;
17	.ipldata : {
18		*(.ipldata)
19	}
20	. = IPL_START;
21	.head.text : {
22		_head = . ;
23		HEAD_TEXT
24		_ehead = . ;
25	}
26	. = PARMAREA;
27	.parmarea : {
28		*(.parmarea)
29	}
30	.text :	{
31		_text = .;	/* Text */
32		*(.text)
33		*(.text.*)
34		INIT_TEXT
35		_etext = . ;
36	}
37	.rodata : {
38		_rodata = . ;
39		*(.rodata)	 /* read-only data */
40		*(.rodata.*)
41		_erodata = . ;
42	}
43	.got : {
44		*(.got)
45	}
46	NOTES
47	.data :	{
48		_data = . ;
49		*(.data)
50		*(.data.*)
51		_edata = . ;
52	}
53
54	BOOT_DATA
55	BOOT_DATA_PRESERVED
56
57	/*
58	 * This is the BSS section of the decompressor and not of the decompressed Linux kernel.
59	 * It will consume place in the decompressor's image.
60	 */
61	. = ALIGN(8);
62	.bss : {
63		_bss = . ;
64		*(.bss)
65		*(.bss.*)
66		*(COMMON)
67		/*
68		 * Stacks for the decompressor
69		 */
70		. = ALIGN(PAGE_SIZE);
71		_dump_info_stack_start = .;
72		. += PAGE_SIZE;
73		_dump_info_stack_end = .;
74		. = ALIGN(PAGE_SIZE);
75		_stack_start = .;
76		. += BOOT_STACK_SIZE;
77		_stack_end = .;
78		_ebss = .;
79	}
80
81	/*
82	 * uncompressed image info used by the decompressor it should match
83	 * struct vmlinux_info. It comes from .vmlinux.info section of
84	 * uncompressed vmlinux in a form of info.o
85	 */
86	. = ALIGN(8);
87	.vmlinux.info : {
88		_vmlinux_info = .;
89		*(.vmlinux.info)
90	}
91
92	.decompressor.syms : {
93		. += 1; /* make sure we have \0 before the first entry */
94		. = ALIGN(2);
95		_decompressor_syms_start = .;
96		*(.decompressor.syms)
97		_decompressor_syms_end = .;
98	}
99
100	_decompressor_end = .;
101
102#ifdef CONFIG_KERNEL_UNCOMPRESSED
103	. = 0x100000;
104#else
105	. = ALIGN(8);
106#endif
107	.rodata.compressed : {
108		_compressed_start = .;
109		*(.vmlinux.bin.compressed)
110		_compressed_end = .;
111	}
112
113#ifndef CONFIG_PIE_BUILD
114	/*
115	 * When the kernel is built with CONFIG_KERNEL_UNCOMPRESSED, the entire
116	 * uncompressed vmlinux.bin is positioned in the bzImage decompressor
117	 * image at the default kernel LMA of 0x100000, enabling it to be
118	 * executed in-place. However, the size of .vmlinux.relocs could be
119	 * large enough to cause an overlap with the uncompressed kernel at the
120	 * address 0x100000. To address this issue, .vmlinux.relocs is
121	 * positioned after the .rodata.compressed.
122	 */
123	. = ALIGN(4);
124	.vmlinux.relocs : {
125		__vmlinux_relocs_64_start = .;
126		*(.vmlinux.relocs_64)
127		__vmlinux_relocs_64_end = .;
128	}
129#endif
130
131#define SB_TRAILER_SIZE 32
132	/* Trailer needed for Secure Boot */
133	. += SB_TRAILER_SIZE; /* make sure .sb.trailer does not overwrite the previous section */
134	. = ALIGN(4096) - SB_TRAILER_SIZE;
135	.sb.trailer : {
136		QUAD(0)
137		QUAD(0)
138		QUAD(0)
139		QUAD(0x000000207a49504c)
140	}
141	_end = .;
142
143	DWARF_DEBUG
144	ELF_DETAILS
145
146	/*
147	 * Make sure that the .got.plt is either completely empty or it
148	 * contains only the three reserved double words.
149	 */
150	.got.plt : {
151		*(.got.plt)
152	}
153	ASSERT(SIZEOF(.got.plt) == 0 || SIZEOF(.got.plt) == 0x18, "Unexpected GOT/PLT entries detected!")
154
155	/*
156	 * Sections that should stay zero sized, which is safer to
157	 * explicitly check instead of blindly discarding.
158	 */
159	.plt : {
160		*(.plt) *(.plt.*) *(.iplt) *(.igot .igot.plt)
161	}
162	ASSERT(SIZEOF(.plt) == 0, "Unexpected run-time procedure linkages detected!")
163	.rela.dyn : {
164		*(.rela.*) *(.rela_*)
165	}
166	ASSERT(SIZEOF(.rela.dyn) == 0, "Unexpected run-time relocations (.rela) detected!")
167
168	/* Sections to be discarded */
169	/DISCARD/ : {
170		COMMON_DISCARDS
171		*(.eh_frame)
172		*(__ex_table)
173		*(*__ksymtab*)
174		*(___kcrctab*)
175	}
176}
177