blob: 73389f51c4e5b2d841619e22e3e27af9ddbbdf24 [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
24 *(.fixup)
25 *(.gnu.warning)
26 } = 0x9090
Eric W. Biederman5ded01e2005-06-25 14:57:48 -070027 /* out-of-line lock text */
28 .text.lock : AT(ADDR(.text.lock) - LOAD_OFFSET) { *(.text.lock) }
Linus Torvalds1da177e2005-04-16 15:20:36 -070029
30 _etext = .; /* End of text section */
31
32 . = ALIGN(16); /* Exception table */
33 __start___ex_table = .;
Eric W. Biederman5ded01e2005-06-25 14:57:48 -070034 __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) { *(__ex_table) }
Linus Torvalds1da177e2005-04-16 15:20:36 -070035 __stop___ex_table = .;
36
37 RODATA
38
Eric W. Biederman5ded01e2005-06-25 14:57:48 -070039 /* Data */
40 .data : AT(ADDR(.data) - LOAD_OFFSET) {
Linus Torvalds1da177e2005-04-16 15:20:36 -070041 *(.data)
42 CONSTRUCTORS
43 }
44
45 _edata = .; /* End of data section */
46
47 __bss_start = .; /* BSS */
Eric W. Biederman5ded01e2005-06-25 14:57:48 -070048 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
Linus Torvalds1da177e2005-04-16 15:20:36 -070049 *(.bss.page_aligned)
50 *(.bss)
51 }
52 __bss_end = .;
53
Eric W. Biederman5ded01e2005-06-25 14:57:48 -070054 . = ALIGN(PAGE_SIZE);
Linus Torvalds1da177e2005-04-16 15:20:36 -070055 . = ALIGN(CONFIG_X86_L1_CACHE_BYTES);
Eric W. Biederman5ded01e2005-06-25 14:57:48 -070056 .data.cacheline_aligned : AT(ADDR(.data.cacheline_aligned) - LOAD_OFFSET) {
57 *(.data.cacheline_aligned)
58 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070059
Eric W. Biederman5ded01e2005-06-25 14:57:48 -070060#define VSYSCALL_ADDR (-10*1024*1024)
61#define VSYSCALL_PHYS_ADDR ((LOADADDR(.data.cacheline_aligned) + SIZEOF(.data.cacheline_aligned) + 4095) & ~(4095))
62#define VSYSCALL_VIRT_ADDR ((ADDR(.data.cacheline_aligned) + SIZEOF(.data.cacheline_aligned) + 4095) & ~(4095))
Linus Torvalds1da177e2005-04-16 15:20:36 -070063
Eric W. Biederman5ded01e2005-06-25 14:57:48 -070064#define VLOAD_OFFSET (VSYSCALL_ADDR - VSYSCALL_PHYS_ADDR)
65#define VLOAD(x) (ADDR(x) - VLOAD_OFFSET)
66
67#define VVIRT_OFFSET (VSYSCALL_ADDR - VSYSCALL_VIRT_ADDR)
68#define VVIRT(x) (ADDR(x) - VVIRT_OFFSET)
69
70 . = VSYSCALL_ADDR;
71 .vsyscall_0 : AT(VSYSCALL_PHYS_ADDR) { *(.vsyscall_0) }
72 __vsyscall_0 = VSYSCALL_VIRT_ADDR;
73
Linus Torvalds1da177e2005-04-16 15:20:36 -070074 . = ALIGN(CONFIG_X86_L1_CACHE_BYTES);
Eric W. Biederman5ded01e2005-06-25 14:57:48 -070075 .xtime_lock : AT(VLOAD(.xtime_lock)) { *(.xtime_lock) }
76 xtime_lock = VVIRT(.xtime_lock);
77
78 .vxtime : AT(VLOAD(.vxtime)) { *(.vxtime) }
79 vxtime = VVIRT(.vxtime);
80
81 .wall_jiffies : AT(VLOAD(.wall_jiffies)) { *(.wall_jiffies) }
82 wall_jiffies = VVIRT(.wall_jiffies);
83
84 .sys_tz : AT(VLOAD(.sys_tz)) { *(.sys_tz) }
85 sys_tz = VVIRT(.sys_tz);
86
87 .sysctl_vsyscall : AT(VLOAD(.sysctl_vsyscall)) { *(.sysctl_vsyscall) }
88 sysctl_vsyscall = VVIRT(.sysctl_vsyscall);
89
90 .xtime : AT(VLOAD(.xtime)) { *(.xtime) }
91 xtime = VVIRT(.xtime);
92
Linus Torvalds1da177e2005-04-16 15:20:36 -070093 . = ALIGN(CONFIG_X86_L1_CACHE_BYTES);
Eric W. Biederman5ded01e2005-06-25 14:57:48 -070094 .jiffies : AT(VLOAD(.jiffies)) { *(.jiffies) }
95 jiffies = VVIRT(.jiffies);
96
97 .vsyscall_1 ADDR(.vsyscall_0) + 1024: AT(VLOAD(.vsyscall_1)) { *(.vsyscall_1) }
98 .vsyscall_2 ADDR(.vsyscall_0) + 2048: AT(VLOAD(.vsyscall_2)) { *(.vsyscall_2) }
99 .vsyscall_3 ADDR(.vsyscall_0) + 3072: AT(VLOAD(.vsyscall_3)) { *(.vsyscall_3) }
100
101 . = VSYSCALL_VIRT_ADDR + 4096;
102
103#undef VSYSCALL_ADDR
104#undef VSYSCALL_PHYS_ADDR
105#undef VSYSCALL_VIRT_ADDR
106#undef VLOAD_OFFSET
107#undef VLOAD
108#undef VVIRT_OFFSET
109#undef VVIRT
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110
111 . = ALIGN(8192); /* init_task */
Eric W. Biederman5ded01e2005-06-25 14:57:48 -0700112 .data.init_task : AT(ADDR(.data.init_task) - LOAD_OFFSET) {
113 *(.data.init_task)
114 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115
116 . = ALIGN(4096);
Eric W. Biederman5ded01e2005-06-25 14:57:48 -0700117 .data.page_aligned : AT(ADDR(.data.page_aligned) - LOAD_OFFSET) {
118 *(.data.page_aligned)
119 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120
121 . = ALIGN(4096); /* Init code and data */
122 __init_begin = .;
Eric W. Biederman5ded01e2005-06-25 14:57:48 -0700123 .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124 _sinittext = .;
125 *(.init.text)
126 _einittext = .;
127 }
128 __initdata_begin = .;
Eric W. Biederman5ded01e2005-06-25 14:57:48 -0700129 .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) { *(.init.data) }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130 __initdata_end = .;
131 . = ALIGN(16);
132 __setup_start = .;
Eric W. Biederman5ded01e2005-06-25 14:57:48 -0700133 .init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) { *(.init.setup) }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134 __setup_end = .;
135 __initcall_start = .;
Eric W. Biederman5ded01e2005-06-25 14:57:48 -0700136 .initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137 *(.initcall1.init)
138 *(.initcall2.init)
139 *(.initcall3.init)
140 *(.initcall4.init)
141 *(.initcall5.init)
142 *(.initcall6.init)
143 *(.initcall7.init)
144 }
145 __initcall_end = .;
146 __con_initcall_start = .;
Eric W. Biederman5ded01e2005-06-25 14:57:48 -0700147 .con_initcall.init : AT(ADDR(.con_initcall.init) - LOAD_OFFSET) {
148 *(.con_initcall.init)
149 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150 __con_initcall_end = .;
151 SECURITY_INIT
152 . = ALIGN(8);
153 __alt_instructions = .;
Eric W. Biederman5ded01e2005-06-25 14:57:48 -0700154 .altinstructions : AT(ADDR(.altinstructions) - LOAD_OFFSET) {
155 *(.altinstructions)
156 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157 __alt_instructions_end = .;
Eric W. Biederman5ded01e2005-06-25 14:57:48 -0700158 .altinstr_replacement : AT(ADDR(.altinstr_replacement) - LOAD_OFFSET) {
159 *(.altinstr_replacement)
160 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161 /* .exit.text is discard at runtime, not link time, to deal with references
162 from .altinstructions and .eh_frame */
Eric W. Biederman5ded01e2005-06-25 14:57:48 -0700163 .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) { *(.exit.text) }
164 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) { *(.exit.data) }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165 . = ALIGN(4096);
166 __initramfs_start = .;
Eric W. Biederman5ded01e2005-06-25 14:57:48 -0700167 .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) { *(.init.ramfs) }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168 __initramfs_end = .;
169 . = ALIGN(32);
170 __per_cpu_start = .;
Eric W. Biederman5ded01e2005-06-25 14:57:48 -0700171 .data.percpu : AT(ADDR(.data.percpu) - LOAD_OFFSET) { *(.data.percpu) }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172 __per_cpu_end = .;
173 . = ALIGN(4096);
174 __init_end = .;
175
176 . = ALIGN(4096);
177 __nosave_begin = .;
Eric W. Biederman5ded01e2005-06-25 14:57:48 -0700178 .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) { *(.data.nosave) }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179 . = ALIGN(4096);
180 __nosave_end = .;
181
182 _end = . ;
183
184 /* Sections to be discarded */
185 /DISCARD/ : {
186 *(.exitcall.exit)
187#ifndef CONFIG_DEBUG_INFO
188 *(.eh_frame)
189#endif
190 }
191
192 /* DWARF 2 */
193 .debug_info 0 : { *(.debug_info) }
194 .debug_abbrev 0 : { *(.debug_abbrev) }
195 .debug_line 0 : { *(.debug_line) }
196 .debug_frame 0 : { *(.debug_frame) }
197 .debug_str 0 : { *(.debug_str) }
198 .debug_loc 0 : { *(.debug_loc) }
199 .debug_macinfo 0 : { *(.debug_macinfo) }
200 /* SGI/MIPS DWARF 2 extensions */
201 .debug_weaknames 0 : { *(.debug_weaknames) }
202 .debug_funcnames 0 : { *(.debug_funcnames) }
203 .debug_typenames 0 : { *(.debug_typenames) }
204 .debug_varnames 0 : { *(.debug_varnames) }
205
206
207 .comment 0 : { *(.comment) }
208}