blob: 1f98947fe715daca0f6a68b11e1ecd1a3d7647a8 [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
Kees Cook441110a2019-10-29 14:13:30 -070013/* Cavium Octeon should not have a separate PT_NOTE Program Header. */
14#ifndef CONFIG_CAVIUM_OCTEON_SOC
15#define EMITS_PT_NOTE
16#endif
17
Linus Torvalds1da177e2005-04-16 15:20:36 -070018#include <asm-generic/vmlinux.lds.h>
19
Ralf Baechle41c594a2006-04-05 09:45:45 +010020#undef mips
Linus Torvalds1da177e2005-04-16 15:20:36 -070021#define mips mips
22OUTPUT_ARCH(mips)
23ENTRY(kernel_entry)
Ralf Baechle603bb992007-10-14 22:49:01 +010024PHDRS {
25 text PT_LOAD FLAGS(7); /* RWX */
David Daney3bfb7222015-10-30 00:54:48 +020026#ifndef CONFIG_CAVIUM_OCTEON_SOC
Ralf Baechle603bb992007-10-14 22:49:01 +010027 note PT_NOTE FLAGS(4); /* R__ */
David Daney3bfb7222015-10-30 00:54:48 +020028#endif /* CAVIUM_OCTEON_SOC */
Ralf Baechle603bb992007-10-14 22:49:01 +010029}
Sam Ravnborg51b563f2009-09-20 12:28:22 +020030
Manuel Laussd71789b2009-09-24 21:44:24 +020031#ifdef CONFIG_32BIT
32 #ifdef CONFIG_CPU_LITTLE_ENDIAN
Ralf Baechle70342282013-01-22 12:59:30 +010033 jiffies = jiffies_64;
Manuel Laussd71789b2009-09-24 21:44:24 +020034 #else
Ralf Baechle70342282013-01-22 12:59:30 +010035 jiffies = jiffies_64 + 4;
Manuel Laussd71789b2009-09-24 21:44:24 +020036 #endif
37#else
Ralf Baechle70342282013-01-22 12:59:30 +010038 jiffies = jiffies_64;
Manuel Laussd71789b2009-09-24 21:44:24 +020039#endif
Sam Ravnborg0f5c9062007-09-15 23:35:53 +020040
Linus Torvalds1da177e2005-04-16 15:20:36 -070041SECTIONS
42{
43#ifdef CONFIG_BOOT_ELF64
Sam Ravnborg0f5c9062007-09-15 23:35:53 +020044 /* Read-only sections, merged into text segment: */
45 /* . = 0xc000000000000000; */
Linus Torvalds1da177e2005-04-16 15:20:36 -070046
Sam Ravnborg0f5c9062007-09-15 23:35:53 +020047 /* This is the value for an Origin kernel, taken from an IRIX kernel. */
48 /* . = 0xc00000000001c000; */
Linus Torvalds1da177e2005-04-16 15:20:36 -070049
Sam Ravnborg0f5c9062007-09-15 23:35:53 +020050 /* Set the vaddr for the text segment to a value
51 * >= 0xa800 0000 0001 9000 if no symmon is going to configured
52 * >= 0xa800 0000 0030 0000 otherwise
53 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070054
Sam Ravnborg0f5c9062007-09-15 23:35:53 +020055 /* . = 0xa800000000300000; */
Sam Ravnborg0f5c9062007-09-15 23:35:53 +020056 . = 0xffffffff80300000;
Linus Torvalds1da177e2005-04-16 15:20:36 -070057#endif
Jiaxun Yangff487d42020-05-06 13:52:45 +080058 . = LINKER_LOAD_ADDRESS;
Sam Ravnborg0f5c9062007-09-15 23:35:53 +020059 /* read-only */
60 _text = .; /* Text and read-only data */
61 .text : {
62 TEXT_TEXT
63 SCHED_TEXT
Chris Metcalf6727ad92016-10-07 17:02:55 -070064 CPUIDLE_TEXT
Sam Ravnborg0f5c9062007-09-15 23:35:53 +020065 LOCK_TEXT
Ralf Baechlef70fd1b2007-10-14 22:50:05 +010066 KPROBES_TEXT
Wu Zhangjin8f99a162009-11-20 20:34:33 +080067 IRQENTRY_TEXT
Alexander Potapenkobe7635e2016-03-25 14:22:05 -070068 SOFTIRQENTRY_TEXT
Sam Ravnborg0f5c9062007-09-15 23:35:53 +020069 *(.fixup)
70 *(.gnu.warning)
Alexander Lobakin795b3a32021-01-10 11:56:41 +000071 . = ALIGN(16);
72 *(.got) /* Global offset table */
Ralf Baechle603bb992007-10-14 22:49:01 +010073 } :text = 0
Sam Ravnborg0f5c9062007-09-15 23:35:53 +020074 _etext = .; /* End of text section */
Linus Torvalds1da177e2005-04-16 15:20:36 -070075
Nelson Elhage6eb10bc2009-07-31 16:58:19 -040076 EXCEPTION_TABLE(16)
Linus Torvalds1da177e2005-04-16 15:20:36 -070077
Sam Ravnborg0f5c9062007-09-15 23:35:53 +020078 /* Exception table for data bus errors */
79 __dbe_table : {
80 __start___dbe_table = .;
Paul Burtonc0436b52018-11-21 21:56:36 +000081 KEEP(*(__dbe_table))
Sam Ravnborg0f5c9062007-09-15 23:35:53 +020082 __stop___dbe_table = .;
83 }
Ralf Baechle603bb992007-10-14 22:49:01 +010084
Steven Rostedta2d063a2011-05-19 21:34:58 -040085 _sdata = .; /* Start of data section */
Kees Cookc8231822019-10-29 14:13:33 -070086 RO_DATA(4096)
Linus Torvalds1da177e2005-04-16 15:20:36 -070087
Sam Ravnborg0f5c9062007-09-15 23:35:53 +020088 /* writeable */
89 .data : { /* Data */
Franck Bui-Huu16be2432007-10-18 23:12:32 +020090 . = . + DATAOFFSET; /* for CONFIG_MAPPED_KERNEL */
Linus Torvalds1da177e2005-04-16 15:20:36 -070091
David Daney7b1c0d22012-07-19 09:11:14 +020092 INIT_TASK_DATA(THREAD_SIZE)
Nelson Elhage6eb10bc2009-07-31 16:58:19 -040093 NOSAVE_DATA
Alexander Lobakin8ac7c872021-01-10 11:56:08 +000094 PAGE_ALIGNED_DATA(PAGE_SIZE)
Nelson Elhage6eb10bc2009-07-31 16:58:19 -040095 CACHELINE_ALIGNED_DATA(1 << CONFIG_MIPS_L1_CACHE_SHIFT)
Catalin Marinasf8bec752011-03-29 11:40:06 +010096 READ_MOSTLY_DATA(1 << CONFIG_MIPS_L1_CACHE_SHIFT)
Franck Bui-Huu16be2432007-10-18 23:12:32 +020097 DATA_DATA
98 CONSTRUCTORS
Sam Ravnborg0f5c9062007-09-15 23:35:53 +020099 }
Peter Zijlstrab5effd32017-03-30 17:49:27 +0200100 BUG_TABLE
Sam Ravnborg0f5c9062007-09-15 23:35:53 +0200101 _gp = . + 0x8000;
102 .lit8 : {
103 *(.lit8)
104 }
105 .lit4 : {
106 *(.lit4)
107 }
108 /* We want the small data sections together, so single-instruction offsets
109 can access them all, and initialized data all before uninitialized, so
110 we can shorten the on-disk segment size. */
111 .sdata : {
112 *(.sdata)
113 }
Sam Ravnborg0f5c9062007-09-15 23:35:53 +0200114 _edata = .; /* End of data section */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115
Sam Ravnborg0f5c9062007-09-15 23:35:53 +0200116 /* will be freed after init */
Nelson Elhagea0b54e22009-07-31 16:58:18 -0400117 . = ALIGN(PAGE_SIZE); /* Init code and data */
Sam Ravnborg0f5c9062007-09-15 23:35:53 +0200118 __init_begin = .;
Nelson Elhage6eb10bc2009-07-31 16:58:19 -0400119 INIT_TEXT_SECTION(PAGE_SIZE)
120 INIT_DATA_SECTION(16)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121
Gabor Juhos487d70d2010-11-23 16:06:25 +0100122 . = ALIGN(4);
123 .mips.machines.init : AT(ADDR(.mips.machines.init) - LOAD_OFFSET) {
124 __mips_machines_start = .;
Paul Burtonc0436b52018-11-21 21:56:36 +0000125 KEEP(*(.mips.machines.init))
Gabor Juhos487d70d2010-11-23 16:06:25 +0100126 __mips_machines_end = .;
127 }
128
Sam Ravnborg0f5c9062007-09-15 23:35:53 +0200129 /* .exit.text is discarded at runtime, not link time, to deal with
130 * references from .rodata
131 */
132 .exit.text : {
Sam Ravnborg01ba2bd2008-01-20 14:15:03 +0100133 EXIT_TEXT
Sam Ravnborg0f5c9062007-09-15 23:35:53 +0200134 }
135 .exit.data : {
Sam Ravnborg01ba2bd2008-01-20 14:15:03 +0100136 EXIT_DATA
Sam Ravnborg0f5c9062007-09-15 23:35:53 +0200137 }
Jonas Gorski1da8f172015-04-12 12:24:58 +0200138#ifdef CONFIG_SMP
Tejun Heo0415b00d12011-03-24 18:50:09 +0100139 PERCPU_SECTION(1 << CONFIG_MIPS_L1_CACHE_SHIFT)
Jonas Gorski1da8f172015-04-12 12:24:58 +0200140#endif
Matt Redfearn069fd762016-03-31 10:05:34 +0100141
Alexander Lobakin008c3cb2021-01-10 11:56:34 +0000142 .rel.dyn : ALIGN(8) {
143 *(.rel)
144 *(.rel*)
145 }
146
Yasha Cherikovsky3f0a53b2019-03-08 14:58:51 +0200147#ifdef CONFIG_MIPS_ELF_APPENDED_DTB
Paul Cercueil7a052932021-03-03 19:33:05 +0000148 STRUCT_ALIGN();
Yasha Cherikovsky3f0a53b2019-03-08 14:58:51 +0200149 .appended_dtb : AT(ADDR(.appended_dtb) - LOAD_OFFSET) {
150 *(.appended_dtb)
151 KEEP(*(.appended_dtb))
152 }
153#endif
154
Matt Redfearn069fd762016-03-31 10:05:34 +0100155#ifdef CONFIG_RELOCATABLE
156 . = ALIGN(4);
157
158 .data.reloc : {
159 _relocation_start = .;
160 /*
161 * Space for relocation table
162 * This needs to be filled so that the
163 * relocs tool can overwrite the content.
164 * An invalid value is left at the start of the
165 * section to abort relocation if the table
166 * has not been filled in.
167 */
168 LONG(0xFFFFFFFF);
169 FILL(0);
170 . += CONFIG_RELOCATION_TABLE_SIZE - 4;
171 _relocation_end = .;
172 }
173#endif
174
Jonas Gorski1da8f172015-04-12 12:24:58 +0200175#ifdef CONFIG_MIPS_RAW_APPENDED_DTB
Bjørn Mork66541112021-03-07 19:23:01 +0100176 .fill : {
177 FILL(0);
178 BYTE(0);
Paul Cercueil3f6c5152021-03-16 15:45:15 +0000179 STRUCT_ALIGN();
Bjørn Mork66541112021-03-07 19:23:01 +0100180 }
Jonas Gorski1da8f172015-04-12 12:24:58 +0200181 __appended_dtb = .;
182 /* leave space for appended DTB */
183 . += 0x100000;
184#endif
David Daney485172b2012-08-14 11:08:01 -0700185 /*
186 * Align to 64K in attempt to eliminate holes before the
187 * .bss..swapper_pg_dir section at the start of .bss. This
188 * also satisfies PAGE_SIZE alignment as the largest page size
189 * allowed is 64K.
190 */
191 . = ALIGN(0x10000);
Sam Ravnborg0f5c9062007-09-15 23:35:53 +0200192 __init_end = .;
193 /* freed after init ends here */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194
David Daney485172b2012-08-14 11:08:01 -0700195 /*
196 * Force .bss to 64K alignment so that .bss..swapper_pg_dir
Ralf Baechle70342282013-01-22 12:59:30 +0100197 * gets that alignment. .sbss should be empty, so there will be
David Daney485172b2012-08-14 11:08:01 -0700198 * no holes after __init_end. */
Paul Burton3f00f4d2016-11-07 11:52:19 +0000199 BSS_SECTION(0, 0x10000, 8)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700200
Sam Ravnborg0f5c9062007-09-15 23:35:53 +0200201 _end = . ;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700202
Sam Ravnborg0f5c9062007-09-15 23:35:53 +0200203 /* These mark the ABI of the kernel for debuggers. */
204 .mdebug.abi32 : {
205 KEEP(*(.mdebug.abi32))
206 }
207 .mdebug.abi64 : {
208 KEEP(*(.mdebug.abi64))
209 }
Daniel Jacobowitz6c76988b2007-08-03 11:43:01 -0400210
Sam Ravnborg0f5c9062007-09-15 23:35:53 +0200211 /* This is the MIPS specific mdebug section. */
212 .mdebug : {
213 *(.mdebug)
214 }
Atsushi Nemoto78665aa2006-05-11 00:41:26 +0900215
Sam Ravnborg0f5c9062007-09-15 23:35:53 +0200216 STABS_DEBUG
217 DWARF_DEBUG
Kees Cookc604abc2020-08-21 12:42:45 -0700218 ELF_DETAILS
Atsushi Nemoto04b6b3b2006-05-10 15:36:04 +0900219
Sam Ravnborg0f5c9062007-09-15 23:35:53 +0200220 /* These must appear regardless of . */
221 .gptab.sdata : {
222 *(.gptab.data)
223 *(.gptab.sdata)
224 }
225 .gptab.sbss : {
226 *(.gptab.bss)
227 *(.gptab.sbss)
228 }
Tejun Heo023bf6f2009-07-09 11:27:40 +0900229
230 /* Sections to be discarded */
231 DISCARDS
232 /DISCARD/ : {
233 /* ABI crap starts here */
Aaro Koskinen61379872015-10-30 00:54:47 +0200234 *(.MIPS.abiflags)
Tejun Heo023bf6f2009-07-09 11:27:40 +0900235 *(.MIPS.options)
Alexander Lobakin5629d4182021-01-10 11:56:22 +0000236 *(.gnu.attributes)
Tejun Heo023bf6f2009-07-09 11:27:40 +0900237 *(.options)
238 *(.pdr)
239 *(.reginfo)
240 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241}