blob: b0eed1faf740c582c3eb4202a70d426ec98dca4b [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/* ld script to make x86-64 Linux kernel
2 * Written by Martin Mares <mj@atrey.karlin.mff.cuni.cz>;
3 */
4
Eric W. Biederman5ded01e2005-06-25 14:57:48 -07005#define LOAD_OFFSET __START_KERNEL_map
6
Linus Torvalds1da177e2005-04-16 15:20:36 -07007#include <asm-generic/vmlinux.lds.h>
Eric W. Biederman5ded01e2005-06-25 14:57:48 -07008#include <asm/page.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07009#include <linux/config.h>
10
Andi Kleenbb334212006-01-11 22:43:54 +010011#undef i386 /* in case the preprocessor is a 32bit one */
12
Linus Torvalds1da177e2005-04-16 15:20:36 -070013OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64")
14OUTPUT_ARCH(i386:x86-64)
15ENTRY(phys_startup_64)
16jiffies_64 = jiffies;
17SECTIONS
18{
Eric W. Biederman5ded01e2005-06-25 14:57:48 -070019 . = __START_KERNEL;
Linus Torvalds1da177e2005-04-16 15:20:36 -070020 phys_startup_64 = startup_64 - LOAD_OFFSET;
21 _text = .; /* Text and read-only data */
Eric W. Biederman5ded01e2005-06-25 14:57:48 -070022 .text : AT(ADDR(.text) - LOAD_OFFSET) {
Linus Torvalds1da177e2005-04-16 15:20:36 -070023 *(.text)
24 SCHED_TEXT
25 LOCK_TEXT
Prasanna S Panchamukhi0f2fbdc2005-09-06 15:19:28 -070026 KPROBES_TEXT
Linus Torvalds1da177e2005-04-16 15:20:36 -070027 *(.fixup)
28 *(.gnu.warning)
29 } = 0x9090
Eric W. Biederman5ded01e2005-06-25 14:57:48 -070030 /* out-of-line lock text */
31 .text.lock : AT(ADDR(.text.lock) - LOAD_OFFSET) { *(.text.lock) }
Linus Torvalds1da177e2005-04-16 15:20:36 -070032
33 _etext = .; /* End of text section */
34
35 . = ALIGN(16); /* Exception table */
36 __start___ex_table = .;
Eric W. Biederman5ded01e2005-06-25 14:57:48 -070037 __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) { *(__ex_table) }
Linus Torvalds1da177e2005-04-16 15:20:36 -070038 __stop___ex_table = .;
39
40 RODATA
41
Eric W. Biederman5ded01e2005-06-25 14:57:48 -070042 /* Data */
43 .data : AT(ADDR(.data) - LOAD_OFFSET) {
Linus Torvalds1da177e2005-04-16 15:20:36 -070044 *(.data)
45 CONSTRUCTORS
46 }
47
48 _edata = .; /* End of data section */
49
50 __bss_start = .; /* BSS */
Eric W. Biederman5ded01e2005-06-25 14:57:48 -070051 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
Linus Torvalds1da177e2005-04-16 15:20:36 -070052 *(.bss.page_aligned)
53 *(.bss)
54 }
Andi Kleen2bc04142005-11-05 17:25:53 +010055 __bss_stop = .;
Linus Torvalds1da177e2005-04-16 15:20:36 -070056
Eric W. Biederman5ded01e2005-06-25 14:57:48 -070057 . = ALIGN(PAGE_SIZE);
Linus Torvalds1da177e2005-04-16 15:20:36 -070058 . = ALIGN(CONFIG_X86_L1_CACHE_BYTES);
Eric W. Biederman5ded01e2005-06-25 14:57:48 -070059 .data.cacheline_aligned : AT(ADDR(.data.cacheline_aligned) - LOAD_OFFSET) {
60 *(.data.cacheline_aligned)
61 }
Christoph Lameter6c036522005-07-07 17:56:59 -070062 . = ALIGN(CONFIG_X86_L1_CACHE_BYTES);
63 .data.read_mostly : AT(ADDR(.data.read_mostly) - LOAD_OFFSET) {
64 *(.data.read_mostly)
65 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070066
Eric W. Biederman5ded01e2005-06-25 14:57:48 -070067#define VSYSCALL_ADDR (-10*1024*1024)
Andrew Mortond312ced2005-07-12 13:58:13 -070068#define VSYSCALL_PHYS_ADDR ((LOADADDR(.data.read_mostly) + SIZEOF(.data.read_mostly) + 4095) & ~(4095))
69#define VSYSCALL_VIRT_ADDR ((ADDR(.data.read_mostly) + SIZEOF(.data.read_mostly) + 4095) & ~(4095))
Linus Torvalds1da177e2005-04-16 15:20:36 -070070
Eric W. Biederman5ded01e2005-06-25 14:57:48 -070071#define VLOAD_OFFSET (VSYSCALL_ADDR - VSYSCALL_PHYS_ADDR)
72#define VLOAD(x) (ADDR(x) - VLOAD_OFFSET)
73
74#define VVIRT_OFFSET (VSYSCALL_ADDR - VSYSCALL_VIRT_ADDR)
75#define VVIRT(x) (ADDR(x) - VVIRT_OFFSET)
76
77 . = VSYSCALL_ADDR;
78 .vsyscall_0 : AT(VSYSCALL_PHYS_ADDR) { *(.vsyscall_0) }
79 __vsyscall_0 = VSYSCALL_VIRT_ADDR;
80
Linus Torvalds1da177e2005-04-16 15:20:36 -070081 . = ALIGN(CONFIG_X86_L1_CACHE_BYTES);
Eric W. Biederman5ded01e2005-06-25 14:57:48 -070082 .xtime_lock : AT(VLOAD(.xtime_lock)) { *(.xtime_lock) }
83 xtime_lock = VVIRT(.xtime_lock);
84
85 .vxtime : AT(VLOAD(.vxtime)) { *(.vxtime) }
86 vxtime = VVIRT(.vxtime);
87
88 .wall_jiffies : AT(VLOAD(.wall_jiffies)) { *(.wall_jiffies) }
89 wall_jiffies = VVIRT(.wall_jiffies);
90
91 .sys_tz : AT(VLOAD(.sys_tz)) { *(.sys_tz) }
92 sys_tz = VVIRT(.sys_tz);
93
94 .sysctl_vsyscall : AT(VLOAD(.sysctl_vsyscall)) { *(.sysctl_vsyscall) }
95 sysctl_vsyscall = VVIRT(.sysctl_vsyscall);
96
97 .xtime : AT(VLOAD(.xtime)) { *(.xtime) }
98 xtime = VVIRT(.xtime);
99
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100 . = ALIGN(CONFIG_X86_L1_CACHE_BYTES);
Eric W. Biederman5ded01e2005-06-25 14:57:48 -0700101 .jiffies : AT(VLOAD(.jiffies)) { *(.jiffies) }
102 jiffies = VVIRT(.jiffies);
103
104 .vsyscall_1 ADDR(.vsyscall_0) + 1024: AT(VLOAD(.vsyscall_1)) { *(.vsyscall_1) }
105 .vsyscall_2 ADDR(.vsyscall_0) + 2048: AT(VLOAD(.vsyscall_2)) { *(.vsyscall_2) }
106 .vsyscall_3 ADDR(.vsyscall_0) + 3072: AT(VLOAD(.vsyscall_3)) { *(.vsyscall_3) }
107
108 . = VSYSCALL_VIRT_ADDR + 4096;
109
110#undef VSYSCALL_ADDR
111#undef VSYSCALL_PHYS_ADDR
112#undef VSYSCALL_VIRT_ADDR
113#undef VLOAD_OFFSET
114#undef VLOAD
115#undef VVIRT_OFFSET
116#undef VVIRT
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117
118 . = ALIGN(8192); /* init_task */
Eric W. Biederman5ded01e2005-06-25 14:57:48 -0700119 .data.init_task : AT(ADDR(.data.init_task) - LOAD_OFFSET) {
120 *(.data.init_task)
121 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122
123 . = ALIGN(4096);
Eric W. Biederman5ded01e2005-06-25 14:57:48 -0700124 .data.page_aligned : AT(ADDR(.data.page_aligned) - LOAD_OFFSET) {
125 *(.data.page_aligned)
126 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127
128 . = ALIGN(4096); /* Init code and data */
129 __init_begin = .;
Eric W. Biederman5ded01e2005-06-25 14:57:48 -0700130 .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131 _sinittext = .;
132 *(.init.text)
133 _einittext = .;
134 }
135 __initdata_begin = .;
Eric W. Biederman5ded01e2005-06-25 14:57:48 -0700136 .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) { *(.init.data) }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137 __initdata_end = .;
138 . = ALIGN(16);
139 __setup_start = .;
Eric W. Biederman5ded01e2005-06-25 14:57:48 -0700140 .init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) { *(.init.setup) }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141 __setup_end = .;
142 __initcall_start = .;
Eric W. Biederman5ded01e2005-06-25 14:57:48 -0700143 .initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144 *(.initcall1.init)
145 *(.initcall2.init)
146 *(.initcall3.init)
147 *(.initcall4.init)
148 *(.initcall5.init)
149 *(.initcall6.init)
150 *(.initcall7.init)
151 }
152 __initcall_end = .;
153 __con_initcall_start = .;
Eric W. Biederman5ded01e2005-06-25 14:57:48 -0700154 .con_initcall.init : AT(ADDR(.con_initcall.init) - LOAD_OFFSET) {
155 *(.con_initcall.init)
156 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157 __con_initcall_end = .;
158 SECURITY_INIT
159 . = ALIGN(8);
160 __alt_instructions = .;
Eric W. Biederman5ded01e2005-06-25 14:57:48 -0700161 .altinstructions : AT(ADDR(.altinstructions) - LOAD_OFFSET) {
162 *(.altinstructions)
163 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164 __alt_instructions_end = .;
Eric W. Biederman5ded01e2005-06-25 14:57:48 -0700165 .altinstr_replacement : AT(ADDR(.altinstr_replacement) - LOAD_OFFSET) {
166 *(.altinstr_replacement)
167 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168 /* .exit.text is discard at runtime, not link time, to deal with references
169 from .altinstructions and .eh_frame */
Eric W. Biederman5ded01e2005-06-25 14:57:48 -0700170 .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) { *(.exit.text) }
171 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) { *(.exit.data) }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172 . = ALIGN(4096);
173 __initramfs_start = .;
Eric W. Biederman5ded01e2005-06-25 14:57:48 -0700174 .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) { *(.init.ramfs) }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700175 __initramfs_end = .;
176 . = ALIGN(32);
177 __per_cpu_start = .;
Eric W. Biederman5ded01e2005-06-25 14:57:48 -0700178 .data.percpu : AT(ADDR(.data.percpu) - LOAD_OFFSET) { *(.data.percpu) }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179 __per_cpu_end = .;
180 . = ALIGN(4096);
181 __init_end = .;
182
183 . = ALIGN(4096);
184 __nosave_begin = .;
Eric W. Biederman5ded01e2005-06-25 14:57:48 -0700185 .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) { *(.data.nosave) }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700186 . = ALIGN(4096);
187 __nosave_end = .;
188
189 _end = . ;
190
191 /* Sections to be discarded */
192 /DISCARD/ : {
193 *(.exitcall.exit)
Jan Beulich6e0c47e2006-01-11 22:42:05 +0100194#ifndef CONFIG_UNWIND_INFO
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195 *(.eh_frame)
196#endif
197 }
198
Paolo 'Blaisorblade' Giarrusso4413a512005-09-10 19:44:55 +0200199 STABS_DEBUG
Linus Torvalds1da177e2005-04-16 15:20:36 -0700200
Paolo 'Blaisorblade' Giarrusso4413a512005-09-10 19:44:55 +0200201 DWARF_DEBUG
Linus Torvalds1da177e2005-04-16 15:20:36 -0700202}