blob: 845776fe52984c8bf9c042fed4890c784cf2c938 [file] [log] [blame]
Sam Ravnborg17ce2652009-04-29 09:47:18 +02001/*
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
31OUTPUT_FORMAT(CONFIG_OUTPUT_FORMAT, CONFIG_OUTPUT_FORMAT, CONFIG_OUTPUT_FORMAT)
32
33#ifdef CONFIG_X86_32
34OUTPUT_ARCH(i386)
35ENTRY(phys_startup_32)
36jiffies = jiffies_64;
37#else
38OUTPUT_ARCH(i386:x86-64)
39ENTRY(phys_startup_64)
40jiffies_64 = jiffies;
41#endif
42
Sam Ravnborgafb80952009-04-29 09:47:19 +020043PHDRS {
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}
Sam Ravnborg17ce2652009-04-29 09:47:18 +020056
Sam Ravnborg444e0ae2009-04-29 09:47:20 +020057SECTIONS
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
Thomas Gleixnera60b7782007-10-11 11:12:11 +020067#ifdef CONFIG_X86_32
68# include "vmlinux_32.lds.S"
69#else
70# include "vmlinux_64.lds.S"
Jean-Paul Saman67d38222007-02-10 01:44:44 -080071#endif
Sam Ravnborg17ce2652009-04-29 09:47:18 +020072
Sam Ravnborg444e0ae2009-04-29 09:47:20 +020073 STABS_DEBUG
74 DWARF_DEBUG
75}
76
Sam Ravnborg17ce2652009-04-29 09:47:18 +020077
78#ifdef CONFIG_X86_32
79ASSERT((_end - LOAD_OFFSET <= KERNEL_IMAGE_SIZE),
80 "kernel image bigger than KERNEL_IMAGE_SIZE")
81#else
82/*
83 * Per-cpu symbols which need to be offset from __per_cpu_load
84 * for the boot processor.
85 */
86#define INIT_PER_CPU(x) init_per_cpu__##x = per_cpu__##x + __per_cpu_load
87INIT_PER_CPU(gdt_page);
88INIT_PER_CPU(irq_stack_union);
89
90/*
91 * Build-time check on the image size:
92 */
93ASSERT((_end - _text <= KERNEL_IMAGE_SIZE),
94 "kernel image bigger than KERNEL_IMAGE_SIZE")
95
96#ifdef CONFIG_SMP
97ASSERT((per_cpu__irq_stack_union == 0),
98 "irq_stack_union is not at start of per-cpu area");
99#endif
100
101#endif /* CONFIG_X86_32 */
102
103#ifdef CONFIG_KEXEC
104#include <asm/kexec.h>
105
106ASSERT(kexec_control_code_size <= KEXEC_CONTROL_CODE_MAX_SIZE,
107 "kexec control code size is too big")
108#endif
109