blob: 46e05447405b43855f46602f493847b75efa252a [file] [log] [blame]
Thomas Gleixner13a9cd42007-10-11 11:14:21 +02001/* ld script to make x86-64 Linux kernel
2 * Written by Martin Mares <mj@atrey.karlin.mff.cuni.cz>;
3 */
4
5#define LOAD_OFFSET __START_KERNEL_map
6
7#include <asm-generic/vmlinux.lds.h>
8#include <asm/page.h>
9
10#undef i386 /* in case the preprocessor is a 32bit one */
11
12OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64")
13OUTPUT_ARCH(i386:x86-64)
14ENTRY(phys_startup_64)
15jiffies_64 = jiffies;
16_proxy_pda = 1;
17PHDRS {
18 text PT_LOAD FLAGS(5); /* R_E */
19 data PT_LOAD FLAGS(7); /* RWE */
20 user PT_LOAD FLAGS(7); /* RWE */
21 data.init PT_LOAD FLAGS(7); /* RWE */
Jan Beulich6360b1f2008-05-12 15:44:41 +020022 note PT_NOTE FLAGS(0); /* ___ */
Thomas Gleixner13a9cd42007-10-11 11:14:21 +020023}
24SECTIONS
25{
26 . = __START_KERNEL;
27 phys_startup_64 = startup_64 - LOAD_OFFSET;
28 _text = .; /* Text and read-only data */
29 .text : AT(ADDR(.text) - LOAD_OFFSET) {
30 /* First the code that has to be first for bootstrapping */
31 *(.text.head)
32 _stext = .;
33 /* Then the rest */
34 TEXT_TEXT
35 SCHED_TEXT
36 LOCK_TEXT
37 KPROBES_TEXT
38 *(.fixup)
39 *(.gnu.warning)
Cyrill Gorcunov3cdac412008-02-17 18:17:17 +030040 _etext = .; /* End of text section */
Jan Beulichc0400032008-01-30 13:33:14 +010041 } :text = 0x9090
Thomas Gleixner13a9cd42007-10-11 11:14:21 +020042
Jan Beulich6360b1f2008-05-12 15:44:41 +020043 NOTES :text :note
44
Thomas Gleixner13a9cd42007-10-11 11:14:21 +020045 . = ALIGN(16); /* Exception table */
Jan Beulichc0400032008-01-30 13:33:14 +010046 __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {
47 __start___ex_table = .;
48 *(__ex_table)
49 __stop___ex_table = .;
Jan Beulich6360b1f2008-05-12 15:44:41 +020050 } :text = 0x9090
Thomas Gleixner13a9cd42007-10-11 11:14:21 +020051
52 RODATA
53
Cyrill Gorcunov3cdac412008-02-17 18:17:17 +030054 . = ALIGN(PAGE_SIZE); /* Align data segment to page size boundary */
Thomas Gleixner13a9cd42007-10-11 11:14:21 +020055 /* Data */
56 .data : AT(ADDR(.data) - LOAD_OFFSET) {
57 DATA_DATA
58 CONSTRUCTORS
59 } :data
60
61 _edata = .; /* End of data section */
62
63 . = ALIGN(PAGE_SIZE);
64 . = ALIGN(CONFIG_X86_L1_CACHE_BYTES);
65 .data.cacheline_aligned : AT(ADDR(.data.cacheline_aligned) - LOAD_OFFSET) {
66 *(.data.cacheline_aligned)
67 }
68 . = ALIGN(CONFIG_X86_INTERNODE_CACHE_BYTES);
69 .data.read_mostly : AT(ADDR(.data.read_mostly) - LOAD_OFFSET) {
70 *(.data.read_mostly)
71 }
72
73#define VSYSCALL_ADDR (-10*1024*1024)
74#define VSYSCALL_PHYS_ADDR ((LOADADDR(.data.read_mostly) + SIZEOF(.data.read_mostly) + 4095) & ~(4095))
75#define VSYSCALL_VIRT_ADDR ((ADDR(.data.read_mostly) + SIZEOF(.data.read_mostly) + 4095) & ~(4095))
76
77#define VLOAD_OFFSET (VSYSCALL_ADDR - VSYSCALL_PHYS_ADDR)
78#define VLOAD(x) (ADDR(x) - VLOAD_OFFSET)
79
80#define VVIRT_OFFSET (VSYSCALL_ADDR - VSYSCALL_VIRT_ADDR)
81#define VVIRT(x) (ADDR(x) - VVIRT_OFFSET)
82
83 . = VSYSCALL_ADDR;
84 .vsyscall_0 : AT(VSYSCALL_PHYS_ADDR) { *(.vsyscall_0) } :user
85 __vsyscall_0 = VSYSCALL_VIRT_ADDR;
86
87 . = ALIGN(CONFIG_X86_L1_CACHE_BYTES);
88 .vsyscall_fn : AT(VLOAD(.vsyscall_fn)) { *(.vsyscall_fn) }
89 . = ALIGN(CONFIG_X86_L1_CACHE_BYTES);
90 .vsyscall_gtod_data : AT(VLOAD(.vsyscall_gtod_data))
91 { *(.vsyscall_gtod_data) }
92 vsyscall_gtod_data = VVIRT(.vsyscall_gtod_data);
93 .vsyscall_clock : AT(VLOAD(.vsyscall_clock))
94 { *(.vsyscall_clock) }
95 vsyscall_clock = VVIRT(.vsyscall_clock);
96
97
98 .vsyscall_1 ADDR(.vsyscall_0) + 1024: AT(VLOAD(.vsyscall_1))
99 { *(.vsyscall_1) }
100 .vsyscall_2 ADDR(.vsyscall_0) + 2048: AT(VLOAD(.vsyscall_2))
101 { *(.vsyscall_2) }
102
103 .vgetcpu_mode : AT(VLOAD(.vgetcpu_mode)) { *(.vgetcpu_mode) }
104 vgetcpu_mode = VVIRT(.vgetcpu_mode);
105
106 . = ALIGN(CONFIG_X86_L1_CACHE_BYTES);
107 .jiffies : AT(VLOAD(.jiffies)) { *(.jiffies) }
108 jiffies = VVIRT(.jiffies);
109
110 .vsyscall_3 ADDR(.vsyscall_0) + 3072: AT(VLOAD(.vsyscall_3))
111 { *(.vsyscall_3) }
112
Cyrill Gorcunov3cdac412008-02-17 18:17:17 +0300113 . = VSYSCALL_VIRT_ADDR + PAGE_SIZE;
Thomas Gleixner13a9cd42007-10-11 11:14:21 +0200114
115#undef VSYSCALL_ADDR
116#undef VSYSCALL_PHYS_ADDR
117#undef VSYSCALL_VIRT_ADDR
118#undef VLOAD_OFFSET
119#undef VLOAD
120#undef VVIRT_OFFSET
121#undef VVIRT
122
Cyrill Gorcunov85c42d02008-02-17 18:17:18 +0300123 . = ALIGN(THREAD_SIZE); /* init_task */
Thomas Gleixner13a9cd42007-10-11 11:14:21 +0200124 .data.init_task : AT(ADDR(.data.init_task) - LOAD_OFFSET) {
125 *(.data.init_task)
126 }:data.init
127
Cyrill Gorcunov3cdac412008-02-17 18:17:17 +0300128 . = ALIGN(PAGE_SIZE);
Thomas Gleixner13a9cd42007-10-11 11:14:21 +0200129 .data.page_aligned : AT(ADDR(.data.page_aligned) - LOAD_OFFSET) {
130 *(.data.page_aligned)
131 }
132
133 /* might get freed after init */
Cyrill Gorcunov3cdac412008-02-17 18:17:17 +0300134 . = ALIGN(PAGE_SIZE);
Thomas Gleixner13a9cd42007-10-11 11:14:21 +0200135 __smp_alt_begin = .;
136 __smp_locks = .;
137 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
138 *(.smp_locks)
139 }
140 __smp_locks_end = .;
Cyrill Gorcunov3cdac412008-02-17 18:17:17 +0300141 . = ALIGN(PAGE_SIZE);
Thomas Gleixner13a9cd42007-10-11 11:14:21 +0200142 __smp_alt_end = .;
143
Cyrill Gorcunov3cdac412008-02-17 18:17:17 +0300144 . = ALIGN(PAGE_SIZE); /* Init code and data */
Thomas Gleixner13a9cd42007-10-11 11:14:21 +0200145 __init_begin = .;
146 .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) {
147 _sinittext = .;
Sam Ravnborg01ba2bd2008-01-20 14:15:03 +0100148 INIT_TEXT
Thomas Gleixner13a9cd42007-10-11 11:14:21 +0200149 _einittext = .;
150 }
Sam Ravnborg01ba2bd2008-01-20 14:15:03 +0100151 .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) {
152 __initdata_begin = .;
153 INIT_DATA
154 __initdata_end = .;
155 }
156
Thomas Gleixner13a9cd42007-10-11 11:14:21 +0200157 . = ALIGN(16);
158 __setup_start = .;
159 .init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) { *(.init.setup) }
160 __setup_end = .;
161 __initcall_start = .;
162 .initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET) {
163 INITCALLS
164 }
165 __initcall_end = .;
166 __con_initcall_start = .;
167 .con_initcall.init : AT(ADDR(.con_initcall.init) - LOAD_OFFSET) {
168 *(.con_initcall.init)
169 }
170 __con_initcall_end = .;
Yinghai Lu10a434f2008-09-04 21:09:45 +0200171 __x86_cpu_dev_start = .;
172 .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
173 *(.x86_cpu_dev.init)
Thomas Petazzoni03ae5762008-02-15 12:00:23 +0100174 }
Yinghai Lu10a434f2008-09-04 21:09:45 +0200175 __x86_cpu_dev_end = .;
Petr Vandroveccb58ffc2008-10-12 10:51:03 +0200176 SECURITY_INIT
Glauber de Oliveira Costafbf51922008-01-30 13:33:19 +0100177
178 . = ALIGN(8);
179 .parainstructions : AT(ADDR(.parainstructions) - LOAD_OFFSET) {
180 __parainstructions = .;
181 *(.parainstructions)
182 __parainstructions_end = .;
183 }
184
Thomas Gleixner13a9cd42007-10-11 11:14:21 +0200185 . = ALIGN(8);
186 __alt_instructions = .;
187 .altinstructions : AT(ADDR(.altinstructions) - LOAD_OFFSET) {
188 *(.altinstructions)
189 }
Cyrill Gorcunov3cdac412008-02-17 18:17:17 +0300190 __alt_instructions_end = .;
Thomas Gleixner13a9cd42007-10-11 11:14:21 +0200191 .altinstr_replacement : AT(ADDR(.altinstr_replacement) - LOAD_OFFSET) {
192 *(.altinstr_replacement)
193 }
194 /* .exit.text is discard at runtime, not link time, to deal with references
195 from .altinstructions and .eh_frame */
Sam Ravnborg01ba2bd2008-01-20 14:15:03 +0100196 .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
197 EXIT_TEXT
198 }
199 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
200 EXIT_DATA
201 }
Thomas Gleixner13a9cd42007-10-11 11:14:21 +0200202
Thomas Gleixner13a9cd42007-10-11 11:14:21 +0200203#ifdef CONFIG_BLK_DEV_INITRD
Cyrill Gorcunov3cdac412008-02-17 18:17:17 +0300204 . = ALIGN(PAGE_SIZE);
Thomas Gleixner13a9cd42007-10-11 11:14:21 +0200205 __initramfs_start = .;
206 .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) { *(.init.ramfs) }
207 __initramfs_end = .;
208#endif
209
Cyrill Gorcunov3cdac412008-02-17 18:17:17 +0300210 PERCPU(PAGE_SIZE)
Thomas Gleixner13a9cd42007-10-11 11:14:21 +0200211
Cyrill Gorcunov3cdac412008-02-17 18:17:17 +0300212 . = ALIGN(PAGE_SIZE);
Thomas Gleixner13a9cd42007-10-11 11:14:21 +0200213 __init_end = .;
214
Cyrill Gorcunov3cdac412008-02-17 18:17:17 +0300215 . = ALIGN(PAGE_SIZE);
Thomas Gleixner13a9cd42007-10-11 11:14:21 +0200216 __nosave_begin = .;
217 .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) { *(.data.nosave) }
Cyrill Gorcunov3cdac412008-02-17 18:17:17 +0300218 . = ALIGN(PAGE_SIZE);
Thomas Gleixner13a9cd42007-10-11 11:14:21 +0200219 __nosave_end = .;
220
221 __bss_start = .; /* BSS */
222 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
223 *(.bss.page_aligned)
224 *(.bss)
225 }
226 __bss_stop = .;
227
228 _end = . ;
229
230 /* Sections to be discarded */
231 /DISCARD/ : {
232 *(.exitcall.exit)
233 *(.eh_frame)
234 }
235
236 STABS_DEBUG
237
238 DWARF_DEBUG
239}
Ingo Molnarb4e04092008-02-21 13:45:16 +0100240
241/*
242 * Build-time check on the image size:
243 */
244ASSERT((_end - _text <= KERNEL_IMAGE_SIZE),
245 "kernel image bigger than KERNEL_IMAGE_SIZE")