2 * ld script for the x86 kernel
4 * Historic 32-bit version written by Martin Mares <mj@atrey.karlin.mff.cuni.cz>
6 * Modernisation and unification done by Sam Ravnborg <sam@ravnborg.org>
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.
17 #define LOAD_OFFSET __PAGE_OFFSET
19 #define LOAD_OFFSET __START_KERNEL_map
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>
29 #undef i386 /* in case the preprocessor is a 32bit one */
31 OUTPUT_FORMAT(CONFIG_OUTPUT_FORMAT, CONFIG_OUTPUT_FORMAT, CONFIG_OUTPUT_FORMAT)
35 ENTRY(phys_startup_32)
38 OUTPUT_ARCH(i386:x86-64)
39 ENTRY(phys_startup_64)
44 text PT_LOAD FLAGS(5); /* R_E */
45 data PT_LOAD FLAGS(7); /* RWE */
47 user PT_LOAD FLAGS(7); /* RWE */
48 data.init PT_LOAD FLAGS(7); /* RWE */
50 percpu PT_LOAD FLAGS(7); /* RWE */
52 data.init2 PT_LOAD FLAGS(7); /* RWE */
54 note PT_NOTE FLAGS(0); /* ___ */
60 . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
61 phys_startup_32 = startup_32 - LOAD_OFFSET;
64 phys_startup_64 = startup_64 - LOAD_OFFSET;
67 /* Text and read-only data */
69 /* bootstrapping code */
70 .text.head : AT(ADDR(.text.head) - LOAD_OFFSET) {
75 /* The rest of the text */
76 .text : AT(ADDR(.text) - LOAD_OFFSET) {
78 /* not really needed, already page aligned */
91 /* End of text section */
99 __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {
100 __start___ex_table = .;
102 __stop___ex_table = .;
108 . = ALIGN(PAGE_SIZE);
109 .data : AT(ADDR(.data) - LOAD_OFFSET) {
114 /* End of data section */
120 /* 32 bit has nosave before _edata */
121 . = ALIGN(PAGE_SIZE);
122 .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
125 . = ALIGN(PAGE_SIZE);
130 . = ALIGN(PAGE_SIZE);
131 .data.page_aligned : AT(ADDR(.data.page_aligned) - LOAD_OFFSET) {
132 *(.data.page_aligned)
139 . = ALIGN(PAGE_SIZE);
140 . = ALIGN(CONFIG_X86_L1_CACHE_BYTES);
142 .data.cacheline_aligned :
143 AT(ADDR(.data.cacheline_aligned) - LOAD_OFFSET) {
144 *(.data.cacheline_aligned)
147 /* rarely changed data like cpu maps */
151 . = ALIGN(CONFIG_X86_INTERNODE_CACHE_BYTES);
153 .data.read_mostly : AT(ADDR(.data.read_mostly) - LOAD_OFFSET) {
157 /* End of data section */
164 #define VSYSCALL_ADDR (-10*1024*1024)
165 #define VSYSCALL_PHYS_ADDR ((LOADADDR(.data.read_mostly) + \
166 SIZEOF(.data.read_mostly) + 4095) & ~(4095))
167 #define VSYSCALL_VIRT_ADDR ((ADDR(.data.read_mostly) + \
168 SIZEOF(.data.read_mostly) + 4095) & ~(4095))
170 #define VLOAD_OFFSET (VSYSCALL_ADDR - VSYSCALL_PHYS_ADDR)
171 #define VLOAD(x) (ADDR(x) - VLOAD_OFFSET)
173 #define VVIRT_OFFSET (VSYSCALL_ADDR - VSYSCALL_VIRT_ADDR)
174 #define VVIRT(x) (ADDR(x) - VVIRT_OFFSET)
177 .vsyscall_0 : AT(VSYSCALL_PHYS_ADDR) {
181 __vsyscall_0 = VSYSCALL_VIRT_ADDR;
183 . = ALIGN(CONFIG_X86_L1_CACHE_BYTES);
184 .vsyscall_fn : AT(VLOAD(.vsyscall_fn)) {
188 . = ALIGN(CONFIG_X86_L1_CACHE_BYTES);
189 .vsyscall_gtod_data : AT(VLOAD(.vsyscall_gtod_data)) {
190 *(.vsyscall_gtod_data)
193 vsyscall_gtod_data = VVIRT(.vsyscall_gtod_data);
194 .vsyscall_clock : AT(VLOAD(.vsyscall_clock)) {
197 vsyscall_clock = VVIRT(.vsyscall_clock);
200 .vsyscall_1 ADDR(.vsyscall_0) + 1024: AT(VLOAD(.vsyscall_1)) {
203 .vsyscall_2 ADDR(.vsyscall_0) + 2048: AT(VLOAD(.vsyscall_2)) {
207 .vgetcpu_mode : AT(VLOAD(.vgetcpu_mode)) {
210 vgetcpu_mode = VVIRT(.vgetcpu_mode);
212 . = ALIGN(CONFIG_X86_L1_CACHE_BYTES);
213 .jiffies : AT(VLOAD(.jiffies)) {
216 jiffies = VVIRT(.jiffies);
218 .vsyscall_3 ADDR(.vsyscall_0) + 3072: AT(VLOAD(.vsyscall_3)) {
222 . = VSYSCALL_VIRT_ADDR + PAGE_SIZE;
225 #undef VSYSCALL_PHYS_ADDR
226 #undef VSYSCALL_VIRT_ADDR
232 #endif /* CONFIG_X86_64 */
235 . = ALIGN(THREAD_SIZE);
236 .data.init_task : AT(ADDR(.data.init_task) - LOAD_OFFSET) {
244 * smp_locks might be freed after init
245 * start/end must be page aligned
247 . = ALIGN(PAGE_SIZE);
248 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
252 . = ALIGN(PAGE_SIZE);
255 /* Init code and data - will be freed after init */
256 . = ALIGN(PAGE_SIZE);
257 __init_begin = .; /* paired with __init_end */
258 .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) {
264 .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) {
269 .init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) {
274 .initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET) {
275 __initcall_start = .;
280 .con_initcall.init : AT(ADDR(.con_initcall.init) - LOAD_OFFSET) {
281 __con_initcall_start = .;
282 *(.con_initcall.init)
283 __con_initcall_end = .;
286 .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
287 __x86_cpu_dev_start = .;
289 __x86_cpu_dev_end = .;
296 # include "vmlinux_32.lds.S"
298 # include "vmlinux_64.lds.S"
307 ASSERT((_end - LOAD_OFFSET <= KERNEL_IMAGE_SIZE),
308 "kernel image bigger than KERNEL_IMAGE_SIZE")
311 * Per-cpu symbols which need to be offset from __per_cpu_load
312 * for the boot processor.
314 #define INIT_PER_CPU(x) init_per_cpu__##x = per_cpu__##x + __per_cpu_load
315 INIT_PER_CPU(gdt_page);
316 INIT_PER_CPU(irq_stack_union);
319 * Build-time check on the image size:
321 ASSERT((_end - _text <= KERNEL_IMAGE_SIZE),
322 "kernel image bigger than KERNEL_IMAGE_SIZE")
325 ASSERT((per_cpu__irq_stack_union == 0),
326 "irq_stack_union is not at start of per-cpu area");
329 #endif /* CONFIG_X86_32 */
332 #include <asm/kexec.h>
334 ASSERT(kexec_control_code_size <= KEXEC_CONTROL_CODE_MAX_SIZE,
335 "kexec control code size is too big")