blob: 25581e87c60d19dd89bddc0faeefb52918c341c5 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/* ld script to make i386 Linux kernel
2 * Written by Martin Mares <mj@atrey.karlin.mff.cuni.cz>;
Vivek Goyal65695802006-12-07 02:14:03 +01003 *
4 * Don't define absolute symbols until and unless you know that symbol
5 * value is should remain constant even if kernel image is relocated
6 * at run time. Absolute symbols are not relocated. If symbol value should
7 * change if kernel is relocated, make the symbol section relative and
8 * put it inside the section definition.
Linus Torvalds1da177e2005-04-16 15:20:36 -07009 */
10
Vivek Goyal79929fd2006-12-07 02:14:10 +010011/* Don't define absolute symbols until and unless you know that symbol
12 * value is should remain constant even if kernel image is relocated
13 * at run time. Absolute symbols are not relocated. If symbol value should
14 * change if kernel is relocated, make the symbol section relative and
15 * put it inside the section definition.
16 */
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -070017#define LOAD_OFFSET __PAGE_OFFSET
18
Linus Torvalds1da177e2005-04-16 15:20:36 -070019#include <asm-generic/vmlinux.lds.h>
20#include <asm/thread_info.h>
21#include <asm/page.h>
Zach Brown379b5442006-01-27 14:02:47 -080022#include <asm/cache.h>
Vivek Goyale69f2022006-12-07 02:14:04 +010023#include <asm/boot.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070024
25OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
26OUTPUT_ARCH(i386)
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -070027ENTRY(phys_startup_32)
Linus Torvalds1da177e2005-04-16 15:20:36 -070028jiffies = jiffies_64;
Jeremy Fitzhardinge9c9b8b32006-09-25 23:32:26 -070029
30PHDRS {
31 text PT_LOAD FLAGS(5); /* R_E */
32 data PT_LOAD FLAGS(7); /* RWE */
33 note PT_NOTE FLAGS(4); /* R__ */
34}
Linus Torvalds1da177e2005-04-16 15:20:36 -070035SECTIONS
36{
Vivek Goyale69f2022006-12-07 02:14:04 +010037 . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -070038 phys_startup_32 = startup_32 - LOAD_OFFSET;
Linus Torvalds1da177e2005-04-16 15:20:36 -070039 /* read-only */
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -070040 .text : AT(ADDR(.text) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +010041 _text = .; /* Text and read-only data */
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 *(.text)
43 SCHED_TEXT
44 LOCK_TEXT
Prasanna S Panchamukhi3d97ae52005-09-06 15:19:27 -070045 KPROBES_TEXT
Linus Torvalds1da177e2005-04-16 15:20:36 -070046 *(.fixup)
47 *(.gnu.warning)
Vivek Goyal65695802006-12-07 02:14:03 +010048 _etext = .; /* End of text section */
49 } :text = 0x9090
Linus Torvalds1da177e2005-04-16 15:20:36 -070050
51 . = ALIGN(16); /* Exception table */
Vivek Goyal65695802006-12-07 02:14:03 +010052 __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {
53 __start___ex_table = .;
54 *(__ex_table)
55 __stop___ex_table = .;
56 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070057
58 RODATA
59
Linus Torvaldseb71c872006-06-24 14:27:42 -070060 . = ALIGN(4);
Linus Torvaldseb71c872006-06-24 14:27:42 -070061 .tracedata : AT(ADDR(.tracedata) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +010062 __tracedata_start = .;
Linus Torvaldseb71c872006-06-24 14:27:42 -070063 *(.tracedata)
Vivek Goyal65695802006-12-07 02:14:03 +010064 __tracedata_end = .;
Linus Torvaldseb71c872006-06-24 14:27:42 -070065 }
Linus Torvaldseb71c872006-06-24 14:27:42 -070066
Linus Torvalds1da177e2005-04-16 15:20:36 -070067 /* writeable */
Vivek Goyalc06cb8b2006-11-08 17:44:41 -080068 . = ALIGN(4096);
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -070069 .data : AT(ADDR(.data) - LOAD_OFFSET) { /* Data */
Linus Torvalds1da177e2005-04-16 15:20:36 -070070 *(.data)
71 CONSTRUCTORS
Jeremy Fitzhardinge9c9b8b32006-09-25 23:32:26 -070072 } :data
Linus Torvalds1da177e2005-04-16 15:20:36 -070073
Rusty Russellc9ccf302006-12-07 02:14:08 +010074 .paravirtprobe : AT(ADDR(.paravirtprobe) - LOAD_OFFSET) {
Vivek Goyal79929fd2006-12-07 02:14:10 +010075 __start_paravirtprobe = .;
Rusty Russellc9ccf302006-12-07 02:14:08 +010076 *(.paravirtprobe)
Vivek Goyal79929fd2006-12-07 02:14:10 +010077 __stop_paravirtprobe = .;
Rusty Russellc9ccf302006-12-07 02:14:08 +010078 }
Rusty Russellc9ccf302006-12-07 02:14:08 +010079
Linus Torvalds1da177e2005-04-16 15:20:36 -070080 . = ALIGN(4096);
Vivek Goyal65695802006-12-07 02:14:03 +010081 .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
82 __nosave_begin = .;
83 *(.data.nosave)
84 . = ALIGN(4096);
85 __nosave_end = .;
86 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070087
88 . = ALIGN(4096);
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -070089 .data.page_aligned : AT(ADDR(.data.page_aligned) - LOAD_OFFSET) {
90 *(.data.idt)
91 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070092
93 . = ALIGN(32);
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -070094 .data.cacheline_aligned : AT(ADDR(.data.cacheline_aligned) - LOAD_OFFSET) {
95 *(.data.cacheline_aligned)
96 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070097
Christoph Lameter6c036522005-07-07 17:56:59 -070098 /* rarely changed data like cpu maps */
99 . = ALIGN(32);
Vivek Goyal65695802006-12-07 02:14:03 +0100100 .data.read_mostly : AT(ADDR(.data.read_mostly) - LOAD_OFFSET) {
101 *(.data.read_mostly)
102 _edata = .; /* End of data section */
103 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104
Jan Beulich176a2712006-06-26 13:57:41 +0200105#ifdef CONFIG_STACK_UNWIND
106 . = ALIGN(4);
107 .eh_frame : AT(ADDR(.eh_frame) - LOAD_OFFSET) {
108 __start_unwind = .;
109 *(.eh_frame)
110 __end_unwind = .;
111 }
112#endif
113
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114 . = ALIGN(THREAD_SIZE); /* init_task */
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700115 .data.init_task : AT(ADDR(.data.init_task) - LOAD_OFFSET) {
116 *(.data.init_task)
117 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800119 /* might get freed after init */
120 . = ALIGN(4096);
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800121 .smp_altinstructions : AT(ADDR(.smp_altinstructions) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100122 __smp_alt_begin = .;
123 __smp_alt_instructions = .;
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800124 *(.smp_altinstructions)
Vivek Goyal65695802006-12-07 02:14:03 +0100125 __smp_alt_instructions_end = .;
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800126 }
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800127 . = ALIGN(4);
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800128 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100129 __smp_locks = .;
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800130 *(.smp_locks)
Vivek Goyal65695802006-12-07 02:14:03 +0100131 __smp_locks_end = .;
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800132 }
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800133 .smp_altinstr_replacement : AT(ADDR(.smp_altinstr_replacement) - LOAD_OFFSET) {
134 *(.smp_altinstr_replacement)
Vivek Goyal65695802006-12-07 02:14:03 +0100135 __smp_alt_end = .;
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800136 }
Vivek Goyal6ed01882006-12-07 02:14:03 +0100137 /* will be freed after init
138 * Following ALIGN() is required to make sure no other data falls on the
139 * same page where __smp_alt_end is pointing as that page might be freed
140 * after boot. Always make sure that ALIGN() directive is present after
141 * the section which contains __smp_alt_end.
142 */
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800143 . = ALIGN(4096);
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800144
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145 /* will be freed after init */
146 . = ALIGN(4096); /* Init code and data */
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700147 .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100148 __init_begin = .;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149 _sinittext = .;
150 *(.init.text)
151 _einittext = .;
152 }
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700153 .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) { *(.init.data) }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154 . = ALIGN(16);
Vivek Goyal65695802006-12-07 02:14:03 +0100155 .init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) {
156 __setup_start = .;
157 *(.init.setup)
158 __setup_end = .;
159 }
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700160 .initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100161 __initcall_start = .;
Andrew Morton61ce1ef2006-10-27 11:41:44 -0700162 INITCALLS
Vivek Goyal65695802006-12-07 02:14:03 +0100163 __initcall_end = .;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164 }
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700165 .con_initcall.init : AT(ADDR(.con_initcall.init) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100166 __con_initcall_start = .;
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700167 *(.con_initcall.init)
Vivek Goyal65695802006-12-07 02:14:03 +0100168 __con_initcall_end = .;
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700169 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170 SECURITY_INIT
171 . = ALIGN(4);
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700172 .altinstructions : AT(ADDR(.altinstructions) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100173 __alt_instructions = .;
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700174 *(.altinstructions)
Vivek Goyal65695802006-12-07 02:14:03 +0100175 __alt_instructions_end = .;
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700176 }
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700177 .altinstr_replacement : AT(ADDR(.altinstr_replacement) - LOAD_OFFSET) {
178 *(.altinstr_replacement)
179 }
Rusty Russell139ec7c2006-12-07 02:14:08 +0100180 . = ALIGN(4);
Rusty Russell139ec7c2006-12-07 02:14:08 +0100181 .parainstructions : AT(ADDR(.parainstructions) - LOAD_OFFSET) {
Vivek Goyal79929fd2006-12-07 02:14:10 +0100182 __start_parainstructions = .;
Rusty Russell139ec7c2006-12-07 02:14:08 +0100183 *(.parainstructions)
Vivek Goyal79929fd2006-12-07 02:14:10 +0100184 __stop_parainstructions = .;
Rusty Russell139ec7c2006-12-07 02:14:08 +0100185 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700186 /* .exit.text is discard at runtime, not link time, to deal with references
187 from .altinstructions and .eh_frame */
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700188 .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) { *(.exit.text) }
189 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) { *(.exit.data) }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190 . = ALIGN(4096);
Vivek Goyal65695802006-12-07 02:14:03 +0100191 .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) {
192 __initramfs_start = .;
193 *(.init.ramfs)
194 __initramfs_end = .;
195 }
Zach Brown379b5442006-01-27 14:02:47 -0800196 . = ALIGN(L1_CACHE_BYTES);
Vivek Goyal65695802006-12-07 02:14:03 +0100197 .data.percpu : AT(ADDR(.data.percpu) - LOAD_OFFSET) {
198 __per_cpu_start = .;
199 *(.data.percpu)
200 __per_cpu_end = .;
201 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700202 . = ALIGN(4096);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203 /* freed after init ends here */
204
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700205 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100206 __init_end = .;
207 __bss_start = .; /* BSS */
208 *(.bss.page_aligned)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209 *(.bss)
Vivek Goyal65695802006-12-07 02:14:03 +0100210 . = ALIGN(4);
211 __bss_stop = .;
212 _end = . ;
213 /* This is where the kernel creates the early boot page tables */
214 . = ALIGN(4096);
215 pg0 = . ;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700216 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700217
218 /* Sections to be discarded */
219 /DISCARD/ : {
220 *(.exitcall.exit)
221 }
222
Paolo 'Blaisorblade' Giarrussoa7d0c212005-09-10 19:44:54 +0200223 STABS_DEBUG
224
225 DWARF_DEBUG
Jeremy Fitzhardinge9c9b8b32006-09-25 23:32:26 -0700226
227 NOTES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700228}