xref: /openbmc/linux/arch/mips/kernel/vmlinux.lds.S (revision 1ac731c529cd4d6adbce134754b51ff7d822b145)
1b2441318SGreg Kroah-Hartman/* SPDX-License-Identifier: GPL-2.0 */
2dbee90b7SRalf Baechle#include <asm/asm-offsets.h>
37b1c0d26SDavid Daney#include <asm/thread_info.h>
4485172b3SDavid Daney
5bef9ae3dSRalf Baechle#define PAGE_SIZE _PAGE_SIZE
6bef9ae3dSRalf Baechle
7485172b3SDavid Daney/*
8485172b3SDavid Daney * Put .bss..swapper_pg_dir as the first thing in .bss. This will
9485172b3SDavid Daney * ensure that it has .bss alignment (64K).
10485172b3SDavid Daney */
11485172b3SDavid Daney#define BSS_FIRST_SECTIONS *(.bss..swapper_pg_dir)
12485172b3SDavid Daney
13441110a5SKees Cook/* Cavium Octeon should not have a separate PT_NOTE Program Header. */
14441110a5SKees Cook#ifndef CONFIG_CAVIUM_OCTEON_SOC
15441110a5SKees Cook#define EMITS_PT_NOTE
16441110a5SKees Cook#endif
17441110a5SKees Cook
18*6dcbd0a6SJiaxun Yang#define RUNTIME_DISCARD_EXIT
19*6dcbd0a6SJiaxun Yang
201da177e4SLinus Torvalds#include <asm-generic/vmlinux.lds.h>
211da177e4SLinus Torvalds
2241c594abSRalf Baechle#undef mips
231da177e4SLinus Torvalds#define mips mips
241da177e4SLinus TorvaldsOUTPUT_ARCH(mips)
251da177e4SLinus TorvaldsENTRY(kernel_entry)
26603bb99cSRalf BaechlePHDRS {
27603bb99cSRalf Baechle	text PT_LOAD FLAGS(7);	/* RWX */
283bfb7224SDavid Daney#ifndef CONFIG_CAVIUM_OCTEON_SOC
29603bb99cSRalf Baechle	note PT_NOTE FLAGS(4);	/* R__ */
303bfb7224SDavid Daney#endif /* CAVIUM_OCTEON_SOC */
31603bb99cSRalf Baechle}
3251b563fcSSam Ravnborg
33d71789b6SManuel Lauss#ifdef CONFIG_32BIT
34d71789b6SManuel Lauss	#ifdef CONFIG_CPU_LITTLE_ENDIAN
3551b563fcSSam Ravnborg		jiffies	 = jiffies_64;
36d71789b6SManuel Lauss	#else
3751b563fcSSam Ravnborg		jiffies	 = jiffies_64 + 4;
38d71789b6SManuel Lauss	#endif
39d71789b6SManuel Lauss#else
4051b563fcSSam Ravnborg	jiffies	 = jiffies_64;
41d71789b6SManuel Lauss#endif
420f5c9064SSam Ravnborg
431da177e4SLinus TorvaldsSECTIONS
441da177e4SLinus Torvalds{
451da177e4SLinus Torvalds#ifdef CONFIG_BOOT_ELF64
461da177e4SLinus Torvalds	/* Read-only sections, merged into text segment: */
471da177e4SLinus Torvalds	/* . = 0xc000000000000000; */
481da177e4SLinus Torvalds
491da177e4SLinus Torvalds	/* This is the value for an Origin kernel, taken from an IRIX kernel.  */
501da177e4SLinus Torvalds	/* . = 0xc00000000001c000; */
511da177e4SLinus Torvalds
521da177e4SLinus Torvalds	/* Set the vaddr for the text segment to a value
530f5c9064SSam Ravnborg	 *   >= 0xa800 0000 0001 9000 if no symmon is going to configured
540f5c9064SSam Ravnborg	 *   >= 0xa800 0000 0030 0000 otherwise
550f5c9064SSam Ravnborg	 */
561da177e4SLinus Torvalds
571da177e4SLinus Torvalds	/* . = 0xa800000000300000; */
581da177e4SLinus Torvalds	. = 0xffffffff80300000;
591da177e4SLinus Torvalds#endif
60ff487d41SJiaxun Yang	. = LINKER_LOAD_ADDRESS;
611da177e4SLinus Torvalds	/* read-only */
621da177e4SLinus Torvalds	_text = .;	/* Text and read-only data */
631da177e4SLinus Torvalds	.text : {
647664709bSSam Ravnborg		TEXT_TEXT
651da177e4SLinus Torvalds		SCHED_TEXT
661da177e4SLinus Torvalds		LOCK_TEXT
67f70fd1b5SRalf Baechle		KPROBES_TEXT
688f99a162SWu Zhangjin		IRQENTRY_TEXT
69be7635e7SAlexander Potapenko		SOFTIRQENTRY_TEXT
701da177e4SLinus Torvalds		*(.fixup)
711da177e4SLinus Torvalds		*(.gnu.warning)
72795b3a36SAlexander Lobakin		. = ALIGN(16);
73795b3a36SAlexander Lobakin		*(.got)	/* Global offset table */
74603bb99cSRalf Baechle	} :text = 0
751da177e4SLinus Torvalds	_etext = .;	/* End of text section */
761da177e4SLinus Torvalds
776eb10bc9SNelson Elhage	EXCEPTION_TABLE(16)
781da177e4SLinus Torvalds
790f5c9064SSam Ravnborg	/* Exception table for data bus errors */
800f5c9064SSam Ravnborg	__dbe_table : {
810f5c9064SSam Ravnborg		__start___dbe_table = .;
82c0436b50SPaul Burton		KEEP(*(__dbe_table))
831da177e4SLinus Torvalds		__stop___dbe_table = .;
840f5c9064SSam Ravnborg	}
85603bb99cSRalf Baechle
86a2d063acSSteven Rostedt	_sdata = .;			/* Start of data section */
87c8231825SKees Cook	RO_DATA(4096)
881da177e4SLinus Torvalds
891da177e4SLinus Torvalds	/* writeable */
901da177e4SLinus Torvalds	.data : {	/* Data */
911da177e4SLinus Torvalds		. = . + DATAOFFSET;		/* for CONFIG_MAPPED_KERNEL */
921da177e4SLinus Torvalds
937b1c0d26SDavid Daney		INIT_TASK_DATA(THREAD_SIZE)
946eb10bc9SNelson Elhage		NOSAVE_DATA
958ac7c87aSAlexander Lobakin		PAGE_ALIGNED_DATA(PAGE_SIZE)
966eb10bc9SNelson Elhage		CACHELINE_ALIGNED_DATA(1 << CONFIG_MIPS_L1_CACHE_SHIFT)
97f8bec75aSCatalin Marinas		READ_MOSTLY_DATA(1 << CONFIG_MIPS_L1_CACHE_SHIFT)
98ca967258SSam Ravnborg		DATA_DATA
991da177e4SLinus Torvalds		CONSTRUCTORS
1001da177e4SLinus Torvalds	}
101b5effd38SPeter Zijlstra	BUG_TABLE
1021da177e4SLinus Torvalds	_gp = . + 0x8000;
1030f5c9064SSam Ravnborg	.lit8 : {
1040f5c9064SSam Ravnborg		*(.lit8)
1050f5c9064SSam Ravnborg	}
1060f5c9064SSam Ravnborg	.lit4 : {
1070f5c9064SSam Ravnborg		*(.lit4)
1080f5c9064SSam Ravnborg	}
1091da177e4SLinus Torvalds	/* We want the small data sections together, so single-instruction offsets
1101da177e4SLinus Torvalds	   can access them all, and initialized data all before uninitialized, so
1111da177e4SLinus Torvalds	   we can shorten the on-disk segment size.  */
1120f5c9064SSam Ravnborg	.sdata : {
1130f5c9064SSam Ravnborg		*(.sdata)
1140f5c9064SSam Ravnborg	}
1151da177e4SLinus Torvalds	_edata =  .;			/* End of data section */
1161da177e4SLinus Torvalds
1171da177e4SLinus Torvalds	/* will be freed after init */
118a0b54e25SNelson Elhage	. = ALIGN(PAGE_SIZE);		/* Init code and data */
1191da177e4SLinus Torvalds	__init_begin = .;
1206eb10bc9SNelson Elhage	INIT_TEXT_SECTION(PAGE_SIZE)
1216eb10bc9SNelson Elhage	INIT_DATA_SECTION(16)
1220f5c9064SSam Ravnborg
123487d70d0SGabor Juhos	. = ALIGN(4);
124487d70d0SGabor Juhos	.mips.machines.init : AT(ADDR(.mips.machines.init) - LOAD_OFFSET) {
125487d70d0SGabor Juhos		__mips_machines_start = .;
126c0436b50SPaul Burton		KEEP(*(.mips.machines.init))
127487d70d0SGabor Juhos		__mips_machines_end = .;
128487d70d0SGabor Juhos	}
129487d70d0SGabor Juhos
1302efac77eSRalf Baechle	/* .exit.text is discarded at runtime, not link time, to deal with
1310f5c9064SSam Ravnborg	 * references from .rodata
1320f5c9064SSam Ravnborg	 */
1330f5c9064SSam Ravnborg	.exit.text : {
13401ba2bdcSSam Ravnborg		EXIT_TEXT
1350f5c9064SSam Ravnborg	}
1360f5c9064SSam Ravnborg	.exit.data : {
13701ba2bdcSSam Ravnborg		EXIT_DATA
1380f5c9064SSam Ravnborg	}
1391da8f179SJonas Gorski#ifdef CONFIG_SMP
1400415b00dSTejun Heo	PERCPU_SECTION(1 << CONFIG_MIPS_L1_CACHE_SHIFT)
1411da8f179SJonas Gorski#endif
142069fd766SMatt Redfearn
143008c3cbdSAlexander Lobakin	.rel.dyn : ALIGN(8) {
144008c3cbdSAlexander Lobakin		*(.rel)
145008c3cbdSAlexander Lobakin		*(.rel*)
146008c3cbdSAlexander Lobakin	}
147008c3cbdSAlexander Lobakin
1483f0a53bcSYasha Cherikovsky#ifdef CONFIG_MIPS_ELF_APPENDED_DTB
1497a05293aSPaul Cercueil	STRUCT_ALIGN();
1503f0a53bcSYasha Cherikovsky	.appended_dtb : AT(ADDR(.appended_dtb) - LOAD_OFFSET) {
1513f0a53bcSYasha Cherikovsky		*(.appended_dtb)
1523f0a53bcSYasha Cherikovsky		KEEP(*(.appended_dtb))
1533f0a53bcSYasha Cherikovsky	}
1543f0a53bcSYasha Cherikovsky#endif
1553f0a53bcSYasha Cherikovsky
156069fd766SMatt Redfearn#ifdef CONFIG_RELOCATABLE
157069fd766SMatt Redfearn	. = ALIGN(4);
158069fd766SMatt Redfearn
159069fd766SMatt Redfearn	.data.reloc : {
160069fd766SMatt Redfearn		_relocation_start = .;
161069fd766SMatt Redfearn		/*
162069fd766SMatt Redfearn		 * Space for relocation table
163069fd766SMatt Redfearn		 * This needs to be filled so that the
164069fd766SMatt Redfearn		 * relocs tool can overwrite the content.
165069fd766SMatt Redfearn		 * An invalid value is left at the start of the
166069fd766SMatt Redfearn		 * section to abort relocation if the table
167069fd766SMatt Redfearn		 * has not been filled in.
168069fd766SMatt Redfearn		 */
169069fd766SMatt Redfearn		LONG(0xFFFFFFFF);
170069fd766SMatt Redfearn		FILL(0);
171069fd766SMatt Redfearn		. += CONFIG_RELOCATION_TABLE_SIZE - 4;
172069fd766SMatt Redfearn		_relocation_end = .;
173069fd766SMatt Redfearn	}
174069fd766SMatt Redfearn#endif
175069fd766SMatt Redfearn
1761da8f179SJonas Gorski#ifdef CONFIG_MIPS_RAW_APPENDED_DTB
1776654111cSBjørn Mork	.fill : {
1786654111cSBjørn Mork		FILL(0);
1796654111cSBjørn Mork		BYTE(0);
1803f6c515dSPaul Cercueil		STRUCT_ALIGN();
1816654111cSBjørn Mork	}
1821da8f179SJonas Gorski	__appended_dtb = .;
1831da8f179SJonas Gorski	/* leave space for appended DTB */
1841da8f179SJonas Gorski	. += 0x100000;
1851da8f179SJonas Gorski#endif
186485172b3SDavid Daney	/*
187485172b3SDavid Daney	 * Align to 64K in attempt to eliminate holes before the
188485172b3SDavid Daney	 * .bss..swapper_pg_dir section at the start of .bss.  This
189485172b3SDavid Daney	 * also satisfies PAGE_SIZE alignment as the largest page size
190485172b3SDavid Daney	 * allowed is 64K.
191485172b3SDavid Daney	 */
192485172b3SDavid Daney	. = ALIGN(0x10000);
1931da177e4SLinus Torvalds	__init_end = .;
1941da177e4SLinus Torvalds	/* freed after init ends here */
1951da177e4SLinus Torvalds
196485172b3SDavid Daney	/*
197485172b3SDavid Daney	 * Force .bss to 64K alignment so that .bss..swapper_pg_dir
198485172b3SDavid Daney	 * gets that alignment.	 .sbss should be empty, so there will be
199485172b3SDavid Daney	 * no holes after __init_end. */
2003f00f4d8SPaul Burton	BSS_SECTION(0, 0x10000, 8)
2011da177e4SLinus Torvalds
2021da177e4SLinus Torvalds	_end = . ;
2031da177e4SLinus Torvalds
2046c76988bSDaniel Jacobowitz	/* These mark the ABI of the kernel for debuggers.  */
2050f5c9064SSam Ravnborg	.mdebug.abi32 : {
2060f5c9064SSam Ravnborg		KEEP(*(.mdebug.abi32))
2070f5c9064SSam Ravnborg	}
2080f5c9064SSam Ravnborg	.mdebug.abi64 : {
2090f5c9064SSam Ravnborg		KEEP(*(.mdebug.abi64))
2100f5c9064SSam Ravnborg	}
2116c76988bSDaniel Jacobowitz
2121da177e4SLinus Torvalds	/* This is the MIPS specific mdebug section.  */
2130f5c9064SSam Ravnborg	.mdebug : {
2140f5c9064SSam Ravnborg		*(.mdebug)
2150f5c9064SSam Ravnborg	}
21678665aaaSAtsushi Nemoto
21778665aaaSAtsushi Nemoto	STABS_DEBUG
21804b6b3b6SAtsushi Nemoto	DWARF_DEBUG
219c604abc3SKees Cook	ELF_DETAILS
22004b6b3b6SAtsushi Nemoto
2211da177e4SLinus Torvalds	/* These must appear regardless of  .  */
2220f5c9064SSam Ravnborg	.gptab.sdata : {
2230f5c9064SSam Ravnborg		*(.gptab.data)
2240f5c9064SSam Ravnborg		*(.gptab.sdata)
2250f5c9064SSam Ravnborg	}
2260f5c9064SSam Ravnborg	.gptab.sbss : {
2270f5c9064SSam Ravnborg		*(.gptab.bss)
2280f5c9064SSam Ravnborg		*(.gptab.sbss)
2290f5c9064SSam Ravnborg	}
230023bf6f1STejun Heo
231023bf6f1STejun Heo	/* Sections to be discarded */
232023bf6f1STejun Heo	DISCARDS
233023bf6f1STejun Heo	/DISCARD/ : {
234023bf6f1STejun Heo		/* ABI crap starts here */
23561379878SAaro Koskinen		*(.MIPS.abiflags)
236023bf6f1STejun Heo		*(.MIPS.options)
2375629d418SAlexander Lobakin		*(.gnu.attributes)
238023bf6f1STejun Heo		*(.options)
239023bf6f1STejun Heo		*(.pdr)
240023bf6f1STejun Heo		*(.reginfo)
241023bf6f1STejun Heo	}
2421da177e4SLinus Torvalds}
243