blob: 33ee0d18fb0adc21d952c98fbf77b5ed8c514d6a [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Ralf Baechledbee90b2006-02-02 14:31:16 +00002#include <asm/asm-offsets.h>
David Daney7b1c0d22012-07-19 09:11:14 +02003#include <asm/thread_info.h>
David Daney485172b2012-08-14 11:08:01 -07004
Ralf Baechlebef9ae32012-12-28 15:15:25 +01005#define PAGE_SIZE _PAGE_SIZE
6
David Daney485172b2012-08-14 11:08:01 -07007/*
8 * Put .bss..swapper_pg_dir as the first thing in .bss. This will
9 * ensure that it has .bss alignment (64K).
10 */
11#define BSS_FIRST_SECTIONS *(.bss..swapper_pg_dir)
12
Linus Torvalds1da177e2005-04-16 15:20:36 -070013#include <asm-generic/vmlinux.lds.h>
14
Ralf Baechle41c594a2006-04-05 09:45:45 +010015#undef mips
Linus Torvalds1da177e2005-04-16 15:20:36 -070016#define mips mips
17OUTPUT_ARCH(mips)
18ENTRY(kernel_entry)
Ralf Baechle603bb992007-10-14 22:49:01 +010019PHDRS {
20 text PT_LOAD FLAGS(7); /* RWX */
David Daney3bfb7222015-10-30 00:54:48 +020021#ifndef CONFIG_CAVIUM_OCTEON_SOC
Ralf Baechle603bb992007-10-14 22:49:01 +010022 note PT_NOTE FLAGS(4); /* R__ */
David Daney3bfb7222015-10-30 00:54:48 +020023#endif /* CAVIUM_OCTEON_SOC */
Ralf Baechle603bb992007-10-14 22:49:01 +010024}
Sam Ravnborg51b563f2009-09-20 12:28:22 +020025
Manuel Laussd71789b2009-09-24 21:44:24 +020026#ifdef CONFIG_32BIT
27 #ifdef CONFIG_CPU_LITTLE_ENDIAN
Ralf Baechle70342282013-01-22 12:59:30 +010028 jiffies = jiffies_64;
Manuel Laussd71789b2009-09-24 21:44:24 +020029 #else
Ralf Baechle70342282013-01-22 12:59:30 +010030 jiffies = jiffies_64 + 4;
Manuel Laussd71789b2009-09-24 21:44:24 +020031 #endif
32#else
Ralf Baechle70342282013-01-22 12:59:30 +010033 jiffies = jiffies_64;
Manuel Laussd71789b2009-09-24 21:44:24 +020034#endif
Sam Ravnborg0f5c9062007-09-15 23:35:53 +020035
Linus Torvalds1da177e2005-04-16 15:20:36 -070036SECTIONS
37{
38#ifdef CONFIG_BOOT_ELF64
Sam Ravnborg0f5c9062007-09-15 23:35:53 +020039 /* Read-only sections, merged into text segment: */
40 /* . = 0xc000000000000000; */
Linus Torvalds1da177e2005-04-16 15:20:36 -070041
Sam Ravnborg0f5c9062007-09-15 23:35:53 +020042 /* This is the value for an Origin kernel, taken from an IRIX kernel. */
43 /* . = 0xc00000000001c000; */
Linus Torvalds1da177e2005-04-16 15:20:36 -070044
Sam Ravnborg0f5c9062007-09-15 23:35:53 +020045 /* Set the vaddr for the text segment to a value
46 * >= 0xa800 0000 0001 9000 if no symmon is going to configured
47 * >= 0xa800 0000 0030 0000 otherwise
48 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070049
Sam Ravnborg0f5c9062007-09-15 23:35:53 +020050 /* . = 0xa800000000300000; */
Sam Ravnborg0f5c9062007-09-15 23:35:53 +020051 . = 0xffffffff80300000;
Linus Torvalds1da177e2005-04-16 15:20:36 -070052#endif
Sam Ravnborg51b563f2009-09-20 12:28:22 +020053 . = VMLINUX_LOAD_ADDRESS;
Sam Ravnborg0f5c9062007-09-15 23:35:53 +020054 /* read-only */
55 _text = .; /* Text and read-only data */
56 .text : {
57 TEXT_TEXT
58 SCHED_TEXT
Chris Metcalf6727ad92016-10-07 17:02:55 -070059 CPUIDLE_TEXT
Sam Ravnborg0f5c9062007-09-15 23:35:53 +020060 LOCK_TEXT
Ralf Baechlef70fd1b2007-10-14 22:50:05 +010061 KPROBES_TEXT
Wu Zhangjin8f99a162009-11-20 20:34:33 +080062 IRQENTRY_TEXT
Alexander Potapenkobe7635e2016-03-25 14:22:05 -070063 SOFTIRQENTRY_TEXT
Atsushi Nemoto6b3766a2008-08-05 23:45:14 +090064 *(.text.*)
Sam Ravnborg0f5c9062007-09-15 23:35:53 +020065 *(.fixup)
66 *(.gnu.warning)
Ralf Baechle603bb992007-10-14 22:49:01 +010067 } :text = 0
Sam Ravnborg0f5c9062007-09-15 23:35:53 +020068 _etext = .; /* End of text section */
Linus Torvalds1da177e2005-04-16 15:20:36 -070069
Nelson Elhage6eb10bc2009-07-31 16:58:19 -040070 EXCEPTION_TABLE(16)
Linus Torvalds1da177e2005-04-16 15:20:36 -070071
Sam Ravnborg0f5c9062007-09-15 23:35:53 +020072 /* Exception table for data bus errors */
73 __dbe_table : {
74 __start___dbe_table = .;
Paul Burtonc0436b52018-11-21 21:56:36 +000075 KEEP(*(__dbe_table))
Sam Ravnborg0f5c9062007-09-15 23:35:53 +020076 __stop___dbe_table = .;
77 }
Ralf Baechle603bb992007-10-14 22:49:01 +010078
David Daney3bfb7222015-10-30 00:54:48 +020079#ifdef CONFIG_CAVIUM_OCTEON_SOC
80#define NOTES_HEADER
81#else /* CONFIG_CAVIUM_OCTEON_SOC */
82#define NOTES_HEADER :note
83#endif /* CONFIG_CAVIUM_OCTEON_SOC */
84 NOTES :text NOTES_HEADER
Ralf Baechle603bb992007-10-14 22:49:01 +010085 .dummy : { *(.dummy) } :text
86
Steven Rostedta2d063a2011-05-19 21:34:58 -040087 _sdata = .; /* Start of data section */
Sam Ravnborg0f5c9062007-09-15 23:35:53 +020088 RODATA
Linus Torvalds1da177e2005-04-16 15:20:36 -070089
Sam Ravnborg0f5c9062007-09-15 23:35:53 +020090 /* writeable */
91 .data : { /* Data */
Franck Bui-Huu16be2432007-10-18 23:12:32 +020092 . = . + DATAOFFSET; /* for CONFIG_MAPPED_KERNEL */
Linus Torvalds1da177e2005-04-16 15:20:36 -070093
David Daney7b1c0d22012-07-19 09:11:14 +020094 INIT_TASK_DATA(THREAD_SIZE)
Nelson Elhage6eb10bc2009-07-31 16:58:19 -040095 NOSAVE_DATA
96 CACHELINE_ALIGNED_DATA(1 << CONFIG_MIPS_L1_CACHE_SHIFT)
Catalin Marinasf8bec752011-03-29 11:40:06 +010097 READ_MOSTLY_DATA(1 << CONFIG_MIPS_L1_CACHE_SHIFT)
Franck Bui-Huu16be2432007-10-18 23:12:32 +020098 DATA_DATA
99 CONSTRUCTORS
Sam Ravnborg0f5c9062007-09-15 23:35:53 +0200100 }
Peter Zijlstrab5effd32017-03-30 17:49:27 +0200101 BUG_TABLE
Sam Ravnborg0f5c9062007-09-15 23:35:53 +0200102 _gp = . + 0x8000;
103 .lit8 : {
104 *(.lit8)
105 }
106 .lit4 : {
107 *(.lit4)
108 }
109 /* We want the small data sections together, so single-instruction offsets
110 can access them all, and initialized data all before uninitialized, so
111 we can shorten the on-disk segment size. */
112 .sdata : {
113 *(.sdata)
114 }
Sam Ravnborg0f5c9062007-09-15 23:35:53 +0200115 _edata = .; /* End of data section */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116
Sam Ravnborg0f5c9062007-09-15 23:35:53 +0200117 /* will be freed after init */
Nelson Elhagea0b54e22009-07-31 16:58:18 -0400118 . = ALIGN(PAGE_SIZE); /* Init code and data */
Sam Ravnborg0f5c9062007-09-15 23:35:53 +0200119 __init_begin = .;
Nelson Elhage6eb10bc2009-07-31 16:58:19 -0400120 INIT_TEXT_SECTION(PAGE_SIZE)
121 INIT_DATA_SECTION(16)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122
Gabor Juhos487d70d2010-11-23 16:06:25 +0100123 . = ALIGN(4);
124 .mips.machines.init : AT(ADDR(.mips.machines.init) - LOAD_OFFSET) {
125 __mips_machines_start = .;
Paul Burtonc0436b52018-11-21 21:56:36 +0000126 KEEP(*(.mips.machines.init))
Gabor Juhos487d70d2010-11-23 16:06:25 +0100127 __mips_machines_end = .;
128 }
129
Sam Ravnborg0f5c9062007-09-15 23:35:53 +0200130 /* .exit.text is discarded at runtime, not link time, to deal with
131 * references from .rodata
132 */
133 .exit.text : {
Sam Ravnborg01ba2bd2008-01-20 14:15:03 +0100134 EXIT_TEXT
Sam Ravnborg0f5c9062007-09-15 23:35:53 +0200135 }
136 .exit.data : {
Sam Ravnborg01ba2bd2008-01-20 14:15:03 +0100137 EXIT_DATA
Sam Ravnborg0f5c9062007-09-15 23:35:53 +0200138 }
Jonas Gorski1da8f172015-04-12 12:24:58 +0200139#ifdef CONFIG_SMP
Tejun Heo0415b00d12011-03-24 18:50:09 +0100140 PERCPU_SECTION(1 << CONFIG_MIPS_L1_CACHE_SHIFT)
Jonas Gorski1da8f172015-04-12 12:24:58 +0200141#endif
Matt Redfearn069fd762016-03-31 10:05:34 +0100142
Yasha Cherikovsky3f0a53b2019-03-08 14:58:51 +0200143#ifdef CONFIG_MIPS_ELF_APPENDED_DTB
144 .appended_dtb : AT(ADDR(.appended_dtb) - LOAD_OFFSET) {
145 *(.appended_dtb)
146 KEEP(*(.appended_dtb))
147 }
148#endif
149
Matt Redfearn069fd762016-03-31 10:05:34 +0100150#ifdef CONFIG_RELOCATABLE
151 . = ALIGN(4);
152
153 .data.reloc : {
154 _relocation_start = .;
155 /*
156 * Space for relocation table
157 * This needs to be filled so that the
158 * relocs tool can overwrite the content.
159 * An invalid value is left at the start of the
160 * section to abort relocation if the table
161 * has not been filled in.
162 */
163 LONG(0xFFFFFFFF);
164 FILL(0);
165 . += CONFIG_RELOCATION_TABLE_SIZE - 4;
166 _relocation_end = .;
167 }
168#endif
169
Jonas Gorski1da8f172015-04-12 12:24:58 +0200170#ifdef CONFIG_MIPS_RAW_APPENDED_DTB
171 __appended_dtb = .;
172 /* leave space for appended DTB */
173 . += 0x100000;
174#endif
David Daney485172b2012-08-14 11:08:01 -0700175 /*
176 * Align to 64K in attempt to eliminate holes before the
177 * .bss..swapper_pg_dir section at the start of .bss. This
178 * also satisfies PAGE_SIZE alignment as the largest page size
179 * allowed is 64K.
180 */
181 . = ALIGN(0x10000);
Sam Ravnborg0f5c9062007-09-15 23:35:53 +0200182 __init_end = .;
183 /* freed after init ends here */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184
David Daney485172b2012-08-14 11:08:01 -0700185 /*
186 * Force .bss to 64K alignment so that .bss..swapper_pg_dir
Ralf Baechle70342282013-01-22 12:59:30 +0100187 * gets that alignment. .sbss should be empty, so there will be
David Daney485172b2012-08-14 11:08:01 -0700188 * no holes after __init_end. */
Paul Burton3f00f4d2016-11-07 11:52:19 +0000189 BSS_SECTION(0, 0x10000, 8)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190
Sam Ravnborg0f5c9062007-09-15 23:35:53 +0200191 _end = . ;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192
Sam Ravnborg0f5c9062007-09-15 23:35:53 +0200193 /* These mark the ABI of the kernel for debuggers. */
194 .mdebug.abi32 : {
195 KEEP(*(.mdebug.abi32))
196 }
197 .mdebug.abi64 : {
198 KEEP(*(.mdebug.abi64))
199 }
Daniel Jacobowitz6c769882007-08-03 11:43:01 -0400200
Sam Ravnborg0f5c9062007-09-15 23:35:53 +0200201 /* This is the MIPS specific mdebug section. */
202 .mdebug : {
203 *(.mdebug)
204 }
Atsushi Nemoto78665aa2006-05-11 00:41:26 +0900205
Sam Ravnborg0f5c9062007-09-15 23:35:53 +0200206 STABS_DEBUG
207 DWARF_DEBUG
Atsushi Nemoto04b6b3b2006-05-10 15:36:04 +0900208
Sam Ravnborg0f5c9062007-09-15 23:35:53 +0200209 /* These must appear regardless of . */
210 .gptab.sdata : {
211 *(.gptab.data)
212 *(.gptab.sdata)
213 }
214 .gptab.sbss : {
215 *(.gptab.bss)
216 *(.gptab.sbss)
217 }
Tejun Heo023bf6f2009-07-09 11:27:40 +0900218
219 /* Sections to be discarded */
220 DISCARDS
221 /DISCARD/ : {
222 /* ABI crap starts here */
Aaro Koskinen61379872015-10-30 00:54:47 +0200223 *(.MIPS.abiflags)
Tejun Heo023bf6f2009-07-09 11:27:40 +0900224 *(.MIPS.options)
225 *(.options)
226 *(.pdr)
227 *(.reginfo)
David Daneyb8199542013-08-08 11:40:49 -0700228 *(.eh_frame)
Tejun Heo023bf6f2009-07-09 11:27:40 +0900229 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700230}