xref: /openbmc/linux/arch/arm64/kernel/vmlinux.lds.S (revision da57a369d3bc5cd61db90f7e9555840381db9b09)
18c2c3df3SCatalin Marinas/*
28c2c3df3SCatalin Marinas * ld script to make ARM Linux kernel
38c2c3df3SCatalin Marinas * taken from the i386 version by Russell King
48c2c3df3SCatalin Marinas * Written by Martin Mares <mj@atrey.karlin.mff.cuni.cz>
58c2c3df3SCatalin Marinas */
68c2c3df3SCatalin Marinas
78c2c3df3SCatalin Marinas#include <asm-generic/vmlinux.lds.h>
88c2c3df3SCatalin Marinas#include <asm/thread_info.h>
98c2c3df3SCatalin Marinas#include <asm/memory.h>
108c2c3df3SCatalin Marinas#include <asm/page.h>
118c2c3df3SCatalin Marinas
12a2c1d73bSMark Rutland#include "image.h"
13a2c1d73bSMark Rutland
148c2c3df3SCatalin Marinas#define ARM_EXIT_KEEP(x)
158c2c3df3SCatalin Marinas#define ARM_EXIT_DISCARD(x)	x
168c2c3df3SCatalin Marinas
178c2c3df3SCatalin MarinasOUTPUT_ARCH(aarch64)
18af885f40SGeoff LevandENTRY(_text)
198c2c3df3SCatalin Marinas
208c2c3df3SCatalin Marinasjiffies = jiffies_64;
218c2c3df3SCatalin Marinas
222240bbb6SMarc Zyngier#define HYPERVISOR_TEXT					\
232240bbb6SMarc Zyngier	/*						\
242240bbb6SMarc Zyngier	 * Force the alignment to be compatible with	\
252240bbb6SMarc Zyngier	 * the vectors requirements			\
262240bbb6SMarc Zyngier	 */						\
272240bbb6SMarc Zyngier	. = ALIGN(2048);				\
282240bbb6SMarc Zyngier	VMLINUX_SYMBOL(__hyp_idmap_text_start) = .;	\
292240bbb6SMarc Zyngier	*(.hyp.idmap.text)				\
302240bbb6SMarc Zyngier	VMLINUX_SYMBOL(__hyp_idmap_text_end) = .;	\
312240bbb6SMarc Zyngier	VMLINUX_SYMBOL(__hyp_text_start) = .;		\
322240bbb6SMarc Zyngier	*(.hyp.text)					\
332240bbb6SMarc Zyngier	VMLINUX_SYMBOL(__hyp_text_end) = .;
342240bbb6SMarc Zyngier
358c2c3df3SCatalin MarinasSECTIONS
368c2c3df3SCatalin Marinas{
378c2c3df3SCatalin Marinas	/*
388c2c3df3SCatalin Marinas	 * XXX: The linker does not define how output sections are
398c2c3df3SCatalin Marinas	 * assigned to input sections when there are multiple statements
408c2c3df3SCatalin Marinas	 * matching the same input section name.  There is no documented
418c2c3df3SCatalin Marinas	 * order of matching.
428c2c3df3SCatalin Marinas	 */
438c2c3df3SCatalin Marinas	/DISCARD/ : {
448c2c3df3SCatalin Marinas		ARM_EXIT_DISCARD(EXIT_TEXT)
458c2c3df3SCatalin Marinas		ARM_EXIT_DISCARD(EXIT_DATA)
468c2c3df3SCatalin Marinas		EXIT_CALL
478c2c3df3SCatalin Marinas		*(.discard)
488c2c3df3SCatalin Marinas		*(.discard.*)
498c2c3df3SCatalin Marinas	}
508c2c3df3SCatalin Marinas
518c2c3df3SCatalin Marinas	. = PAGE_OFFSET + TEXT_OFFSET;
528c2c3df3SCatalin Marinas
538c2c3df3SCatalin Marinas	.head.text : {
548c2c3df3SCatalin Marinas		_text = .;
558c2c3df3SCatalin Marinas		HEAD_TEXT
568c2c3df3SCatalin Marinas	}
578c2c3df3SCatalin Marinas	.text : {			/* Real text segment		*/
588c2c3df3SCatalin Marinas		_stext = .;		/* Text and read-only data	*/
598c2c3df3SCatalin Marinas			__exception_text_start = .;
608c2c3df3SCatalin Marinas			*(.exception.text)
618c2c3df3SCatalin Marinas			__exception_text_end = .;
628c2c3df3SCatalin Marinas			IRQENTRY_TEXT
638c2c3df3SCatalin Marinas			TEXT_TEXT
648c2c3df3SCatalin Marinas			SCHED_TEXT
658c2c3df3SCatalin Marinas			LOCK_TEXT
662240bbb6SMarc Zyngier			HYPERVISOR_TEXT
678c2c3df3SCatalin Marinas			*(.fixup)
688c2c3df3SCatalin Marinas			*(.gnu.warning)
698c2c3df3SCatalin Marinas		. = ALIGN(16);
708c2c3df3SCatalin Marinas		*(.got)			/* Global offset table		*/
718c2c3df3SCatalin Marinas	}
728c2c3df3SCatalin Marinas
738c2c3df3SCatalin Marinas	RO_DATA(PAGE_SIZE)
74adace895SWill Deacon	EXCEPTION_TABLE(8)
75c80b7ee8SMark Salter	NOTES
768c2c3df3SCatalin Marinas	_etext = .;			/* End of text and rodata section */
778c2c3df3SCatalin Marinas
788c2c3df3SCatalin Marinas	. = ALIGN(PAGE_SIZE);
798c2c3df3SCatalin Marinas	__init_begin = .;
808c2c3df3SCatalin Marinas
818c2c3df3SCatalin Marinas	INIT_TEXT_SECTION(8)
828c2c3df3SCatalin Marinas	.exit.text : {
838c2c3df3SCatalin Marinas		ARM_EXIT_KEEP(EXIT_TEXT)
848c2c3df3SCatalin Marinas	}
858c2c3df3SCatalin Marinas	. = ALIGN(16);
868c2c3df3SCatalin Marinas	.init.data : {
878c2c3df3SCatalin Marinas		INIT_DATA
888c2c3df3SCatalin Marinas		INIT_SETUP(16)
898c2c3df3SCatalin Marinas		INIT_CALLS
908c2c3df3SCatalin Marinas		CON_INITCALL
918c2c3df3SCatalin Marinas		SECURITY_INITCALL
928c2c3df3SCatalin Marinas		INIT_RAM_FS
938c2c3df3SCatalin Marinas	}
948c2c3df3SCatalin Marinas	.exit.data : {
958c2c3df3SCatalin Marinas		ARM_EXIT_KEEP(EXIT_DATA)
968c2c3df3SCatalin Marinas	}
978c2c3df3SCatalin Marinas
988c2c3df3SCatalin Marinas	PERCPU_SECTION(64)
998c2c3df3SCatalin Marinas
1008c2c3df3SCatalin Marinas	__init_end = .;
1018c2c3df3SCatalin Marinas
1023c620626SMark Salter	. = ALIGN(PAGE_SIZE);
1033c620626SMark Salter	_data = .;
1048c2c3df3SCatalin Marinas	_sdata = .;
1053c620626SMark Salter	RW_DATA_SECTION(64, PAGE_SIZE, THREAD_SIZE)
1068c2c3df3SCatalin Marinas	_edata = .;
1078c2c3df3SCatalin Marinas
1088c2c3df3SCatalin Marinas	BSS_SECTION(0, 0, 0)
109bd00cd5fSMark Rutland
110bd00cd5fSMark Rutland	. = ALIGN(PAGE_SIZE);
111bd00cd5fSMark Rutland	idmap_pg_dir = .;
112bd00cd5fSMark Rutland	. += IDMAP_DIR_SIZE;
113bd00cd5fSMark Rutland	swapper_pg_dir = .;
114bd00cd5fSMark Rutland	. += SWAPPER_DIR_SIZE;
115bd00cd5fSMark Rutland
1168c2c3df3SCatalin Marinas	_end = .;
1178c2c3df3SCatalin Marinas
1188c2c3df3SCatalin Marinas	STABS_DEBUG
119a2c1d73bSMark Rutland
120a2c1d73bSMark Rutland	HEAD_SYMBOLS
1218c2c3df3SCatalin Marinas}
1222240bbb6SMarc Zyngier
1232240bbb6SMarc Zyngier/*
1242240bbb6SMarc Zyngier * The HYP init code can't be more than a page long.
1252240bbb6SMarc Zyngier */
1262240bbb6SMarc ZyngierASSERT(((__hyp_idmap_text_start + PAGE_SIZE) > __hyp_idmap_text_end),
1272240bbb6SMarc Zyngier       "HYP init code too big")
128*da57a369SMark Rutland
129*da57a369SMark Rutland/*
130*da57a369SMark Rutland * If padding is applied before .head.text, virt<->phys conversions will fail.
131*da57a369SMark Rutland */
132*da57a369SMark RutlandASSERT(_text == (PAGE_OFFSET + TEXT_OFFSET), "HEAD is misaligned")
133