1 /* ld script to make x86-64 Linux kernel
2 * Written by Martin Mares <mj@atrey.karlin.mff.cuni.cz>;
5 #define LOAD_OFFSET __START_KERNEL_map
7 #include <asm-generic/vmlinux.lds.h>
9 #include <linux/config.h>
11 #undef i386 /* in case the preprocessor is a 32bit one */
13 OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64")
14 OUTPUT_ARCH(i386:x86-64)
15 ENTRY(phys_startup_64)
20 phys_startup_64 = startup_64 - LOAD_OFFSET;
21 _text = .; /* Text and read-only data */
22 .text : AT(ADDR(.text) - LOAD_OFFSET) {
30 /* out-of-line lock text */
31 .text.lock : AT(ADDR(.text.lock) - LOAD_OFFSET) { *(.text.lock) }
33 _etext = .; /* End of text section */
35 . = ALIGN(16); /* Exception table */
36 __start___ex_table = .;
37 __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) { *(__ex_table) }
38 __stop___ex_table = .;
43 .data : AT(ADDR(.data) - LOAD_OFFSET) {
48 _edata = .; /* End of data section */
50 __bss_start = .; /* BSS */
51 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
58 . = ALIGN(CONFIG_X86_L1_CACHE_BYTES);
59 .data.cacheline_aligned : AT(ADDR(.data.cacheline_aligned) - LOAD_OFFSET) {
60 *(.data.cacheline_aligned)
62 . = ALIGN(CONFIG_X86_L1_CACHE_BYTES);
63 .data.read_mostly : AT(ADDR(.data.read_mostly) - LOAD_OFFSET) {
67 #define VSYSCALL_ADDR (-10*1024*1024)
68 #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))
71 #define VLOAD_OFFSET (VSYSCALL_ADDR - VSYSCALL_PHYS_ADDR)
72 #define VLOAD(x) (ADDR(x) - VLOAD_OFFSET)
74 #define VVIRT_OFFSET (VSYSCALL_ADDR - VSYSCALL_VIRT_ADDR)
75 #define VVIRT(x) (ADDR(x) - VVIRT_OFFSET)
78 .vsyscall_0 : AT(VSYSCALL_PHYS_ADDR) { *(.vsyscall_0) }
79 __vsyscall_0 = VSYSCALL_VIRT_ADDR;
81 . = ALIGN(CONFIG_X86_L1_CACHE_BYTES);
82 .xtime_lock : AT(VLOAD(.xtime_lock)) { *(.xtime_lock) }
83 xtime_lock = VVIRT(.xtime_lock);
85 .vxtime : AT(VLOAD(.vxtime)) { *(.vxtime) }
86 vxtime = VVIRT(.vxtime);
88 .wall_jiffies : AT(VLOAD(.wall_jiffies)) { *(.wall_jiffies) }
89 wall_jiffies = VVIRT(.wall_jiffies);
91 .sys_tz : AT(VLOAD(.sys_tz)) { *(.sys_tz) }
92 sys_tz = VVIRT(.sys_tz);
94 .sysctl_vsyscall : AT(VLOAD(.sysctl_vsyscall)) { *(.sysctl_vsyscall) }
95 sysctl_vsyscall = VVIRT(.sysctl_vsyscall);
97 .xtime : AT(VLOAD(.xtime)) { *(.xtime) }
98 xtime = VVIRT(.xtime);
100 . = ALIGN(CONFIG_X86_L1_CACHE_BYTES);
101 .jiffies : AT(VLOAD(.jiffies)) { *(.jiffies) }
102 jiffies = VVIRT(.jiffies);
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) }
108 . = VSYSCALL_VIRT_ADDR + 4096;
111 #undef VSYSCALL_PHYS_ADDR
112 #undef VSYSCALL_VIRT_ADDR
118 . = ALIGN(8192); /* init_task */
119 .data.init_task : AT(ADDR(.data.init_task) - LOAD_OFFSET) {
124 .data.page_aligned : AT(ADDR(.data.page_aligned) - LOAD_OFFSET) {
125 *(.data.page_aligned)
128 . = ALIGN(4096); /* Init code and data */
130 .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) {
135 __initdata_begin = .;
136 .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) { *(.init.data) }
140 .init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) { *(.init.setup) }
142 __initcall_start = .;
143 .initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET) {
153 __con_initcall_start = .;
154 .con_initcall.init : AT(ADDR(.con_initcall.init) - LOAD_OFFSET) {
155 *(.con_initcall.init)
157 __con_initcall_end = .;
160 __alt_instructions = .;
161 .altinstructions : AT(ADDR(.altinstructions) - LOAD_OFFSET) {
164 __alt_instructions_end = .;
165 .altinstr_replacement : AT(ADDR(.altinstr_replacement) - LOAD_OFFSET) {
166 *(.altinstr_replacement)
168 /* .exit.text is discard at runtime, not link time, to deal with references
169 from .altinstructions and .eh_frame */
170 .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) { *(.exit.text) }
171 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) { *(.exit.data) }
173 __initramfs_start = .;
174 .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) { *(.init.ramfs) }
178 .data.percpu : AT(ADDR(.data.percpu) - LOAD_OFFSET) { *(.data.percpu) }
185 .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) { *(.data.nosave) }
191 /* Sections to be discarded */
194 #ifndef CONFIG_UNWIND_INFO