blob: 9b265783be6a193d6a341e3a60308d16ce1cb5fe [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002
Mike Rapoport65fddcf2020-06-08 21:32:42 -07003#include <linux/pgtable.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07004#include <asm/cache.h>
5#include <asm/ptrace.h>
David Howells05008712018-01-02 15:12:01 +00006#include <asm/thread_info.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07007
Kees Cook441110a2019-10-29 14:13:30 -07008#define EMITS_PT_NOTE
Kees Cook9b30e702019-10-29 14:13:43 -07009#define RO_EXCEPTION_TABLE_ALIGN 16
Kees Cook441110a2019-10-29 14:13:30 -070010
Linus Torvalds1da177e2005-04-16 15:20:36 -070011#include <asm-generic/vmlinux.lds.h>
12
13OUTPUT_FORMAT("elf64-ia64-little")
14OUTPUT_ARCH(ia64)
15ENTRY(phys_start)
16jiffies = jiffies_64;
Sam Ravnborg7b313fd2010-06-19 17:19:25 +020017
Linus Torvalds1da177e2005-04-16 15:20:36 -070018PHDRS {
Kees Cook430c6b22019-10-29 14:13:27 -070019 text PT_LOAD;
Sam Ravnborg7b313fd2010-06-19 17:19:25 +020020 percpu PT_LOAD;
21 data PT_LOAD;
22 note PT_NOTE;
23 unwind 0x70000001; /* PT_IA_64_UNWIND, but ld doesn't match the name */
Linus Torvalds1da177e2005-04-16 15:20:36 -070024}
Linus Torvalds1da177e2005-04-16 15:20:36 -070025
Sam Ravnborg7b313fd2010-06-19 17:19:25 +020026SECTIONS {
27 /*
28 * unwind exit sections must be discarded before
29 * the rest of the sections get included.
30 */
31 /DISCARD/ : {
32 *(.IA_64.unwind.exit.text)
33 *(.IA_64.unwind_info.exit.text)
34 *(.comment)
35 *(.note)
36 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070037
Sam Ravnborg7b313fd2010-06-19 17:19:25 +020038 v = PAGE_OFFSET; /* this symbol is here to make debugging easier... */
39 phys_start = _start - LOAD_OFFSET;
Linus Torvalds1da177e2005-04-16 15:20:36 -070040
Sam Ravnborg7b313fd2010-06-19 17:19:25 +020041 code : {
Kees Cook430c6b22019-10-29 14:13:27 -070042 } :text
Sam Ravnborg7b313fd2010-06-19 17:19:25 +020043 . = KERNEL_START;
Linus Torvalds1da177e2005-04-16 15:20:36 -070044
Sam Ravnborg7b313fd2010-06-19 17:19:25 +020045 _text = .;
46 _stext = .;
47
48 .text : AT(ADDR(.text) - LOAD_OFFSET) {
49 __start_ivt_text = .;
50 *(.text..ivt)
51 __end_ivt_text = .;
52 TEXT_TEXT
53 SCHED_TEXT
Chris Metcalf6727ad92016-10-07 17:02:55 -070054 CPUIDLE_TEXT
Sam Ravnborg7b313fd2010-06-19 17:19:25 +020055 LOCK_TEXT
56 KPROBES_TEXT
Alexander Potapenko505a0ef2020-04-06 20:10:22 -070057 IRQENTRY_TEXT
58 SOFTIRQENTRY_TEXT
Sam Ravnborg7b313fd2010-06-19 17:19:25 +020059 *(.gnu.linkonce.t*)
60 }
61
62 .text2 : AT(ADDR(.text2) - LOAD_OFFSET) {
63 *(.text2)
64 }
65
Linus Torvalds1da177e2005-04-16 15:20:36 -070066#ifdef CONFIG_SMP
Sam Ravnborg7b313fd2010-06-19 17:19:25 +020067 .text..lock : AT(ADDR(.text..lock) - LOAD_OFFSET) {
68 *(.text..lock)
69 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070070#endif
Sam Ravnborg7b313fd2010-06-19 17:19:25 +020071 _etext = .;
Linus Torvalds1da177e2005-04-16 15:20:36 -070072
Sam Ravnborg7b313fd2010-06-19 17:19:25 +020073 /*
74 * Read-only data
75 */
David Mosberger-Tang336cdba82007-08-09 11:53:15 -060076
Sam Ravnborg7b313fd2010-06-19 17:19:25 +020077 /* MCA table */
78 . = ALIGN(16);
79 __mca_table : AT(ADDR(__mca_table) - LOAD_OFFSET) {
80 __start___mca_table = .;
81 *(__mca_table)
82 __stop___mca_table = .;
Russ Andersond89cfe72006-03-29 11:31:23 -060083 }
84
Sam Ravnborg7b313fd2010-06-19 17:19:25 +020085 .data..patch.phys_stack_reg : AT(ADDR(.data..patch.phys_stack_reg) - LOAD_OFFSET) {
86 __start___phys_stack_reg_patchlist = .;
87 *(.data..patch.phys_stack_reg)
88 __end___phys_stack_reg_patchlist = .;
Chen, Kenneth Wa0776ec2006-10-13 10:05:45 -070089 }
90
Sam Ravnborg7b313fd2010-06-19 17:19:25 +020091 /*
92 * Global data
93 */
94 _data = .;
Linus Torvalds1da177e2005-04-16 15:20:36 -070095
Sam Ravnborg7b313fd2010-06-19 17:19:25 +020096 /* Unwind info & table: */
97 . = ALIGN(8);
98 .IA_64.unwind_info : AT(ADDR(.IA_64.unwind_info) - LOAD_OFFSET) {
99 *(.IA_64.unwind_info*)
100 }
101 .IA_64.unwind : AT(ADDR(.IA_64.unwind) - LOAD_OFFSET) {
102 __start_unwind = .;
103 *(.IA_64.unwind*)
104 __end_unwind = .;
Kees Cook430c6b22019-10-29 14:13:27 -0700105 } :text :unwind
Sam Ravnborg7b313fd2010-06-19 17:19:25 +0200106 code_continues2 : {
Kees Cook430c6b22019-10-29 14:13:27 -0700107 } :text
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108
Kees Cookc8231822019-10-29 14:13:33 -0700109 RO_DATA(4096)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110
Sam Ravnborg7b313fd2010-06-19 17:19:25 +0200111 .opd : AT(ADDR(.opd) - LOAD_OFFSET) {
Sergey Senozhatsky8e307882017-11-10 08:48:26 +0900112 __start_opd = .;
Sam Ravnborg7b313fd2010-06-19 17:19:25 +0200113 *(.opd)
Sergey Senozhatsky8e307882017-11-10 08:48:26 +0900114 __end_opd = .;
Chen, Kenneth W39e18de2006-03-12 09:20:27 -0800115 }
116
Sam Ravnborg7b313fd2010-06-19 17:19:25 +0200117 /*
118 * Initialization code and data:
119 */
120 . = ALIGN(PAGE_SIZE);
121 __init_begin = .;
122
123 INIT_TEXT_SECTION(PAGE_SIZE)
124 INIT_DATA_SECTION(16)
125
126 .data..patch.vtop : AT(ADDR(.data..patch.vtop) - LOAD_OFFSET) {
127 __start___vtop_patchlist = .;
128 *(.data..patch.vtop)
129 __end___vtop_patchlist = .;
Tony Luck4dcc29e2008-05-27 13:23:16 -0700130 }
131
Sam Ravnborg7b313fd2010-06-19 17:19:25 +0200132 .data..patch.rse : AT(ADDR(.data..patch.rse) - LOAD_OFFSET) {
133 __start___rse_patchlist = .;
134 *(.data..patch.rse)
135 __end___rse_patchlist = .;
136 }
137
138 .data..patch.mckinley_e9 : AT(ADDR(.data..patch.mckinley_e9) - LOAD_OFFSET) {
139 __start___mckinley_e9_bundles = .;
140 *(.data..patch.mckinley_e9)
141 __end___mckinley_e9_bundles = .;
Chen, Kenneth W39e18de2006-03-12 09:20:27 -0800142 }
143
Tejun Heo36886472009-10-02 13:28:56 +0900144#ifdef CONFIG_SMP
Sam Ravnborg7b313fd2010-06-19 17:19:25 +0200145 . = ALIGN(PERCPU_PAGE_SIZE);
146 __cpu0_per_cpu = .;
147 . = . + PERCPU_PAGE_SIZE; /* cpu0 per-cpu space */
Tejun Heo36886472009-10-02 13:28:56 +0900148#endif
149
Sam Ravnborg7b313fd2010-06-19 17:19:25 +0200150 . = ALIGN(PAGE_SIZE);
151 __init_end = .;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152
Sam Ravnborg7b313fd2010-06-19 17:19:25 +0200153 .data..page_aligned : AT(ADDR(.data..page_aligned) - LOAD_OFFSET) {
154 PAGE_ALIGNED_DATA(PAGE_SIZE)
155 . = ALIGN(PAGE_SIZE);
156 __start_gate_section = .;
157 *(.data..gate)
158 __stop_gate_section = .;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159 }
Sam Ravnborg7b313fd2010-06-19 17:19:25 +0200160 /*
161 * make sure the gate page doesn't expose
162 * kernel data
163 */
164 . = ALIGN(PAGE_SIZE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165
Sam Ravnborg7b313fd2010-06-19 17:19:25 +0200166 /* Per-cpu data: */
167 . = ALIGN(PERCPU_PAGE_SIZE);
Tejun Heo19df0c22011-01-25 14:26:50 +0100168 PERCPU_VADDR(SMP_CACHE_BYTES, PERCPU_ADDR, :percpu)
Sam Ravnborg7b313fd2010-06-19 17:19:25 +0200169 __phys_per_cpu_start = __per_cpu_load;
170 /*
171 * ensure percpu data fits
172 * into percpu page size
173 */
174 . = __phys_per_cpu_start + PERCPU_PAGE_SIZE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700175
Sam Ravnborg7b313fd2010-06-19 17:19:25 +0200176 data : {
177 } :data
178 .data : AT(ADDR(.data) - LOAD_OFFSET) {
Tony Luck30f72762011-05-20 10:38:53 -0700179 _sdata = .;
Nelson Elhage6ae86352009-07-31 16:57:53 -0400180 INIT_TASK_DATA(PAGE_SIZE)
181 CACHELINE_ALIGNED_DATA(SMP_CACHE_BYTES)
182 READ_MOSTLY_DATA(SMP_CACHE_BYTES)
Sam Ravnborgca967252007-05-17 13:38:44 +0200183 DATA_DATA
184 *(.data1)
185 *(.gnu.linkonce.d*)
186 CONSTRUCTORS
187 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188
Peter Zijlstrab5effd32017-03-30 17:49:27 +0200189 BUG_TABLE
190
Sam Ravnborg7b313fd2010-06-19 17:19:25 +0200191 . = ALIGN(16); /* gp must be 16-byte aligned for exc. table */
192 .got : AT(ADDR(.got) - LOAD_OFFSET) {
193 *(.got.plt)
194 *(.got)
195 }
196 __gp = ADDR(.got) + 0x200000;
Nelson Elhage6ae86352009-07-31 16:57:53 -0400197
Sam Ravnborg7b313fd2010-06-19 17:19:25 +0200198 /*
199 * We want the small data sections together,
200 * so single-instruction offsets can access
201 * them all, and initialized data all before
202 * uninitialized, so we can shorten the
203 * on-disk segment size.
204 */
205 .sdata : AT(ADDR(.sdata) - LOAD_OFFSET) {
206 *(.sdata)
207 *(.sdata1)
208 *(.srdata)
209 }
210 _edata = .;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700211
Sam Ravnborg7b313fd2010-06-19 17:19:25 +0200212 BSS_SECTION(0, 0, 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213
Sam Ravnborg7b313fd2010-06-19 17:19:25 +0200214 _end = .;
Nelson Elhage6ae86352009-07-31 16:57:53 -0400215
Sam Ravnborg7b313fd2010-06-19 17:19:25 +0200216 code : {
Kees Cook430c6b22019-10-29 14:13:27 -0700217 } :text
Tejun Heo023bf6f2009-07-09 11:27:40 +0900218
Sam Ravnborg7b313fd2010-06-19 17:19:25 +0200219 STABS_DEBUG
220 DWARF_DEBUG
Kees Cookc604abc2020-08-21 12:42:45 -0700221 ELF_DETAILS
Sam Ravnborg7b313fd2010-06-19 17:19:25 +0200222
223 /* Default discards */
224 DISCARDS
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225}