x86: Use section .data.page_aligned for the idt_table.
[safe/jmp/linux-2.6] / arch / x86 / kernel / vmlinux.lds.S
1 /*
2  * ld script for the x86 kernel
3  *
4  * Historic 32-bit version written by Martin Mares <mj@atrey.karlin.mff.cuni.cz>
5  *
6  * Modernisation, unification and other changes and fixes:
7  *   Copyright (C) 2007-2009  Sam Ravnborg <sam@ravnborg.org>
8  *
9  *
10  * Don't define absolute symbols until and unless you know that symbol
11  * value is should remain constant even if kernel image is relocated
12  * at run time. Absolute symbols are not relocated. If symbol value should
13  * change if kernel is relocated, make the symbol section relative and
14  * put it inside the section definition.
15  */
16
17 #ifdef CONFIG_X86_32
18 #define LOAD_OFFSET __PAGE_OFFSET
19 #else
20 #define LOAD_OFFSET __START_KERNEL_map
21 #endif
22
23 #include <asm-generic/vmlinux.lds.h>
24 #include <asm/asm-offsets.h>
25 #include <asm/thread_info.h>
26 #include <asm/page_types.h>
27 #include <asm/cache.h>
28 #include <asm/boot.h>
29
30 #undef i386     /* in case the preprocessor is a 32bit one */
31
32 OUTPUT_FORMAT(CONFIG_OUTPUT_FORMAT, CONFIG_OUTPUT_FORMAT, CONFIG_OUTPUT_FORMAT)
33
34 #ifdef CONFIG_X86_32
35 OUTPUT_ARCH(i386)
36 ENTRY(phys_startup_32)
37 jiffies = jiffies_64;
38 #else
39 OUTPUT_ARCH(i386:x86-64)
40 ENTRY(phys_startup_64)
41 jiffies_64 = jiffies;
42 #endif
43
44 PHDRS {
45         text PT_LOAD FLAGS(5);          /* R_E */
46         data PT_LOAD FLAGS(7);          /* RWE */
47 #ifdef CONFIG_X86_64
48         user PT_LOAD FLAGS(7);          /* RWE */
49 #ifdef CONFIG_SMP
50         percpu PT_LOAD FLAGS(7);        /* RWE */
51 #endif
52         init PT_LOAD FLAGS(7);          /* RWE */
53 #endif
54         note PT_NOTE FLAGS(0);          /* ___ */
55 }
56
57 SECTIONS
58 {
59 #ifdef CONFIG_X86_32
60         . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
61         phys_startup_32 = startup_32 - LOAD_OFFSET;
62 #else
63         . = __START_KERNEL;
64         phys_startup_64 = startup_64 - LOAD_OFFSET;
65 #endif
66
67         /* Text and read-only data */
68         .text :  AT(ADDR(.text) - LOAD_OFFSET) {
69                 _text = .;
70                 /* bootstrapping code */
71                 HEAD_TEXT
72 #ifdef CONFIG_X86_32
73                 . = ALIGN(PAGE_SIZE);
74                 *(.text.page_aligned)
75 #endif
76                 . = ALIGN(8);
77                 _stext = .;
78                 TEXT_TEXT
79                 SCHED_TEXT
80                 LOCK_TEXT
81                 KPROBES_TEXT
82                 IRQENTRY_TEXT
83                 *(.fixup)
84                 *(.gnu.warning)
85                 /* End of text section */
86                 _etext = .;
87         } :text = 0x9090
88
89         NOTES :text :note
90
91         /* Exception table */
92         . = ALIGN(16);
93         __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {
94                 __start___ex_table = .;
95                 *(__ex_table)
96                 __stop___ex_table = .;
97         } :text = 0x9090
98
99         RO_DATA(PAGE_SIZE)
100
101         /* Data */
102         .data : AT(ADDR(.data) - LOAD_OFFSET) {
103                 /* Start of data section */
104                 _sdata = .;
105
106                 /* init_task */
107                 INIT_TASK_DATA(THREAD_SIZE)
108
109 #ifdef CONFIG_X86_32
110                 /* 32 bit has nosave before _edata */
111                 NOSAVE_DATA
112 #endif
113
114                 PAGE_ALIGNED_DATA(PAGE_SIZE)
115
116                 CACHELINE_ALIGNED_DATA(CONFIG_X86_L1_CACHE_BYTES)
117
118                 DATA_DATA
119                 CONSTRUCTORS
120
121                 /* rarely changed data like cpu maps */
122                 READ_MOSTLY_DATA(CONFIG_X86_INTERNODE_CACHE_BYTES)
123
124                 /* End of data section */
125                 _edata = .;
126         } :data
127
128 #ifdef CONFIG_X86_64
129
130 #define VSYSCALL_ADDR (-10*1024*1024)
131
132 #define VLOAD_OFFSET (VSYSCALL_ADDR - __vsyscall_0 + LOAD_OFFSET)
133 #define VLOAD(x) (ADDR(x) - VLOAD_OFFSET)
134
135 #define VVIRT_OFFSET (VSYSCALL_ADDR - __vsyscall_0)
136 #define VVIRT(x) (ADDR(x) - VVIRT_OFFSET)
137
138         . = ALIGN(4096);
139         __vsyscall_0 = .;
140
141         . = VSYSCALL_ADDR;
142         .vsyscall_0 : AT(VLOAD(.vsyscall_0)) {
143                 *(.vsyscall_0)
144         } :user
145
146         . = ALIGN(CONFIG_X86_L1_CACHE_BYTES);
147         .vsyscall_fn : AT(VLOAD(.vsyscall_fn)) {
148                 *(.vsyscall_fn)
149         }
150
151         . = ALIGN(CONFIG_X86_L1_CACHE_BYTES);
152         .vsyscall_gtod_data : AT(VLOAD(.vsyscall_gtod_data)) {
153                 *(.vsyscall_gtod_data)
154         }
155
156         vsyscall_gtod_data = VVIRT(.vsyscall_gtod_data);
157         .vsyscall_clock : AT(VLOAD(.vsyscall_clock)) {
158                 *(.vsyscall_clock)
159         }
160         vsyscall_clock = VVIRT(.vsyscall_clock);
161
162
163         .vsyscall_1 ADDR(.vsyscall_0) + 1024: AT(VLOAD(.vsyscall_1)) {
164                 *(.vsyscall_1)
165         }
166         .vsyscall_2 ADDR(.vsyscall_0) + 2048: AT(VLOAD(.vsyscall_2)) {
167                 *(.vsyscall_2)
168         }
169
170         .vgetcpu_mode : AT(VLOAD(.vgetcpu_mode)) {
171                 *(.vgetcpu_mode)
172         }
173         vgetcpu_mode = VVIRT(.vgetcpu_mode);
174
175         . = ALIGN(CONFIG_X86_L1_CACHE_BYTES);
176         .jiffies : AT(VLOAD(.jiffies)) {
177                 *(.jiffies)
178         }
179         jiffies = VVIRT(.jiffies);
180
181         .vsyscall_3 ADDR(.vsyscall_0) + 3072: AT(VLOAD(.vsyscall_3)) {
182                 *(.vsyscall_3)
183         }
184
185         . = __vsyscall_0 + PAGE_SIZE;
186
187 #undef VSYSCALL_ADDR
188 #undef VLOAD_OFFSET
189 #undef VLOAD
190 #undef VVIRT_OFFSET
191 #undef VVIRT
192
193 #endif /* CONFIG_X86_64 */
194
195         /* Init code and data - will be freed after init */
196         . = ALIGN(PAGE_SIZE);
197         .init.begin : AT(ADDR(.init.begin) - LOAD_OFFSET) {
198                 __init_begin = .; /* paired with __init_end */
199         }
200
201 #if defined(CONFIG_X86_64) && defined(CONFIG_SMP)
202         /*
203          * percpu offsets are zero-based on SMP.  PERCPU_VADDR() changes the
204          * output PHDR, so the next output section - .init.text - should
205          * start another segment - init.
206          */
207         PERCPU_VADDR(0, :percpu)
208 #endif
209
210         .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) {
211                 _sinittext = .;
212                 INIT_TEXT
213                 _einittext = .;
214         }
215 #ifdef CONFIG_X86_64
216         :init
217 #endif
218
219         .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) {
220                 INIT_DATA
221         }
222
223         . = ALIGN(16);
224         .init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) {
225                 __setup_start = .;
226                 *(.init.setup)
227                 __setup_end = .;
228         }
229         .initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET) {
230                 __initcall_start = .;
231                 INITCALLS
232                 __initcall_end = .;
233         }
234
235         .con_initcall.init : AT(ADDR(.con_initcall.init) - LOAD_OFFSET) {
236                 __con_initcall_start = .;
237                 *(.con_initcall.init)
238                 __con_initcall_end = .;
239         }
240
241         .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
242                 __x86_cpu_dev_start = .;
243                 *(.x86_cpu_dev.init)
244                 __x86_cpu_dev_end = .;
245         }
246
247         SECURITY_INIT
248
249         . = ALIGN(8);
250         .parainstructions : AT(ADDR(.parainstructions) - LOAD_OFFSET) {
251                 __parainstructions = .;
252                 *(.parainstructions)
253                 __parainstructions_end = .;
254         }
255
256         . = ALIGN(8);
257         .altinstructions : AT(ADDR(.altinstructions) - LOAD_OFFSET) {
258                 __alt_instructions = .;
259                 *(.altinstructions)
260                 __alt_instructions_end = .;
261         }
262
263         .altinstr_replacement : AT(ADDR(.altinstr_replacement) - LOAD_OFFSET) {
264                 *(.altinstr_replacement)
265         }
266
267         /*
268          * .exit.text is discard at runtime, not link time, to deal with
269          *  references from .altinstructions and .eh_frame
270          */
271         .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
272                 EXIT_TEXT
273         }
274
275         .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
276                 EXIT_DATA
277         }
278
279 #ifdef CONFIG_BLK_DEV_INITRD
280         . = ALIGN(PAGE_SIZE);
281         .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) {
282                 __initramfs_start = .;
283                 *(.init.ramfs)
284                 __initramfs_end = .;
285         }
286 #endif
287
288 #if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP)
289         PERCPU(PAGE_SIZE)
290 #endif
291
292         . = ALIGN(PAGE_SIZE);
293
294         /* freed after init ends here */
295         .init.end : AT(ADDR(.init.end) - LOAD_OFFSET) {
296                 __init_end = .;
297         }
298
299         /*
300          * smp_locks might be freed after init
301          * start/end must be page aligned
302          */
303         . = ALIGN(PAGE_SIZE);
304         .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
305                 __smp_locks = .;
306                 *(.smp_locks)
307                 __smp_locks_end = .;
308                 . = ALIGN(PAGE_SIZE);
309         }
310
311 #ifdef CONFIG_X86_64
312         .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
313                 NOSAVE_DATA
314         }
315 #endif
316
317         /* BSS */
318         . = ALIGN(PAGE_SIZE);
319         .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
320                 __bss_start = .;
321                 *(.bss.page_aligned)
322                 *(.bss)
323                 . = ALIGN(4);
324                 __bss_stop = .;
325         }
326
327         . = ALIGN(PAGE_SIZE);
328         .brk : AT(ADDR(.brk) - LOAD_OFFSET) {
329                 __brk_base = .;
330                 . += 64 * 1024;         /* 64k alignment slop space */
331                 *(.brk_reservation)     /* areas brk users have reserved */
332                 __brk_limit = .;
333         }
334
335         .end : AT(ADDR(.end) - LOAD_OFFSET) {
336                 _end = .;
337         }
338
339         STABS_DEBUG
340         DWARF_DEBUG
341
342         /* Sections to be discarded */
343         DISCARDS
344         /DISCARD/ : { *(.eh_frame) }
345 }
346
347
348 #ifdef CONFIG_X86_32
349 . = ASSERT((_end - LOAD_OFFSET <= KERNEL_IMAGE_SIZE),
350            "kernel image bigger than KERNEL_IMAGE_SIZE");
351 #else
352 /*
353  * Per-cpu symbols which need to be offset from __per_cpu_load
354  * for the boot processor.
355  */
356 #define INIT_PER_CPU(x) init_per_cpu__##x = per_cpu__##x + __per_cpu_load
357 INIT_PER_CPU(gdt_page);
358 INIT_PER_CPU(irq_stack_union);
359
360 /*
361  * Build-time check on the image size:
362  */
363 . = ASSERT((_end - _text <= KERNEL_IMAGE_SIZE),
364            "kernel image bigger than KERNEL_IMAGE_SIZE");
365
366 #ifdef CONFIG_SMP
367 . = ASSERT((per_cpu__irq_stack_union == 0),
368            "irq_stack_union is not at start of per-cpu area");
369 #endif
370
371 #endif /* CONFIG_X86_32 */
372
373 #ifdef CONFIG_KEXEC
374 #include <asm/kexec.h>
375
376 . = ASSERT(kexec_control_code_size <= KEXEC_CONTROL_CODE_MAX_SIZE,
377            "kexec control code size is too big");
378 #endif
379