x86, vmlinux.lds: unify data output sections
[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 and unification done by Sam Ravnborg <sam@ravnborg.org>
7  *
8  *
9  * Don't define absolute symbols until and unless you know that symbol
10  * value is should remain constant even if kernel image is relocated
11  * at run time. Absolute symbols are not relocated. If symbol value should
12  * change if kernel is relocated, make the symbol section relative and
13  * put it inside the section definition.
14  */
15
16 #ifdef CONFIG_X86_32
17 #define LOAD_OFFSET __PAGE_OFFSET
18 #else
19 #define LOAD_OFFSET __START_KERNEL_map
20 #endif
21
22 #include <asm-generic/vmlinux.lds.h>
23 #include <asm/asm-offsets.h>
24 #include <asm/thread_info.h>
25 #include <asm/page_types.h>
26 #include <asm/cache.h>
27 #include <asm/boot.h>
28
29 #undef i386     /* in case the preprocessor is a 32bit one */
30
31 OUTPUT_FORMAT(CONFIG_OUTPUT_FORMAT, CONFIG_OUTPUT_FORMAT, CONFIG_OUTPUT_FORMAT)
32
33 #ifdef CONFIG_X86_32
34 OUTPUT_ARCH(i386)
35 ENTRY(phys_startup_32)
36 jiffies = jiffies_64;
37 #else
38 OUTPUT_ARCH(i386:x86-64)
39 ENTRY(phys_startup_64)
40 jiffies_64 = jiffies;
41 #endif
42
43 PHDRS {
44         text PT_LOAD FLAGS(5);          /* R_E */
45         data PT_LOAD FLAGS(7);          /* RWE */
46 #ifdef CONFIG_X86_64
47         user PT_LOAD FLAGS(7);          /* RWE */
48         data.init PT_LOAD FLAGS(7);     /* RWE */
49 #ifdef CONFIG_SMP
50         percpu PT_LOAD FLAGS(7);        /* RWE */
51 #endif
52         data.init2 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
69         /* bootstrapping code */
70         .text.head : AT(ADDR(.text.head) - LOAD_OFFSET) {
71                 _text = .;
72                 *(.text.head)
73         } :text = 0x9090
74
75         /* The rest of the text */
76         .text :  AT(ADDR(.text) - LOAD_OFFSET) {
77 #ifdef CONFIG_X86_32
78                 /* not really needed, already page aligned */
79                 . = ALIGN(PAGE_SIZE);
80                 *(.text.page_aligned)
81 #endif
82                 . = ALIGN(8);
83                 _stext = .;
84                 TEXT_TEXT
85                 SCHED_TEXT
86                 LOCK_TEXT
87                 KPROBES_TEXT
88                 IRQENTRY_TEXT
89                 *(.fixup)
90                 *(.gnu.warning)
91                 /* End of text section */
92                 _etext = .;
93         } :text = 0x9090
94
95         NOTES :text :note
96
97         /* Exception table */
98         . = ALIGN(16);
99         __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {
100                 __start___ex_table = .;
101                 *(__ex_table)
102                 __stop___ex_table = .;
103         } :text = 0x9090
104
105         RODATA
106
107         /* Data */
108         . = ALIGN(PAGE_SIZE);
109         .data : AT(ADDR(.data) - LOAD_OFFSET) {
110                 DATA_DATA
111                 CONSTRUCTORS
112
113 #ifdef CONFIG_X86_64
114                 /* End of data section */
115                 _edata = .;
116 #endif
117         } :data
118
119 #ifdef CONFIG_X86_32
120         /* 32 bit has nosave before _edata */
121         . = ALIGN(PAGE_SIZE);
122         .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
123                 __nosave_begin = .;
124                 *(.data.nosave)
125                 . = ALIGN(PAGE_SIZE);
126                 __nosave_end = .;
127         }
128 #endif
129
130         . = ALIGN(PAGE_SIZE);
131         .data.page_aligned : AT(ADDR(.data.page_aligned) - LOAD_OFFSET) {
132                 *(.data.page_aligned)
133                 *(.data.idt)
134         }
135
136 #ifdef CONFIG_X86_32
137         . = ALIGN(32);
138 #else
139         . = ALIGN(PAGE_SIZE);
140         . = ALIGN(CONFIG_X86_L1_CACHE_BYTES);
141 #endif
142         .data.cacheline_aligned :
143                 AT(ADDR(.data.cacheline_aligned) - LOAD_OFFSET) {
144                 *(.data.cacheline_aligned)
145         }
146
147         /* rarely changed data like cpu maps */
148 #ifdef CONFIG_X86_32
149         . = ALIGN(32);
150 #else
151         . = ALIGN(CONFIG_X86_INTERNODE_CACHE_BYTES);
152 #endif
153         .data.read_mostly : AT(ADDR(.data.read_mostly) - LOAD_OFFSET) {
154                 *(.data.read_mostly)
155
156 #ifdef CONFIG_X86_32
157                 /* End of data section */
158                 _edata = .;
159 #endif
160         }
161
162
163 #ifdef CONFIG_X86_32
164 # include "vmlinux_32.lds.S"
165 #else
166 # include "vmlinux_64.lds.S"
167 #endif
168
169         STABS_DEBUG
170         DWARF_DEBUG
171 }
172
173
174 #ifdef CONFIG_X86_32
175 ASSERT((_end - LOAD_OFFSET <= KERNEL_IMAGE_SIZE),
176         "kernel image bigger than KERNEL_IMAGE_SIZE")
177 #else
178 /*
179  * Per-cpu symbols which need to be offset from __per_cpu_load
180  * for the boot processor.
181  */
182 #define INIT_PER_CPU(x) init_per_cpu__##x = per_cpu__##x + __per_cpu_load
183 INIT_PER_CPU(gdt_page);
184 INIT_PER_CPU(irq_stack_union);
185
186 /*
187  * Build-time check on the image size:
188  */
189 ASSERT((_end - _text <= KERNEL_IMAGE_SIZE),
190         "kernel image bigger than KERNEL_IMAGE_SIZE")
191
192 #ifdef CONFIG_SMP
193 ASSERT((per_cpu__irq_stack_union == 0),
194         "irq_stack_union is not at start of per-cpu area");
195 #endif
196
197 #endif /* CONFIG_X86_32 */
198
199 #ifdef CONFIG_KEXEC
200 #include <asm/kexec.h>
201
202 ASSERT(kexec_control_code_size <= KEXEC_CONTROL_CODE_MAX_SIZE,
203        "kexec control code size is too big")
204 #endif
205