xref: /openbmc/linux/arch/arm64/kernel/vmlinux.lds.S (revision 8684014d)
1/*
2 * ld script to make ARM Linux kernel
3 * taken from the i386 version by Russell King
4 * Written by Martin Mares <mj@atrey.karlin.mff.cuni.cz>
5 */
6
7#include <asm-generic/vmlinux.lds.h>
8#include <asm/thread_info.h>
9#include <asm/memory.h>
10#include <asm/page.h>
11
12#include "image.h"
13
14/* .exit.text needed in case of alternative patching */
15#define ARM_EXIT_KEEP(x)	x
16#define ARM_EXIT_DISCARD(x)
17
18OUTPUT_ARCH(aarch64)
19ENTRY(_text)
20
21jiffies = jiffies_64;
22
23#define HYPERVISOR_TEXT					\
24	/*						\
25	 * Force the alignment to be compatible with	\
26	 * the vectors requirements			\
27	 */						\
28	. = ALIGN(2048);				\
29	VMLINUX_SYMBOL(__hyp_idmap_text_start) = .;	\
30	*(.hyp.idmap.text)				\
31	VMLINUX_SYMBOL(__hyp_idmap_text_end) = .;	\
32	VMLINUX_SYMBOL(__hyp_text_start) = .;		\
33	*(.hyp.text)					\
34	VMLINUX_SYMBOL(__hyp_text_end) = .;
35
36/*
37 * The size of the PE/COFF section that covers the kernel image, which
38 * runs from stext to _edata, must be a round multiple of the PE/COFF
39 * FileAlignment, which we set to its minimum value of 0x200. 'stext'
40 * itself is 4 KB aligned, so padding out _edata to a 0x200 aligned
41 * boundary should be sufficient.
42 */
43PECOFF_FILE_ALIGNMENT = 0x200;
44
45#ifdef CONFIG_EFI
46#define PECOFF_EDATA_PADDING	\
47	.pecoff_edata_padding : { BYTE(0); . = ALIGN(PECOFF_FILE_ALIGNMENT); }
48#else
49#define PECOFF_EDATA_PADDING
50#endif
51
52SECTIONS
53{
54	/*
55	 * XXX: The linker does not define how output sections are
56	 * assigned to input sections when there are multiple statements
57	 * matching the same input section name.  There is no documented
58	 * order of matching.
59	 */
60	/DISCARD/ : {
61		ARM_EXIT_DISCARD(EXIT_TEXT)
62		ARM_EXIT_DISCARD(EXIT_DATA)
63		EXIT_CALL
64		*(.discard)
65		*(.discard.*)
66	}
67
68	. = PAGE_OFFSET + TEXT_OFFSET;
69
70	.head.text : {
71		_text = .;
72		HEAD_TEXT
73	}
74	.text : {			/* Real text segment		*/
75		_stext = .;		/* Text and read-only data	*/
76			__exception_text_start = .;
77			*(.exception.text)
78			__exception_text_end = .;
79			IRQENTRY_TEXT
80			TEXT_TEXT
81			SCHED_TEXT
82			LOCK_TEXT
83			HYPERVISOR_TEXT
84			*(.fixup)
85			*(.gnu.warning)
86		. = ALIGN(16);
87		*(.got)			/* Global offset table		*/
88	}
89
90	RO_DATA(PAGE_SIZE)
91	EXCEPTION_TABLE(8)
92	NOTES
93	_etext = .;			/* End of text and rodata section */
94
95	. = ALIGN(PAGE_SIZE);
96	__init_begin = .;
97
98	INIT_TEXT_SECTION(8)
99	.exit.text : {
100		ARM_EXIT_KEEP(EXIT_TEXT)
101	}
102	. = ALIGN(16);
103	.init.data : {
104		INIT_DATA
105		INIT_SETUP(16)
106		INIT_CALLS
107		CON_INITCALL
108		SECURITY_INITCALL
109		INIT_RAM_FS
110	}
111	.exit.data : {
112		ARM_EXIT_KEEP(EXIT_DATA)
113	}
114
115	PERCPU_SECTION(64)
116
117	. = ALIGN(PAGE_SIZE);
118	__init_end = .;
119
120	. = ALIGN(4);
121	.altinstructions : {
122		__alt_instructions = .;
123		*(.altinstructions)
124		__alt_instructions_end = .;
125	}
126	.altinstr_replacement : {
127		*(.altinstr_replacement)
128	}
129
130	. = ALIGN(PAGE_SIZE);
131	_data = .;
132	_sdata = .;
133	RW_DATA_SECTION(64, PAGE_SIZE, THREAD_SIZE)
134	PECOFF_EDATA_PADDING
135	_edata = .;
136
137	BSS_SECTION(0, 0, 0)
138
139	. = ALIGN(PAGE_SIZE);
140	idmap_pg_dir = .;
141	. += IDMAP_DIR_SIZE;
142	swapper_pg_dir = .;
143	. += SWAPPER_DIR_SIZE;
144
145	_end = .;
146
147	STABS_DEBUG
148
149	HEAD_SYMBOLS
150}
151
152/*
153 * The HYP init code can't be more than a page long.
154 */
155ASSERT(((__hyp_idmap_text_start + PAGE_SIZE) > __hyp_idmap_text_end),
156       "HYP init code too big")
157
158/*
159 * If padding is applied before .head.text, virt<->phys conversions will fail.
160 */
161ASSERT(_text == (PAGE_OFFSET + TEXT_OFFSET), "HEAD is misaligned")
162