blob: f4ec722318358d2675dc57c1a58e55b0e3b72041 [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;
Andi Kleen08269c62007-04-16 10:30:27 +020029_proxy_pda = 1;
Jeremy Fitzhardinge9c9b8b32006-09-25 23:32:26 -070030
31PHDRS {
32 text PT_LOAD FLAGS(5); /* R_E */
33 data PT_LOAD FLAGS(7); /* RWE */
34 note PT_NOTE FLAGS(4); /* R__ */
35}
Linus Torvalds1da177e2005-04-16 15:20:36 -070036SECTIONS
37{
Vivek Goyale69f2022006-12-07 02:14:04 +010038 . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -070039 phys_startup_32 = startup_32 - LOAD_OFFSET;
Vivek Goyalf8657e12007-02-13 13:26:22 +010040
41 .text.head : AT(ADDR(.text.head) - LOAD_OFFSET) {
42 _text = .; /* Text and read-only data */
43 *(.text.head)
44 } :text = 0x9090
45
Linus Torvalds1da177e2005-04-16 15:20:36 -070046 /* read-only */
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -070047 .text : AT(ADDR(.text) - LOAD_OFFSET) {
Linus Torvalds1da177e2005-04-16 15:20:36 -070048 *(.text)
49 SCHED_TEXT
50 LOCK_TEXT
Prasanna S Panchamukhi3d97ae52005-09-06 15:19:27 -070051 KPROBES_TEXT
Linus Torvalds1da177e2005-04-16 15:20:36 -070052 *(.fixup)
53 *(.gnu.warning)
Vivek Goyal65695802006-12-07 02:14:03 +010054 _etext = .; /* End of text section */
55 } :text = 0x9090
Linus Torvalds1da177e2005-04-16 15:20:36 -070056
57 . = ALIGN(16); /* Exception table */
Vivek Goyal65695802006-12-07 02:14:03 +010058 __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {
59 __start___ex_table = .;
60 *(__ex_table)
61 __stop___ex_table = .;
62 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070063
Jeremy Fitzhardinge91768d62006-12-08 02:36:21 -080064 BUG_TABLE
65
Linus Torvaldseb71c872006-06-24 14:27:42 -070066 . = ALIGN(4);
Linus Torvaldseb71c872006-06-24 14:27:42 -070067 .tracedata : AT(ADDR(.tracedata) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +010068 __tracedata_start = .;
Linus Torvaldseb71c872006-06-24 14:27:42 -070069 *(.tracedata)
Vivek Goyal65695802006-12-07 02:14:03 +010070 __tracedata_end = .;
Linus Torvaldseb71c872006-06-24 14:27:42 -070071 }
Linus Torvaldseb71c872006-06-24 14:27:42 -070072
Jan Beulich6fb14752007-05-02 19:27:10 +020073 RODATA
74
Linus Torvalds1da177e2005-04-16 15:20:36 -070075 /* writeable */
Vivek Goyalc06cb8b2006-11-08 17:44:41 -080076 . = ALIGN(4096);
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -070077 .data : AT(ADDR(.data) - LOAD_OFFSET) { /* Data */
Linus Torvalds1da177e2005-04-16 15:20:36 -070078 *(.data)
79 CONSTRUCTORS
Jeremy Fitzhardinge9c9b8b32006-09-25 23:32:26 -070080 } :data
Linus Torvalds1da177e2005-04-16 15:20:36 -070081
Rusty Russellc9ccf302006-12-07 02:14:08 +010082 .paravirtprobe : AT(ADDR(.paravirtprobe) - LOAD_OFFSET) {
Vivek Goyal79929fd2006-12-07 02:14:10 +010083 __start_paravirtprobe = .;
Rusty Russellc9ccf302006-12-07 02:14:08 +010084 *(.paravirtprobe)
Vivek Goyal79929fd2006-12-07 02:14:10 +010085 __stop_paravirtprobe = .;
Rusty Russellc9ccf302006-12-07 02:14:08 +010086 }
Rusty Russellc9ccf302006-12-07 02:14:08 +010087
Linus Torvalds1da177e2005-04-16 15:20:36 -070088 . = ALIGN(4096);
Vivek Goyal65695802006-12-07 02:14:03 +010089 .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
90 __nosave_begin = .;
91 *(.data.nosave)
92 . = ALIGN(4096);
93 __nosave_end = .;
94 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070095
96 . = ALIGN(4096);
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -070097 .data.page_aligned : AT(ADDR(.data.page_aligned) - LOAD_OFFSET) {
98 *(.data.idt)
99 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100
101 . = ALIGN(32);
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700102 .data.cacheline_aligned : AT(ADDR(.data.cacheline_aligned) - LOAD_OFFSET) {
103 *(.data.cacheline_aligned)
104 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105
Christoph Lameter6c036522005-07-07 17:56:59 -0700106 /* rarely changed data like cpu maps */
107 . = ALIGN(32);
Vivek Goyal65695802006-12-07 02:14:03 +0100108 .data.read_mostly : AT(ADDR(.data.read_mostly) - LOAD_OFFSET) {
109 *(.data.read_mostly)
110 _edata = .; /* End of data section */
111 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112
113 . = ALIGN(THREAD_SIZE); /* init_task */
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700114 .data.init_task : AT(ADDR(.data.init_task) - LOAD_OFFSET) {
115 *(.data.init_task)
116 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800118 /* might get freed after init */
119 . = ALIGN(4096);
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800120 .smp_altinstructions : AT(ADDR(.smp_altinstructions) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100121 __smp_alt_begin = .;
122 __smp_alt_instructions = .;
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800123 *(.smp_altinstructions)
Vivek Goyal65695802006-12-07 02:14:03 +0100124 __smp_alt_instructions_end = .;
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800125 }
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800126 . = ALIGN(4);
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800127 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100128 __smp_locks = .;
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800129 *(.smp_locks)
Vivek Goyal65695802006-12-07 02:14:03 +0100130 __smp_locks_end = .;
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800131 }
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800132 .smp_altinstr_replacement : AT(ADDR(.smp_altinstr_replacement) - LOAD_OFFSET) {
133 *(.smp_altinstr_replacement)
Vivek Goyal65695802006-12-07 02:14:03 +0100134 __smp_alt_end = .;
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800135 }
Vivek Goyal6ed01882006-12-07 02:14:03 +0100136 /* will be freed after init
137 * Following ALIGN() is required to make sure no other data falls on the
138 * same page where __smp_alt_end is pointing as that page might be freed
139 * after boot. Always make sure that ALIGN() directive is present after
140 * the section which contains __smp_alt_end.
141 */
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800142 . = ALIGN(4096);
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800143
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144 /* will be freed after init */
145 . = ALIGN(4096); /* Init code and data */
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700146 .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100147 __init_begin = .;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148 _sinittext = .;
149 *(.init.text)
150 _einittext = .;
151 }
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700152 .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) { *(.init.data) }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153 . = ALIGN(16);
Vivek Goyal65695802006-12-07 02:14:03 +0100154 .init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) {
155 __setup_start = .;
156 *(.init.setup)
157 __setup_end = .;
158 }
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700159 .initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100160 __initcall_start = .;
Andrew Morton61ce1ef2006-10-27 11:41:44 -0700161 INITCALLS
Vivek Goyal65695802006-12-07 02:14:03 +0100162 __initcall_end = .;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163 }
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700164 .con_initcall.init : AT(ADDR(.con_initcall.init) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100165 __con_initcall_start = .;
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700166 *(.con_initcall.init)
Vivek Goyal65695802006-12-07 02:14:03 +0100167 __con_initcall_end = .;
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700168 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700169 SECURITY_INIT
170 . = ALIGN(4);
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700171 .altinstructions : AT(ADDR(.altinstructions) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100172 __alt_instructions = .;
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700173 *(.altinstructions)
Vivek Goyal65695802006-12-07 02:14:03 +0100174 __alt_instructions_end = .;
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700175 }
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700176 .altinstr_replacement : AT(ADDR(.altinstr_replacement) - LOAD_OFFSET) {
177 *(.altinstr_replacement)
178 }
Rusty Russell139ec7c2006-12-07 02:14:08 +0100179 . = ALIGN(4);
Rusty Russell139ec7c2006-12-07 02:14:08 +0100180 .parainstructions : AT(ADDR(.parainstructions) - LOAD_OFFSET) {
Vivek Goyal79929fd2006-12-07 02:14:10 +0100181 __start_parainstructions = .;
Rusty Russell139ec7c2006-12-07 02:14:08 +0100182 *(.parainstructions)
Vivek Goyal79929fd2006-12-07 02:14:10 +0100183 __stop_parainstructions = .;
Rusty Russell139ec7c2006-12-07 02:14:08 +0100184 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185 /* .exit.text is discard at runtime, not link time, to deal with references
186 from .altinstructions and .eh_frame */
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700187 .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) { *(.exit.text) }
188 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) { *(.exit.data) }
Jean-Paul Saman67d38222007-02-10 01:44:44 -0800189#if defined(CONFIG_BLK_DEV_INITRD)
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 }
Jean-Paul Saman67d38222007-02-10 01:44:44 -0800196#endif
Zach Brown379b5442006-01-27 14:02:47 -0800197 . = ALIGN(L1_CACHE_BYTES);
Vivek Goyal65695802006-12-07 02:14:03 +0100198 .data.percpu : AT(ADDR(.data.percpu) - LOAD_OFFSET) {
199 __per_cpu_start = .;
200 *(.data.percpu)
201 __per_cpu_end = .;
202 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203 . = ALIGN(4096);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700204 /* freed after init ends here */
205
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700206 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100207 __init_end = .;
208 __bss_start = .; /* BSS */
209 *(.bss.page_aligned)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210 *(.bss)
Vivek Goyal65695802006-12-07 02:14:03 +0100211 . = ALIGN(4);
212 __bss_stop = .;
213 _end = . ;
214 /* This is where the kernel creates the early boot page tables */
215 . = ALIGN(4096);
216 pg0 = . ;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700217 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218
219 /* Sections to be discarded */
220 /DISCARD/ : {
221 *(.exitcall.exit)
222 }
223
Paolo 'Blaisorblade' Giarrussoa7d0c212005-09-10 19:44:54 +0200224 STABS_DEBUG
225
226 DWARF_DEBUG
Jeremy Fitzhardinge9c9b8b32006-09-25 23:32:26 -0700227
228 NOTES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700229}