blob: 4cbbe7c488391fffb7ecd765ba6c623dfde4ebf7 [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
11OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64")
12OUTPUT_ARCH(i386:x86-64)
13ENTRY(phys_startup_64)
14jiffies_64 = jiffies;
15SECTIONS
16{
Eric W. Biederman5ded01e2005-06-25 14:57:48 -070017 . = __START_KERNEL;
Linus Torvalds1da177e2005-04-16 15:20:36 -070018 phys_startup_64 = startup_64 - LOAD_OFFSET;
19 _text = .; /* Text and read-only data */
Eric W. Biederman5ded01e2005-06-25 14:57:48 -070020 .text : AT(ADDR(.text) - LOAD_OFFSET) {
Linus Torvalds1da177e2005-04-16 15:20:36 -070021 *(.text)
22 SCHED_TEXT
23 LOCK_TEXT
Prasanna S Panchamukhi0f2fbdc2005-09-06 15:19:28 -070024 KPROBES_TEXT
Linus Torvalds1da177e2005-04-16 15:20:36 -070025 *(.fixup)
26 *(.gnu.warning)
27 } = 0x9090
Eric W. Biederman5ded01e2005-06-25 14:57:48 -070028 /* out-of-line lock text */
29 .text.lock : AT(ADDR(.text.lock) - LOAD_OFFSET) { *(.text.lock) }
Linus Torvalds1da177e2005-04-16 15:20:36 -070030
31 _etext = .; /* End of text section */
32
33 . = ALIGN(16); /* Exception table */
34 __start___ex_table = .;
Eric W. Biederman5ded01e2005-06-25 14:57:48 -070035 __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) { *(__ex_table) }
Linus Torvalds1da177e2005-04-16 15:20:36 -070036 __stop___ex_table = .;
37
38 RODATA
39
Eric W. Biederman5ded01e2005-06-25 14:57:48 -070040 /* Data */
41 .data : AT(ADDR(.data) - LOAD_OFFSET) {
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 *(.data)
43 CONSTRUCTORS
44 }
45
46 _edata = .; /* End of data section */
47
48 __bss_start = .; /* BSS */
Eric W. Biederman5ded01e2005-06-25 14:57:48 -070049 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
Linus Torvalds1da177e2005-04-16 15:20:36 -070050 *(.bss.page_aligned)
51 *(.bss)
52 }
Andi Kleen2bc04142005-11-05 17:25:53 +010053 __bss_stop = .;
Linus Torvalds1da177e2005-04-16 15:20:36 -070054
Eric W. Biederman5ded01e2005-06-25 14:57:48 -070055 . = ALIGN(PAGE_SIZE);
Linus Torvalds1da177e2005-04-16 15:20:36 -070056 . = ALIGN(CONFIG_X86_L1_CACHE_BYTES);
Eric W. Biederman5ded01e2005-06-25 14:57:48 -070057 .data.cacheline_aligned : AT(ADDR(.data.cacheline_aligned) - LOAD_OFFSET) {
58 *(.data.cacheline_aligned)
59 }
Christoph Lameter6c036522005-07-07 17:56:59 -070060 . = ALIGN(CONFIG_X86_L1_CACHE_BYTES);
61 .data.read_mostly : AT(ADDR(.data.read_mostly) - LOAD_OFFSET) {
62 *(.data.read_mostly)
63 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070064
Eric W. Biederman5ded01e2005-06-25 14:57:48 -070065#define VSYSCALL_ADDR (-10*1024*1024)
Andrew Mortond312ced2005-07-12 13:58:13 -070066#define VSYSCALL_PHYS_ADDR ((LOADADDR(.data.read_mostly) + SIZEOF(.data.read_mostly) + 4095) & ~(4095))
67#define VSYSCALL_VIRT_ADDR ((ADDR(.data.read_mostly) + SIZEOF(.data.read_mostly) + 4095) & ~(4095))
Linus Torvalds1da177e2005-04-16 15:20:36 -070068
Eric W. Biederman5ded01e2005-06-25 14:57:48 -070069#define VLOAD_OFFSET (VSYSCALL_ADDR - VSYSCALL_PHYS_ADDR)
70#define VLOAD(x) (ADDR(x) - VLOAD_OFFSET)
71
72#define VVIRT_OFFSET (VSYSCALL_ADDR - VSYSCALL_VIRT_ADDR)
73#define VVIRT(x) (ADDR(x) - VVIRT_OFFSET)
74
75 . = VSYSCALL_ADDR;
76 .vsyscall_0 : AT(VSYSCALL_PHYS_ADDR) { *(.vsyscall_0) }
77 __vsyscall_0 = VSYSCALL_VIRT_ADDR;
78
Linus Torvalds1da177e2005-04-16 15:20:36 -070079 . = ALIGN(CONFIG_X86_L1_CACHE_BYTES);
Eric W. Biederman5ded01e2005-06-25 14:57:48 -070080 .xtime_lock : AT(VLOAD(.xtime_lock)) { *(.xtime_lock) }
81 xtime_lock = VVIRT(.xtime_lock);
82
83 .vxtime : AT(VLOAD(.vxtime)) { *(.vxtime) }
84 vxtime = VVIRT(.vxtime);
85
86 .wall_jiffies : AT(VLOAD(.wall_jiffies)) { *(.wall_jiffies) }
87 wall_jiffies = VVIRT(.wall_jiffies);
88
89 .sys_tz : AT(VLOAD(.sys_tz)) { *(.sys_tz) }
90 sys_tz = VVIRT(.sys_tz);
91
92 .sysctl_vsyscall : AT(VLOAD(.sysctl_vsyscall)) { *(.sysctl_vsyscall) }
93 sysctl_vsyscall = VVIRT(.sysctl_vsyscall);
94
95 .xtime : AT(VLOAD(.xtime)) { *(.xtime) }
96 xtime = VVIRT(.xtime);
97
Linus Torvalds1da177e2005-04-16 15:20:36 -070098 . = ALIGN(CONFIG_X86_L1_CACHE_BYTES);
Eric W. Biederman5ded01e2005-06-25 14:57:48 -070099 .jiffies : AT(VLOAD(.jiffies)) { *(.jiffies) }
100 jiffies = VVIRT(.jiffies);
101
102 .vsyscall_1 ADDR(.vsyscall_0) + 1024: AT(VLOAD(.vsyscall_1)) { *(.vsyscall_1) }
103 .vsyscall_2 ADDR(.vsyscall_0) + 2048: AT(VLOAD(.vsyscall_2)) { *(.vsyscall_2) }
104 .vsyscall_3 ADDR(.vsyscall_0) + 3072: AT(VLOAD(.vsyscall_3)) { *(.vsyscall_3) }
105
106 . = VSYSCALL_VIRT_ADDR + 4096;
107
108#undef VSYSCALL_ADDR
109#undef VSYSCALL_PHYS_ADDR
110#undef VSYSCALL_VIRT_ADDR
111#undef VLOAD_OFFSET
112#undef VLOAD
113#undef VVIRT_OFFSET
114#undef VVIRT
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115
116 . = ALIGN(8192); /* init_task */
Eric W. Biederman5ded01e2005-06-25 14:57:48 -0700117 .data.init_task : AT(ADDR(.data.init_task) - LOAD_OFFSET) {
118 *(.data.init_task)
119 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120
121 . = ALIGN(4096);
Eric W. Biederman5ded01e2005-06-25 14:57:48 -0700122 .data.page_aligned : AT(ADDR(.data.page_aligned) - LOAD_OFFSET) {
123 *(.data.page_aligned)
124 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125
126 . = ALIGN(4096); /* Init code and data */
127 __init_begin = .;
Eric W. Biederman5ded01e2005-06-25 14:57:48 -0700128 .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129 _sinittext = .;
130 *(.init.text)
131 _einittext = .;
132 }
133 __initdata_begin = .;
Eric W. Biederman5ded01e2005-06-25 14:57:48 -0700134 .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) { *(.init.data) }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135 __initdata_end = .;
136 . = ALIGN(16);
137 __setup_start = .;
Eric W. Biederman5ded01e2005-06-25 14:57:48 -0700138 .init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) { *(.init.setup) }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139 __setup_end = .;
140 __initcall_start = .;
Eric W. Biederman5ded01e2005-06-25 14:57:48 -0700141 .initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142 *(.initcall1.init)
143 *(.initcall2.init)
144 *(.initcall3.init)
145 *(.initcall4.init)
146 *(.initcall5.init)
147 *(.initcall6.init)
148 *(.initcall7.init)
149 }
150 __initcall_end = .;
151 __con_initcall_start = .;
Eric W. Biederman5ded01e2005-06-25 14:57:48 -0700152 .con_initcall.init : AT(ADDR(.con_initcall.init) - LOAD_OFFSET) {
153 *(.con_initcall.init)
154 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155 __con_initcall_end = .;
156 SECURITY_INIT
157 . = ALIGN(8);
158 __alt_instructions = .;
Eric W. Biederman5ded01e2005-06-25 14:57:48 -0700159 .altinstructions : AT(ADDR(.altinstructions) - LOAD_OFFSET) {
160 *(.altinstructions)
161 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162 __alt_instructions_end = .;
Eric W. Biederman5ded01e2005-06-25 14:57:48 -0700163 .altinstr_replacement : AT(ADDR(.altinstr_replacement) - LOAD_OFFSET) {
164 *(.altinstr_replacement)
165 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166 /* .exit.text is discard at runtime, not link time, to deal with references
167 from .altinstructions and .eh_frame */
Eric W. Biederman5ded01e2005-06-25 14:57:48 -0700168 .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) { *(.exit.text) }
169 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) { *(.exit.data) }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170 . = ALIGN(4096);
171 __initramfs_start = .;
Eric W. Biederman5ded01e2005-06-25 14:57:48 -0700172 .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) { *(.init.ramfs) }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173 __initramfs_end = .;
174 . = ALIGN(32);
175 __per_cpu_start = .;
Eric W. Biederman5ded01e2005-06-25 14:57:48 -0700176 .data.percpu : AT(ADDR(.data.percpu) - LOAD_OFFSET) { *(.data.percpu) }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177 __per_cpu_end = .;
178 . = ALIGN(4096);
179 __init_end = .;
180
181 . = ALIGN(4096);
182 __nosave_begin = .;
Eric W. Biederman5ded01e2005-06-25 14:57:48 -0700183 .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) { *(.data.nosave) }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184 . = ALIGN(4096);
185 __nosave_end = .;
186
187 _end = . ;
188
189 /* Sections to be discarded */
190 /DISCARD/ : {
191 *(.exitcall.exit)
Jan Beulich6e0c47e2006-01-11 22:42:05 +0100192#ifndef CONFIG_UNWIND_INFO
Linus Torvalds1da177e2005-04-16 15:20:36 -0700193 *(.eh_frame)
194#endif
195 }
196
Paolo 'Blaisorblade' Giarrusso4413a512005-09-10 19:44:55 +0200197 STABS_DEBUG
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198
Paolo 'Blaisorblade' Giarrusso4413a512005-09-10 19:44:55 +0200199 DWARF_DEBUG
Linus Torvalds1da177e2005-04-16 15:20:36 -0700200}