GNU Linux-libre 4.4.299-gnu1
[releases.git] / arch / powerpc / kernel / vmlinux.lds.S
1 #ifdef CONFIG_PPC64
2 #define PROVIDE32(x)    PROVIDE(__unused__##x)
3 #else
4 #define PROVIDE32(x)    PROVIDE(x)
5 #endif
6 #include <asm/page.h>
7 #include <asm-generic/vmlinux.lds.h>
8 #include <asm/cache.h>
9 #include <asm/thread_info.h>
10
11 ENTRY(_stext)
12
13 PHDRS {
14         kernel PT_LOAD FLAGS(7); /* RWX */
15         notes PT_NOTE FLAGS(0);
16         dummy PT_NOTE FLAGS(0);
17
18         /* binutils < 2.18 has a bug that makes it misbehave when taking an
19            ELF file with all segments at load address 0 as input.  This
20            happens when running "strip" on vmlinux, because of the AT() magic
21            in this linker script.  People using GCC >= 4.2 won't run into
22            this problem, because the "build-id" support will put some data
23            into the "notes" segment (at a non-zero load address).
24
25            To work around this, we force some data into both the "dummy"
26            segment and the kernel segment, so the dummy segment will get a
27            non-zero load address.  It's not enough to always create the
28            "notes" segment, since if nothing gets assigned to it, its load
29            address will be zero.  */
30 }
31
32 #ifdef CONFIG_PPC64
33 OUTPUT_ARCH(powerpc:common64)
34 jiffies = jiffies_64;
35 #else
36 OUTPUT_ARCH(powerpc:common)
37 jiffies = jiffies_64 + 4;
38 #endif
39 SECTIONS
40 {
41         . = KERNELBASE;
42
43 /*
44  * Text, read only data and other permanent read-only sections
45  */
46
47         /* Text and gots */
48         .text : AT(ADDR(.text) - LOAD_OFFSET) {
49                 ALIGN_FUNCTION();
50                 HEAD_TEXT
51                 _text = .;
52                 /* careful! __ftr_alt_* sections need to be close to .text */
53                 *(.text .fixup __ftr_alt_* .ref.text)
54                 SCHED_TEXT
55                 LOCK_TEXT
56                 KPROBES_TEXT
57                 IRQENTRY_TEXT
58
59 #ifdef CONFIG_PPC32
60                 *(.got1)
61                 __got2_start = .;
62                 *(.got2)
63                 __got2_end = .;
64 #endif /* CONFIG_PPC32 */
65
66         } :kernel
67
68         . = ALIGN(PAGE_SIZE);
69         _etext = .;
70         PROVIDE32 (etext = .);
71
72         /* Read-only data */
73         RODATA
74
75 #ifdef CONFIG_PPC64
76         . = ALIGN(8);
77         __stf_entry_barrier_fixup : AT(ADDR(__stf_entry_barrier_fixup) - LOAD_OFFSET) {
78                 __start___stf_entry_barrier_fixup = .;
79                 *(__stf_entry_barrier_fixup)
80                 __stop___stf_entry_barrier_fixup = .;
81         }
82
83         . = ALIGN(8);
84         __uaccess_flush_fixup : AT(ADDR(__uaccess_flush_fixup) - LOAD_OFFSET) {
85                 __start___uaccess_flush_fixup = .;
86                 *(__uaccess_flush_fixup)
87                 __stop___uaccess_flush_fixup = .;
88         }
89
90         . = ALIGN(8);
91         __entry_flush_fixup : AT(ADDR(__entry_flush_fixup) - LOAD_OFFSET) {
92                 __start___entry_flush_fixup = .;
93                 *(__entry_flush_fixup)
94                 __stop___entry_flush_fixup = .;
95         }
96
97         . = ALIGN(8);
98         __stf_exit_barrier_fixup : AT(ADDR(__stf_exit_barrier_fixup) - LOAD_OFFSET) {
99                 __start___stf_exit_barrier_fixup = .;
100                 *(__stf_exit_barrier_fixup)
101                 __stop___stf_exit_barrier_fixup = .;
102         }
103
104         . = ALIGN(8);
105         __rfi_flush_fixup : AT(ADDR(__rfi_flush_fixup) - LOAD_OFFSET) {
106                 __start___rfi_flush_fixup = .;
107                 *(__rfi_flush_fixup)
108                 __stop___rfi_flush_fixup = .;
109         }
110 #endif /* CONFIG_PPC64 */
111
112 #ifdef CONFIG_PPC_BARRIER_NOSPEC
113         . = ALIGN(8);
114         __spec_barrier_fixup : AT(ADDR(__spec_barrier_fixup) - LOAD_OFFSET) {
115                 __start___barrier_nospec_fixup = .;
116                 *(__barrier_nospec_fixup)
117                 __stop___barrier_nospec_fixup = .;
118         }
119 #endif /* CONFIG_PPC_BARRIER_NOSPEC */
120
121 #ifdef CONFIG_PPC_FSL_BOOK3E
122         . = ALIGN(8);
123         __spec_btb_flush_fixup : AT(ADDR(__spec_btb_flush_fixup) - LOAD_OFFSET) {
124                 __start__btb_flush_fixup = .;
125                 *(__btb_flush_fixup)
126                 __stop__btb_flush_fixup = .;
127         }
128 #endif
129         EXCEPTION_TABLE(0)
130
131         NOTES :kernel :notes
132
133         /* The dummy segment contents for the bug workaround mentioned above
134            near PHDRS.  */
135         .dummy : AT(ADDR(.dummy) - LOAD_OFFSET) {
136                 LONG(0)
137                 LONG(0)
138                 LONG(0)
139         } :kernel :dummy
140
141 /*
142  * Init sections discarded at runtime
143  */
144         . = ALIGN(PAGE_SIZE);
145         __init_begin = .;
146         INIT_TEXT_SECTION(PAGE_SIZE) :kernel
147
148         /* .exit.text is discarded at runtime, not link time,
149          * to deal with references from __bug_table
150          */
151         .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
152                 EXIT_TEXT
153         }
154
155         .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) {
156                 INIT_DATA
157                 __vtop_table_begin = .;
158                 *(.vtop_fixup);
159                 __vtop_table_end = .;
160                 __ptov_table_begin = .;
161                 *(.ptov_fixup);
162                 __ptov_table_end = .;
163         }
164
165         .init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) {
166                 INIT_SETUP(16)
167         }
168
169         .initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET) {
170                 INIT_CALLS
171         }
172
173         .con_initcall.init : AT(ADDR(.con_initcall.init) - LOAD_OFFSET) {
174                 CON_INITCALL
175         }
176
177         SECURITY_INIT
178
179         . = ALIGN(8);
180         __ftr_fixup : AT(ADDR(__ftr_fixup) - LOAD_OFFSET) {
181                 __start___ftr_fixup = .;
182                 *(__ftr_fixup)
183                 __stop___ftr_fixup = .;
184         }
185         . = ALIGN(8);
186         __mmu_ftr_fixup : AT(ADDR(__mmu_ftr_fixup) - LOAD_OFFSET) {
187                 __start___mmu_ftr_fixup = .;
188                 *(__mmu_ftr_fixup)
189                 __stop___mmu_ftr_fixup = .;
190         }
191         . = ALIGN(8);
192         __lwsync_fixup : AT(ADDR(__lwsync_fixup) - LOAD_OFFSET) {
193                 __start___lwsync_fixup = .;
194                 *(__lwsync_fixup)
195                 __stop___lwsync_fixup = .;
196         }
197 #ifdef CONFIG_PPC64
198         . = ALIGN(8);
199         __fw_ftr_fixup : AT(ADDR(__fw_ftr_fixup) - LOAD_OFFSET) {
200                 __start___fw_ftr_fixup = .;
201                 *(__fw_ftr_fixup)
202                 __stop___fw_ftr_fixup = .;
203         }
204 #endif
205         .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) {
206                 INIT_RAM_FS
207         }
208
209         PERCPU_SECTION(L1_CACHE_BYTES)
210
211         . = ALIGN(8);
212         .machine.desc : AT(ADDR(.machine.desc) - LOAD_OFFSET) {
213                 __machine_desc_start = . ;
214                 *(.machine.desc)
215                 __machine_desc_end = . ;
216         }
217 #ifdef CONFIG_RELOCATABLE
218         . = ALIGN(8);
219         .dynsym : AT(ADDR(.dynsym) - LOAD_OFFSET)
220         {
221 #ifdef CONFIG_RELOCATABLE_PPC32
222                 __dynamic_symtab = .;
223 #endif
224                 *(.dynsym)
225         }
226         .dynstr : AT(ADDR(.dynstr) - LOAD_OFFSET) { *(.dynstr) }
227         .dynamic : AT(ADDR(.dynamic) - LOAD_OFFSET)
228         {
229                 __dynamic_start = .;
230                 *(.dynamic)
231         }
232         .hash : AT(ADDR(.hash) - LOAD_OFFSET) { *(.hash) }
233         .interp : AT(ADDR(.interp) - LOAD_OFFSET) { *(.interp) }
234         .rela.dyn : AT(ADDR(.rela.dyn) - LOAD_OFFSET)
235         {
236                 __rela_dyn_start = .;
237                 *(.rela*)
238         }
239 #endif
240         /* .exit.data is discarded at runtime, not link time,
241          * to deal with references from .exit.text
242          */
243         .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
244                 EXIT_DATA
245         }
246
247         /* freed after init ends here */
248         . = ALIGN(PAGE_SIZE);
249         __init_end = .;
250
251 /*
252  * And now the various read/write data
253  */
254
255         . = ALIGN(PAGE_SIZE);
256         _sdata = .;
257
258 #ifdef CONFIG_PPC32
259         .data : AT(ADDR(.data) - LOAD_OFFSET) {
260                 DATA_DATA
261                 *(.sdata)
262                 *(.got.plt) *(.got)
263         }
264 #else
265         .data : AT(ADDR(.data) - LOAD_OFFSET) {
266                 DATA_DATA
267                 *(.data.rel*)
268                 *(.toc1)
269                 *(.branch_lt)
270         }
271
272 #ifdef CONFIG_DEBUG_INFO_BTF
273         .BTF : AT(ADDR(.BTF) - LOAD_OFFSET) {
274                 *(.BTF)
275         }
276 #endif
277
278         .opd : AT(ADDR(.opd) - LOAD_OFFSET) {
279                 *(.opd)
280         }
281
282         . = ALIGN(256);
283         .got : AT(ADDR(.got) - LOAD_OFFSET) {
284                 __toc_start = .;
285 #ifndef CONFIG_RELOCATABLE
286                 __prom_init_toc_start = .;
287                 arch/powerpc/kernel/prom_init.o*(.toc .got)
288                 __prom_init_toc_end = .;
289 #endif
290                 *(.got)
291                 *(.toc)
292         }
293 #endif
294
295         /* The initial task and kernel stack */
296         INIT_TASK_DATA_SECTION(THREAD_SIZE)
297
298         .data..page_aligned : AT(ADDR(.data..page_aligned) - LOAD_OFFSET) {
299                 PAGE_ALIGNED_DATA(PAGE_SIZE)
300         }
301
302         .data..cacheline_aligned : AT(ADDR(.data..cacheline_aligned) - LOAD_OFFSET) {
303                 CACHELINE_ALIGNED_DATA(L1_CACHE_BYTES)
304         }
305
306         .data..read_mostly : AT(ADDR(.data..read_mostly) - LOAD_OFFSET) {
307                 READ_MOSTLY_DATA(L1_CACHE_BYTES)
308         }
309
310         . = ALIGN(PAGE_SIZE);
311         .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
312                 NOSAVE_DATA
313         }
314
315         . = ALIGN(PAGE_SIZE);
316         _edata  =  .;
317         PROVIDE32 (edata = .);
318
319 /*
320  * And finally the bss
321  */
322
323         BSS_SECTION(0, 0, 0)
324
325         . = ALIGN(PAGE_SIZE);
326         _end = . ;
327         PROVIDE32 (end = .);
328
329         /* Sections to be discarded. */
330         DISCARDS
331 }