Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Ralf Baechle | dbee90b | 2006-02-02 14:31:16 +0000 | [diff] [blame] | 2 | #include <asm/asm-offsets.h> |
David Daney | 7b1c0d2 | 2012-07-19 09:11:14 +0200 | [diff] [blame] | 3 | #include <asm/thread_info.h> |
David Daney | 485172b | 2012-08-14 11:08:01 -0700 | [diff] [blame] | 4 | |
Ralf Baechle | bef9ae3 | 2012-12-28 15:15:25 +0100 | [diff] [blame] | 5 | #define PAGE_SIZE _PAGE_SIZE |
| 6 | |
David Daney | 485172b | 2012-08-14 11:08:01 -0700 | [diff] [blame] | 7 | /* |
| 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 Cook | 441110a | 2019-10-29 14:13:30 -0700 | [diff] [blame] | 13 | /* 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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | #include <asm-generic/vmlinux.lds.h> |
| 19 | |
Ralf Baechle | 41c594a | 2006-04-05 09:45:45 +0100 | [diff] [blame] | 20 | #undef mips |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | #define mips mips |
| 22 | OUTPUT_ARCH(mips) |
| 23 | ENTRY(kernel_entry) |
Ralf Baechle | 603bb99 | 2007-10-14 22:49:01 +0100 | [diff] [blame] | 24 | PHDRS { |
| 25 | text PT_LOAD FLAGS(7); /* RWX */ |
David Daney | 3bfb722 | 2015-10-30 00:54:48 +0200 | [diff] [blame] | 26 | #ifndef CONFIG_CAVIUM_OCTEON_SOC |
Ralf Baechle | 603bb99 | 2007-10-14 22:49:01 +0100 | [diff] [blame] | 27 | note PT_NOTE FLAGS(4); /* R__ */ |
David Daney | 3bfb722 | 2015-10-30 00:54:48 +0200 | [diff] [blame] | 28 | #endif /* CAVIUM_OCTEON_SOC */ |
Ralf Baechle | 603bb99 | 2007-10-14 22:49:01 +0100 | [diff] [blame] | 29 | } |
Sam Ravnborg | 51b563f | 2009-09-20 12:28:22 +0200 | [diff] [blame] | 30 | |
Manuel Lauss | d71789b | 2009-09-24 21:44:24 +0200 | [diff] [blame] | 31 | #ifdef CONFIG_32BIT |
| 32 | #ifdef CONFIG_CPU_LITTLE_ENDIAN |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 33 | jiffies = jiffies_64; |
Manuel Lauss | d71789b | 2009-09-24 21:44:24 +0200 | [diff] [blame] | 34 | #else |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 35 | jiffies = jiffies_64 + 4; |
Manuel Lauss | d71789b | 2009-09-24 21:44:24 +0200 | [diff] [blame] | 36 | #endif |
| 37 | #else |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 38 | jiffies = jiffies_64; |
Manuel Lauss | d71789b | 2009-09-24 21:44:24 +0200 | [diff] [blame] | 39 | #endif |
Sam Ravnborg | 0f5c906 | 2007-09-15 23:35:53 +0200 | [diff] [blame] | 40 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | SECTIONS |
| 42 | { |
| 43 | #ifdef CONFIG_BOOT_ELF64 |
Sam Ravnborg | 0f5c906 | 2007-09-15 23:35:53 +0200 | [diff] [blame] | 44 | /* Read-only sections, merged into text segment: */ |
| 45 | /* . = 0xc000000000000000; */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | |
Sam Ravnborg | 0f5c906 | 2007-09-15 23:35:53 +0200 | [diff] [blame] | 47 | /* This is the value for an Origin kernel, taken from an IRIX kernel. */ |
| 48 | /* . = 0xc00000000001c000; */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | |
Sam Ravnborg | 0f5c906 | 2007-09-15 23:35:53 +0200 | [diff] [blame] | 50 | /* 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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | |
Sam Ravnborg | 0f5c906 | 2007-09-15 23:35:53 +0200 | [diff] [blame] | 55 | /* . = 0xa800000000300000; */ |
Sam Ravnborg | 0f5c906 | 2007-09-15 23:35:53 +0200 | [diff] [blame] | 56 | . = 0xffffffff80300000; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | #endif |
Jiaxun Yang | ff487d4 | 2020-05-06 13:52:45 +0800 | [diff] [blame] | 58 | . = LINKER_LOAD_ADDRESS; |
Sam Ravnborg | 0f5c906 | 2007-09-15 23:35:53 +0200 | [diff] [blame] | 59 | /* read-only */ |
| 60 | _text = .; /* Text and read-only data */ |
| 61 | .text : { |
| 62 | TEXT_TEXT |
| 63 | SCHED_TEXT |
Chris Metcalf | 6727ad9 | 2016-10-07 17:02:55 -0700 | [diff] [blame] | 64 | CPUIDLE_TEXT |
Sam Ravnborg | 0f5c906 | 2007-09-15 23:35:53 +0200 | [diff] [blame] | 65 | LOCK_TEXT |
Ralf Baechle | f70fd1b | 2007-10-14 22:50:05 +0100 | [diff] [blame] | 66 | KPROBES_TEXT |
Wu Zhangjin | 8f99a16 | 2009-11-20 20:34:33 +0800 | [diff] [blame] | 67 | IRQENTRY_TEXT |
Alexander Potapenko | be7635e | 2016-03-25 14:22:05 -0700 | [diff] [blame] | 68 | SOFTIRQENTRY_TEXT |
Sam Ravnborg | 0f5c906 | 2007-09-15 23:35:53 +0200 | [diff] [blame] | 69 | *(.fixup) |
| 70 | *(.gnu.warning) |
Alexander Lobakin | 795b3a3 | 2021-01-10 11:56:41 +0000 | [diff] [blame] | 71 | . = ALIGN(16); |
| 72 | *(.got) /* Global offset table */ |
Ralf Baechle | 603bb99 | 2007-10-14 22:49:01 +0100 | [diff] [blame] | 73 | } :text = 0 |
Sam Ravnborg | 0f5c906 | 2007-09-15 23:35:53 +0200 | [diff] [blame] | 74 | _etext = .; /* End of text section */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | |
Nelson Elhage | 6eb10bc | 2009-07-31 16:58:19 -0400 | [diff] [blame] | 76 | EXCEPTION_TABLE(16) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | |
Sam Ravnborg | 0f5c906 | 2007-09-15 23:35:53 +0200 | [diff] [blame] | 78 | /* Exception table for data bus errors */ |
| 79 | __dbe_table : { |
| 80 | __start___dbe_table = .; |
Paul Burton | c0436b5 | 2018-11-21 21:56:36 +0000 | [diff] [blame] | 81 | KEEP(*(__dbe_table)) |
Sam Ravnborg | 0f5c906 | 2007-09-15 23:35:53 +0200 | [diff] [blame] | 82 | __stop___dbe_table = .; |
| 83 | } |
Ralf Baechle | 603bb99 | 2007-10-14 22:49:01 +0100 | [diff] [blame] | 84 | |
Steven Rostedt | a2d063a | 2011-05-19 21:34:58 -0400 | [diff] [blame] | 85 | _sdata = .; /* Start of data section */ |
Kees Cook | c823182 | 2019-10-29 14:13:33 -0700 | [diff] [blame] | 86 | RO_DATA(4096) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | |
Sam Ravnborg | 0f5c906 | 2007-09-15 23:35:53 +0200 | [diff] [blame] | 88 | /* writeable */ |
| 89 | .data : { /* Data */ |
Franck Bui-Huu | 16be243 | 2007-10-18 23:12:32 +0200 | [diff] [blame] | 90 | . = . + DATAOFFSET; /* for CONFIG_MAPPED_KERNEL */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | |
David Daney | 7b1c0d2 | 2012-07-19 09:11:14 +0200 | [diff] [blame] | 92 | INIT_TASK_DATA(THREAD_SIZE) |
Nelson Elhage | 6eb10bc | 2009-07-31 16:58:19 -0400 | [diff] [blame] | 93 | NOSAVE_DATA |
Alexander Lobakin | 8ac7c87 | 2021-01-10 11:56:08 +0000 | [diff] [blame] | 94 | PAGE_ALIGNED_DATA(PAGE_SIZE) |
Nelson Elhage | 6eb10bc | 2009-07-31 16:58:19 -0400 | [diff] [blame] | 95 | CACHELINE_ALIGNED_DATA(1 << CONFIG_MIPS_L1_CACHE_SHIFT) |
Catalin Marinas | f8bec75 | 2011-03-29 11:40:06 +0100 | [diff] [blame] | 96 | READ_MOSTLY_DATA(1 << CONFIG_MIPS_L1_CACHE_SHIFT) |
Franck Bui-Huu | 16be243 | 2007-10-18 23:12:32 +0200 | [diff] [blame] | 97 | DATA_DATA |
| 98 | CONSTRUCTORS |
Sam Ravnborg | 0f5c906 | 2007-09-15 23:35:53 +0200 | [diff] [blame] | 99 | } |
Peter Zijlstra | b5effd3 | 2017-03-30 17:49:27 +0200 | [diff] [blame] | 100 | BUG_TABLE |
Sam Ravnborg | 0f5c906 | 2007-09-15 23:35:53 +0200 | [diff] [blame] | 101 | _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 Ravnborg | 0f5c906 | 2007-09-15 23:35:53 +0200 | [diff] [blame] | 114 | _edata = .; /* End of data section */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | |
Sam Ravnborg | 0f5c906 | 2007-09-15 23:35:53 +0200 | [diff] [blame] | 116 | /* will be freed after init */ |
Nelson Elhage | a0b54e2 | 2009-07-31 16:58:18 -0400 | [diff] [blame] | 117 | . = ALIGN(PAGE_SIZE); /* Init code and data */ |
Sam Ravnborg | 0f5c906 | 2007-09-15 23:35:53 +0200 | [diff] [blame] | 118 | __init_begin = .; |
Nelson Elhage | 6eb10bc | 2009-07-31 16:58:19 -0400 | [diff] [blame] | 119 | INIT_TEXT_SECTION(PAGE_SIZE) |
| 120 | INIT_DATA_SECTION(16) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 121 | |
Gabor Juhos | 487d70d | 2010-11-23 16:06:25 +0100 | [diff] [blame] | 122 | . = ALIGN(4); |
| 123 | .mips.machines.init : AT(ADDR(.mips.machines.init) - LOAD_OFFSET) { |
| 124 | __mips_machines_start = .; |
Paul Burton | c0436b5 | 2018-11-21 21:56:36 +0000 | [diff] [blame] | 125 | KEEP(*(.mips.machines.init)) |
Gabor Juhos | 487d70d | 2010-11-23 16:06:25 +0100 | [diff] [blame] | 126 | __mips_machines_end = .; |
| 127 | } |
| 128 | |
Sam Ravnborg | 0f5c906 | 2007-09-15 23:35:53 +0200 | [diff] [blame] | 129 | /* .exit.text is discarded at runtime, not link time, to deal with |
| 130 | * references from .rodata |
| 131 | */ |
| 132 | .exit.text : { |
Sam Ravnborg | 01ba2bd | 2008-01-20 14:15:03 +0100 | [diff] [blame] | 133 | EXIT_TEXT |
Sam Ravnborg | 0f5c906 | 2007-09-15 23:35:53 +0200 | [diff] [blame] | 134 | } |
| 135 | .exit.data : { |
Sam Ravnborg | 01ba2bd | 2008-01-20 14:15:03 +0100 | [diff] [blame] | 136 | EXIT_DATA |
Sam Ravnborg | 0f5c906 | 2007-09-15 23:35:53 +0200 | [diff] [blame] | 137 | } |
Jonas Gorski | 1da8f17 | 2015-04-12 12:24:58 +0200 | [diff] [blame] | 138 | #ifdef CONFIG_SMP |
Tejun Heo | 0415b00d1 | 2011-03-24 18:50:09 +0100 | [diff] [blame] | 139 | PERCPU_SECTION(1 << CONFIG_MIPS_L1_CACHE_SHIFT) |
Jonas Gorski | 1da8f17 | 2015-04-12 12:24:58 +0200 | [diff] [blame] | 140 | #endif |
Matt Redfearn | 069fd76 | 2016-03-31 10:05:34 +0100 | [diff] [blame] | 141 | |
Alexander Lobakin | 008c3cb | 2021-01-10 11:56:34 +0000 | [diff] [blame] | 142 | .rel.dyn : ALIGN(8) { |
| 143 | *(.rel) |
| 144 | *(.rel*) |
| 145 | } |
| 146 | |
Yasha Cherikovsky | 3f0a53b | 2019-03-08 14:58:51 +0200 | [diff] [blame] | 147 | #ifdef CONFIG_MIPS_ELF_APPENDED_DTB |
Paul Cercueil | 7a05293 | 2021-03-03 19:33:05 +0000 | [diff] [blame] | 148 | STRUCT_ALIGN(); |
Yasha Cherikovsky | 3f0a53b | 2019-03-08 14:58:51 +0200 | [diff] [blame] | 149 | .appended_dtb : AT(ADDR(.appended_dtb) - LOAD_OFFSET) { |
| 150 | *(.appended_dtb) |
| 151 | KEEP(*(.appended_dtb)) |
| 152 | } |
| 153 | #endif |
| 154 | |
Matt Redfearn | 069fd76 | 2016-03-31 10:05:34 +0100 | [diff] [blame] | 155 | #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 Gorski | 1da8f17 | 2015-04-12 12:24:58 +0200 | [diff] [blame] | 175 | #ifdef CONFIG_MIPS_RAW_APPENDED_DTB |
Bjørn Mork | 6654111 | 2021-03-07 19:23:01 +0100 | [diff] [blame] | 176 | .fill : { |
| 177 | FILL(0); |
| 178 | BYTE(0); |
Paul Cercueil | 3f6c515 | 2021-03-16 15:45:15 +0000 | [diff] [blame] | 179 | STRUCT_ALIGN(); |
Bjørn Mork | 6654111 | 2021-03-07 19:23:01 +0100 | [diff] [blame] | 180 | } |
Jonas Gorski | 1da8f17 | 2015-04-12 12:24:58 +0200 | [diff] [blame] | 181 | __appended_dtb = .; |
| 182 | /* leave space for appended DTB */ |
| 183 | . += 0x100000; |
| 184 | #endif |
David Daney | 485172b | 2012-08-14 11:08:01 -0700 | [diff] [blame] | 185 | /* |
| 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 Ravnborg | 0f5c906 | 2007-09-15 23:35:53 +0200 | [diff] [blame] | 192 | __init_end = .; |
| 193 | /* freed after init ends here */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 194 | |
David Daney | 485172b | 2012-08-14 11:08:01 -0700 | [diff] [blame] | 195 | /* |
| 196 | * Force .bss to 64K alignment so that .bss..swapper_pg_dir |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 197 | * gets that alignment. .sbss should be empty, so there will be |
David Daney | 485172b | 2012-08-14 11:08:01 -0700 | [diff] [blame] | 198 | * no holes after __init_end. */ |
Paul Burton | 3f00f4d | 2016-11-07 11:52:19 +0000 | [diff] [blame] | 199 | BSS_SECTION(0, 0x10000, 8) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 200 | |
Sam Ravnborg | 0f5c906 | 2007-09-15 23:35:53 +0200 | [diff] [blame] | 201 | _end = . ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 202 | |
Sam Ravnborg | 0f5c906 | 2007-09-15 23:35:53 +0200 | [diff] [blame] | 203 | /* 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 Jacobowitz | 6c76988b | 2007-08-03 11:43:01 -0400 | [diff] [blame] | 210 | |
Sam Ravnborg | 0f5c906 | 2007-09-15 23:35:53 +0200 | [diff] [blame] | 211 | /* This is the MIPS specific mdebug section. */ |
| 212 | .mdebug : { |
| 213 | *(.mdebug) |
| 214 | } |
Atsushi Nemoto | 78665aa | 2006-05-11 00:41:26 +0900 | [diff] [blame] | 215 | |
Sam Ravnborg | 0f5c906 | 2007-09-15 23:35:53 +0200 | [diff] [blame] | 216 | STABS_DEBUG |
| 217 | DWARF_DEBUG |
Kees Cook | c604abc | 2020-08-21 12:42:45 -0700 | [diff] [blame] | 218 | ELF_DETAILS |
Atsushi Nemoto | 04b6b3b | 2006-05-10 15:36:04 +0900 | [diff] [blame] | 219 | |
Sam Ravnborg | 0f5c906 | 2007-09-15 23:35:53 +0200 | [diff] [blame] | 220 | /* 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 Heo | 023bf6f | 2009-07-09 11:27:40 +0900 | [diff] [blame] | 229 | |
| 230 | /* Sections to be discarded */ |
| 231 | DISCARDS |
| 232 | /DISCARD/ : { |
| 233 | /* ABI crap starts here */ |
Aaro Koskinen | 6137987 | 2015-10-30 00:54:47 +0200 | [diff] [blame] | 234 | *(.MIPS.abiflags) |
Tejun Heo | 023bf6f | 2009-07-09 11:27:40 +0900 | [diff] [blame] | 235 | *(.MIPS.options) |
Alexander Lobakin | 5629d418 | 2021-01-10 11:56:22 +0000 | [diff] [blame] | 236 | *(.gnu.attributes) |
Tejun Heo | 023bf6f | 2009-07-09 11:27:40 +0900 | [diff] [blame] | 237 | *(.options) |
| 238 | *(.pdr) |
| 239 | *(.reginfo) |
| 240 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 241 | } |