]> bbs.cooldavid.org Git - net-next-2.6.git/blob - arch/x86/kernel/vmlinux_32.lds.S
x86: beautify vmlinux_32.lds.S
[net-next-2.6.git] / arch / x86 / kernel / vmlinux_32.lds.S
1 /* ld script to make i386 Linux kernel
2  * Written by Martin Mares <mj@atrey.karlin.mff.cuni.cz>;
3  *
4  * Don't define absolute symbols until and unless you know that symbol
5  * value is should remain constant even if kernel image is relocated
6  * at run time. Absolute symbols are not relocated. If symbol value should
7  * change if kernel is relocated, make the symbol section relative and
8  * put it inside the section definition.
9  */
10
11 #define LOAD_OFFSET __PAGE_OFFSET
12
13 #include <asm-generic/vmlinux.lds.h>
14 #include <asm/thread_info.h>
15 #include <asm/page_types.h>
16 #include <asm/cache.h>
17 #include <asm/boot.h>
18
19 OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
20 OUTPUT_ARCH(i386)
21 ENTRY(phys_startup_32)
22 jiffies = jiffies_64;
23
24 PHDRS {
25         text PT_LOAD FLAGS(5);          /* R_E */
26         data PT_LOAD FLAGS(7);          /* RWE */
27         note PT_NOTE FLAGS(0);          /* ___ */
28 }
29 SECTIONS
30 {
31         . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
32         phys_startup_32 = startup_32 - LOAD_OFFSET;
33
34         /* Text and read-only data */
35         .text.head : AT(ADDR(.text.head) - LOAD_OFFSET) {
36                 _text = .;
37                 *(.text.head)
38         } :text = 0x9090
39
40         /* read-only */
41         .text : AT(ADDR(.text) - LOAD_OFFSET) {
42                 /* not really needed, already page aligned */
43                 . = ALIGN(PAGE_SIZE);
44                 *(.text.page_aligned)
45                 TEXT_TEXT
46                 SCHED_TEXT
47                 LOCK_TEXT
48                 KPROBES_TEXT
49                 IRQENTRY_TEXT
50                 *(.fixup)
51                 *(.gnu.warning)
52                 /* End of text section */
53                 _etext = .;
54         } :text = 0x9090
55
56         NOTES :text :note
57
58         /* Exception table */
59         . = ALIGN(16);
60         __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {
61                 __start___ex_table = .;
62                  *(__ex_table)
63                 __stop___ex_table = .;
64         } :text = 0x9090
65
66         RODATA
67
68         /* writeable */
69         . = ALIGN(PAGE_SIZE);
70         /* Data */
71         .data : AT(ADDR(.data) - LOAD_OFFSET) {
72                 DATA_DATA
73                 CONSTRUCTORS
74         } :data
75
76         . = ALIGN(PAGE_SIZE);
77         .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
78                 __nosave_begin = .;
79                 *(.data.nosave)
80                 . = ALIGN(PAGE_SIZE);
81                 __nosave_end = .;
82         }
83
84         . = ALIGN(PAGE_SIZE);
85         .data.page_aligned : AT(ADDR(.data.page_aligned) - LOAD_OFFSET) {
86                 *(.data.page_aligned)
87                 *(.data.idt)
88         }
89
90         . = ALIGN(32);
91         .data.cacheline_aligned :
92                 AT(ADDR(.data.cacheline_aligned) - LOAD_OFFSET) {
93                 *(.data.cacheline_aligned)
94         }
95
96         /* rarely changed data like cpu maps */
97         . = ALIGN(32);
98         .data.read_mostly : AT(ADDR(.data.read_mostly) - LOAD_OFFSET) {
99                 *(.data.read_mostly)
100
101                 /* End of data section */
102                 _edata = .;
103         }
104
105         /* init_task */
106         . = ALIGN(THREAD_SIZE);
107         .data.init_task : AT(ADDR(.data.init_task) - LOAD_OFFSET) {
108                 *(.data.init_task)
109         }
110
111         . = ALIGN(PAGE_SIZE);
112         .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
113                 /* might get freed after init */
114                 __smp_locks = .;
115                 *(.smp_locks)
116                 __smp_locks_end = .;
117         }
118         /* will be freed after init
119          * Following ALIGN() is required to make sure no other data falls on the
120          * same page where __smp_alt_end is pointing as that page might be freed
121          * after boot. Always make sure that ALIGN() directive is present after
122          * the section which contains __smp_alt_end.
123          */
124         . = ALIGN(PAGE_SIZE);
125
126         /* Init code and data - will be freed after init */
127         . = ALIGN(PAGE_SIZE);
128         .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) {
129                 __init_begin = .;
130                 _sinittext = .;
131                 INIT_TEXT
132                 _einittext = .;
133         }
134
135         .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) {
136                 INIT_DATA
137         }
138
139         . = ALIGN(16);
140         .init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) {
141                 __setup_start = .;
142                 *(.init.setup)
143                 __setup_end = .;
144         }
145         .initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET) {
146                 __initcall_start = .;
147                 INITCALLS
148                 __initcall_end = .;
149         }
150
151         .con_initcall.init : AT(ADDR(.con_initcall.init) - LOAD_OFFSET) {
152                 __con_initcall_start = .;
153                 *(.con_initcall.init)
154                 __con_initcall_end = .;
155         }
156
157         .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
158                 __x86_cpu_dev_start = .;
159                 *(.x86_cpu_dev.init)
160                 __x86_cpu_dev_end = .;
161         }
162
163         SECURITY_INIT
164
165         . = ALIGN(4);
166         .altinstructions : AT(ADDR(.altinstructions) - LOAD_OFFSET) {
167                 __alt_instructions = .;
168                 *(.altinstructions)
169                 __alt_instructions_end = .;
170         }
171
172         .altinstr_replacement : AT(ADDR(.altinstr_replacement) - LOAD_OFFSET) {
173                 *(.altinstr_replacement)
174         }
175
176         . = ALIGN(4);
177         .parainstructions : AT(ADDR(.parainstructions) - LOAD_OFFSET) {
178                 __parainstructions = .;
179                 *(.parainstructions)
180                 __parainstructions_end = .;
181         }
182
183         /*
184          * .exit.text is discard at runtime, not link time, to deal with
185          *  references from .altinstructions and .eh_frame
186          */
187         .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
188                 EXIT_TEXT
189         }
190
191         .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
192                 EXIT_DATA
193         }
194
195 #if defined(CONFIG_BLK_DEV_INITRD)
196         . = ALIGN(PAGE_SIZE);
197         .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) {
198                 __initramfs_start = .;
199                 *(.init.ramfs)
200                 __initramfs_end = .;
201         }
202 #endif
203
204         PERCPU(PAGE_SIZE)
205
206         . = ALIGN(PAGE_SIZE);
207         /* freed after init ends here */
208
209         /* BSS */
210         .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
211                 __init_end = .;
212                 __bss_start = .;
213                 *(.bss.page_aligned)
214                 *(.bss)
215                 . = ALIGN(4);
216                 __bss_stop = .;
217         }
218
219         .brk : AT(ADDR(.brk) - LOAD_OFFSET) {
220                 . = ALIGN(PAGE_SIZE);
221                 __brk_base = .;
222                 . += 64 * 1024;         /* 64k alignment slop space */
223                 *(.brk_reservation)     /* areas brk users have reserved */
224                 __brk_limit = .;
225         }
226
227         .end : AT(ADDR(.end) - LOAD_OFFSET) {
228                 _end = . ;
229         }
230
231         /* Sections to be discarded */
232         /DISCARD/ : {
233                 *(.exitcall.exit)
234                 *(.discard)
235         }
236
237         STABS_DEBUG
238         DWARF_DEBUG
239 }
240
241 /*
242  * Build-time check on the image size:
243  */
244 ASSERT((_end - LOAD_OFFSET <= KERNEL_IMAGE_SIZE),
245         "kernel image bigger than KERNEL_IMAGE_SIZE")
246
247 #ifdef CONFIG_KEXEC
248 /* Link time checks */
249 #include <asm/kexec.h>
250
251 ASSERT(kexec_control_code_size <= KEXEC_CONTROL_CODE_MAX_SIZE,
252        "kexec control code size is too big")
253 #endif