blob: cbd24860fbb79b3c744f78bc117f48e6e513c8fe [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
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -070011#define LOAD_OFFSET __PAGE_OFFSET
12
Linus Torvalds1da177e2005-04-16 15:20:36 -070013#include <asm-generic/vmlinux.lds.h>
14#include <asm/thread_info.h>
15#include <asm/page.h>
Zach Brown379b5442006-01-27 14:02:47 -080016#include <asm/cache.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070017
18OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
19OUTPUT_ARCH(i386)
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -070020ENTRY(phys_startup_32)
Linus Torvalds1da177e2005-04-16 15:20:36 -070021jiffies = jiffies_64;
Jeremy Fitzhardinge9c9b8b32006-09-25 23:32:26 -070022
23PHDRS {
24 text PT_LOAD FLAGS(5); /* R_E */
25 data PT_LOAD FLAGS(7); /* RWE */
26 note PT_NOTE FLAGS(4); /* R__ */
27}
Linus Torvalds1da177e2005-04-16 15:20:36 -070028SECTIONS
29{
Eric W. Biederman3d345e32005-06-25 14:57:49 -070030 . = __KERNEL_START;
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -070031 phys_startup_32 = startup_32 - LOAD_OFFSET;
Linus Torvalds1da177e2005-04-16 15:20:36 -070032 /* read-only */
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -070033 .text : AT(ADDR(.text) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +010034 _text = .; /* Text and read-only data */
Linus Torvalds1da177e2005-04-16 15:20:36 -070035 *(.text)
36 SCHED_TEXT
37 LOCK_TEXT
Prasanna S Panchamukhi3d97ae52005-09-06 15:19:27 -070038 KPROBES_TEXT
Linus Torvalds1da177e2005-04-16 15:20:36 -070039 *(.fixup)
40 *(.gnu.warning)
Vivek Goyal65695802006-12-07 02:14:03 +010041 _etext = .; /* End of text section */
42 } :text = 0x9090
Linus Torvalds1da177e2005-04-16 15:20:36 -070043
44 . = ALIGN(16); /* Exception table */
Vivek Goyal65695802006-12-07 02:14:03 +010045 __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {
46 __start___ex_table = .;
47 *(__ex_table)
48 __stop___ex_table = .;
49 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070050
51 RODATA
52
Linus Torvaldseb71c872006-06-24 14:27:42 -070053 . = ALIGN(4);
Linus Torvaldseb71c872006-06-24 14:27:42 -070054 .tracedata : AT(ADDR(.tracedata) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +010055 __tracedata_start = .;
Linus Torvaldseb71c872006-06-24 14:27:42 -070056 *(.tracedata)
Vivek Goyal65695802006-12-07 02:14:03 +010057 __tracedata_end = .;
Linus Torvaldseb71c872006-06-24 14:27:42 -070058 }
Linus Torvaldseb71c872006-06-24 14:27:42 -070059
Linus Torvalds1da177e2005-04-16 15:20:36 -070060 /* writeable */
Vivek Goyalc06cb8b2006-11-08 17:44:41 -080061 . = ALIGN(4096);
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -070062 .data : AT(ADDR(.data) - LOAD_OFFSET) { /* Data */
Linus Torvalds1da177e2005-04-16 15:20:36 -070063 *(.data)
64 CONSTRUCTORS
Jeremy Fitzhardinge9c9b8b32006-09-25 23:32:26 -070065 } :data
Linus Torvalds1da177e2005-04-16 15:20:36 -070066
67 . = ALIGN(4096);
Vivek Goyal65695802006-12-07 02:14:03 +010068 .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
69 __nosave_begin = .;
70 *(.data.nosave)
71 . = ALIGN(4096);
72 __nosave_end = .;
73 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070074
75 . = ALIGN(4096);
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -070076 .data.page_aligned : AT(ADDR(.data.page_aligned) - LOAD_OFFSET) {
77 *(.data.idt)
78 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070079
80 . = ALIGN(32);
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -070081 .data.cacheline_aligned : AT(ADDR(.data.cacheline_aligned) - LOAD_OFFSET) {
82 *(.data.cacheline_aligned)
83 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070084
Christoph Lameter6c036522005-07-07 17:56:59 -070085 /* rarely changed data like cpu maps */
86 . = ALIGN(32);
Vivek Goyal65695802006-12-07 02:14:03 +010087 .data.read_mostly : AT(ADDR(.data.read_mostly) - LOAD_OFFSET) {
88 *(.data.read_mostly)
89 _edata = .; /* End of data section */
90 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070091
Jan Beulich176a2712006-06-26 13:57:41 +020092#ifdef CONFIG_STACK_UNWIND
93 . = ALIGN(4);
94 .eh_frame : AT(ADDR(.eh_frame) - LOAD_OFFSET) {
95 __start_unwind = .;
96 *(.eh_frame)
97 __end_unwind = .;
98 }
99#endif
100
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101 . = ALIGN(THREAD_SIZE); /* init_task */
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700102 .data.init_task : AT(ADDR(.data.init_task) - LOAD_OFFSET) {
103 *(.data.init_task)
104 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800106 /* might get freed after init */
107 . = ALIGN(4096);
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800108 .smp_altinstructions : AT(ADDR(.smp_altinstructions) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100109 __smp_alt_begin = .;
110 __smp_alt_instructions = .;
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800111 *(.smp_altinstructions)
Vivek Goyal65695802006-12-07 02:14:03 +0100112 __smp_alt_instructions_end = .;
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800113 }
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800114 . = ALIGN(4);
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800115 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100116 __smp_locks = .;
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800117 *(.smp_locks)
Vivek Goyal65695802006-12-07 02:14:03 +0100118 __smp_locks_end = .;
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800119 }
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800120 .smp_altinstr_replacement : AT(ADDR(.smp_altinstr_replacement) - LOAD_OFFSET) {
121 *(.smp_altinstr_replacement)
Vivek Goyal65695802006-12-07 02:14:03 +0100122 __smp_alt_end = .;
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800123 }
124 . = ALIGN(4096);
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800125
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126 /* will be freed after init */
127 . = ALIGN(4096); /* Init code and data */
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700128 .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100129 __init_begin = .;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130 _sinittext = .;
131 *(.init.text)
132 _einittext = .;
133 }
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700134 .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) { *(.init.data) }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135 . = ALIGN(16);
Vivek Goyal65695802006-12-07 02:14:03 +0100136 .init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) {
137 __setup_start = .;
138 *(.init.setup)
139 __setup_end = .;
140 }
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700141 .initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100142 __initcall_start = .;
Andrew Morton61ce1ef2006-10-27 11:41:44 -0700143 INITCALLS
Vivek Goyal65695802006-12-07 02:14:03 +0100144 __initcall_end = .;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145 }
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700146 .con_initcall.init : AT(ADDR(.con_initcall.init) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100147 __con_initcall_start = .;
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700148 *(.con_initcall.init)
Vivek Goyal65695802006-12-07 02:14:03 +0100149 __con_initcall_end = .;
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700150 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151 SECURITY_INIT
152 . = ALIGN(4);
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700153 .altinstructions : AT(ADDR(.altinstructions) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100154 __alt_instructions = .;
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700155 *(.altinstructions)
Vivek Goyal65695802006-12-07 02:14:03 +0100156 __alt_instructions_end = .;
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700157 }
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -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. Biedermanad0d75e2005-06-25 14:57:47 -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);
Vivek Goyal65695802006-12-07 02:14:03 +0100166 .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) {
167 __initramfs_start = .;
168 *(.init.ramfs)
169 __initramfs_end = .;
170 }
Zach Brown379b5442006-01-27 14:02:47 -0800171 . = ALIGN(L1_CACHE_BYTES);
Vivek Goyal65695802006-12-07 02:14:03 +0100172 .data.percpu : AT(ADDR(.data.percpu) - LOAD_OFFSET) {
173 __per_cpu_start = .;
174 *(.data.percpu)
175 __per_cpu_end = .;
176 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177 . = ALIGN(4096);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700178 /* freed after init ends here */
179
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700180 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100181 __init_end = .;
182 __bss_start = .; /* BSS */
183 *(.bss.page_aligned)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184 *(.bss)
Vivek Goyal65695802006-12-07 02:14:03 +0100185 . = ALIGN(4);
186 __bss_stop = .;
187 _end = . ;
188 /* This is where the kernel creates the early boot page tables */
189 . = ALIGN(4096);
190 pg0 = . ;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192
193 /* Sections to be discarded */
194 /DISCARD/ : {
195 *(.exitcall.exit)
196 }
197
Paolo 'Blaisorblade' Giarrussoa7d0c212005-09-10 19:44:54 +0200198 STABS_DEBUG
199
200 DWARF_DEBUG
Jeremy Fitzhardinge9c9b8b32006-09-25 23:32:26 -0700201
202 NOTES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203}