blob: 877dc5cfe3a8a6019f0e46d267386a6391044218 [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>
Vivek Goyale69f2022006-12-07 02:14:04 +010017#include <asm/boot.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070018
19OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
20OUTPUT_ARCH(i386)
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -070021ENTRY(phys_startup_32)
Linus Torvalds1da177e2005-04-16 15:20:36 -070022jiffies = jiffies_64;
Jeremy Fitzhardinge9c9b8b32006-09-25 23:32:26 -070023
24PHDRS {
25 text PT_LOAD FLAGS(5); /* R_E */
26 data PT_LOAD FLAGS(7); /* RWE */
27 note PT_NOTE FLAGS(4); /* R__ */
28}
Linus Torvalds1da177e2005-04-16 15:20:36 -070029SECTIONS
30{
Vivek Goyale69f2022006-12-07 02:14:04 +010031 . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -070032 phys_startup_32 = startup_32 - LOAD_OFFSET;
Linus Torvalds1da177e2005-04-16 15:20:36 -070033 /* read-only */
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -070034 .text : AT(ADDR(.text) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +010035 _text = .; /* Text and read-only data */
Linus Torvalds1da177e2005-04-16 15:20:36 -070036 *(.text)
37 SCHED_TEXT
38 LOCK_TEXT
Prasanna S Panchamukhi3d97ae52005-09-06 15:19:27 -070039 KPROBES_TEXT
Linus Torvalds1da177e2005-04-16 15:20:36 -070040 *(.fixup)
41 *(.gnu.warning)
Vivek Goyal65695802006-12-07 02:14:03 +010042 _etext = .; /* End of text section */
43 } :text = 0x9090
Linus Torvalds1da177e2005-04-16 15:20:36 -070044
45 . = ALIGN(16); /* Exception table */
Vivek Goyal65695802006-12-07 02:14:03 +010046 __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {
47 __start___ex_table = .;
48 *(__ex_table)
49 __stop___ex_table = .;
50 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070051
52 RODATA
53
Linus Torvaldseb71c872006-06-24 14:27:42 -070054 . = ALIGN(4);
Linus Torvaldseb71c872006-06-24 14:27:42 -070055 .tracedata : AT(ADDR(.tracedata) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +010056 __tracedata_start = .;
Linus Torvaldseb71c872006-06-24 14:27:42 -070057 *(.tracedata)
Vivek Goyal65695802006-12-07 02:14:03 +010058 __tracedata_end = .;
Linus Torvaldseb71c872006-06-24 14:27:42 -070059 }
Linus Torvaldseb71c872006-06-24 14:27:42 -070060
Linus Torvalds1da177e2005-04-16 15:20:36 -070061 /* writeable */
Vivek Goyalc06cb8b2006-11-08 17:44:41 -080062 . = ALIGN(4096);
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -070063 .data : AT(ADDR(.data) - LOAD_OFFSET) { /* Data */
Linus Torvalds1da177e2005-04-16 15:20:36 -070064 *(.data)
65 CONSTRUCTORS
Jeremy Fitzhardinge9c9b8b32006-09-25 23:32:26 -070066 } :data
Linus Torvalds1da177e2005-04-16 15:20:36 -070067
Rusty Russellc9ccf302006-12-07 02:14:08 +010068 __start_paravirtprobe = .;
69 .paravirtprobe : AT(ADDR(.paravirtprobe) - LOAD_OFFSET) {
70 *(.paravirtprobe)
71 }
72 __stop_paravirtprobe = .;
73
Linus Torvalds1da177e2005-04-16 15:20:36 -070074 . = ALIGN(4096);
Vivek Goyal65695802006-12-07 02:14:03 +010075 .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
76 __nosave_begin = .;
77 *(.data.nosave)
78 . = ALIGN(4096);
79 __nosave_end = .;
80 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070081
82 . = ALIGN(4096);
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -070083 .data.page_aligned : AT(ADDR(.data.page_aligned) - LOAD_OFFSET) {
84 *(.data.idt)
85 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070086
87 . = ALIGN(32);
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -070088 .data.cacheline_aligned : AT(ADDR(.data.cacheline_aligned) - LOAD_OFFSET) {
89 *(.data.cacheline_aligned)
90 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070091
Christoph Lameter6c036522005-07-07 17:56:59 -070092 /* rarely changed data like cpu maps */
93 . = ALIGN(32);
Vivek Goyal65695802006-12-07 02:14:03 +010094 .data.read_mostly : AT(ADDR(.data.read_mostly) - LOAD_OFFSET) {
95 *(.data.read_mostly)
96 _edata = .; /* End of data section */
97 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070098
Jan Beulich176a2712006-06-26 13:57:41 +020099#ifdef CONFIG_STACK_UNWIND
100 . = ALIGN(4);
101 .eh_frame : AT(ADDR(.eh_frame) - LOAD_OFFSET) {
102 __start_unwind = .;
103 *(.eh_frame)
104 __end_unwind = .;
105 }
106#endif
107
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108 . = ALIGN(THREAD_SIZE); /* init_task */
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700109 .data.init_task : AT(ADDR(.data.init_task) - LOAD_OFFSET) {
110 *(.data.init_task)
111 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800113 /* might get freed after init */
114 . = ALIGN(4096);
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800115 .smp_altinstructions : AT(ADDR(.smp_altinstructions) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100116 __smp_alt_begin = .;
117 __smp_alt_instructions = .;
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800118 *(.smp_altinstructions)
Vivek Goyal65695802006-12-07 02:14:03 +0100119 __smp_alt_instructions_end = .;
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800120 }
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800121 . = ALIGN(4);
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800122 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100123 __smp_locks = .;
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800124 *(.smp_locks)
Vivek Goyal65695802006-12-07 02:14:03 +0100125 __smp_locks_end = .;
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800126 }
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800127 .smp_altinstr_replacement : AT(ADDR(.smp_altinstr_replacement) - LOAD_OFFSET) {
128 *(.smp_altinstr_replacement)
Vivek Goyal65695802006-12-07 02:14:03 +0100129 __smp_alt_end = .;
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800130 }
Vivek Goyal6ed01882006-12-07 02:14:03 +0100131 /* will be freed after init
132 * Following ALIGN() is required to make sure no other data falls on the
133 * same page where __smp_alt_end is pointing as that page might be freed
134 * after boot. Always make sure that ALIGN() directive is present after
135 * the section which contains __smp_alt_end.
136 */
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800137 . = ALIGN(4096);
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800138
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139 /* will be freed after init */
140 . = ALIGN(4096); /* Init code and data */
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700141 .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100142 __init_begin = .;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143 _sinittext = .;
144 *(.init.text)
145 _einittext = .;
146 }
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700147 .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) { *(.init.data) }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148 . = ALIGN(16);
Vivek Goyal65695802006-12-07 02:14:03 +0100149 .init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) {
150 __setup_start = .;
151 *(.init.setup)
152 __setup_end = .;
153 }
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700154 .initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100155 __initcall_start = .;
Andrew Morton61ce1ef2006-10-27 11:41:44 -0700156 INITCALLS
Vivek Goyal65695802006-12-07 02:14:03 +0100157 __initcall_end = .;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700158 }
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700159 .con_initcall.init : AT(ADDR(.con_initcall.init) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100160 __con_initcall_start = .;
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700161 *(.con_initcall.init)
Vivek Goyal65695802006-12-07 02:14:03 +0100162 __con_initcall_end = .;
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700163 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164 SECURITY_INIT
165 . = ALIGN(4);
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700166 .altinstructions : AT(ADDR(.altinstructions) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100167 __alt_instructions = .;
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700168 *(.altinstructions)
Vivek Goyal65695802006-12-07 02:14:03 +0100169 __alt_instructions_end = .;
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700170 }
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700171 .altinstr_replacement : AT(ADDR(.altinstr_replacement) - LOAD_OFFSET) {
172 *(.altinstr_replacement)
173 }
Rusty Russell139ec7c2006-12-07 02:14:08 +0100174 . = ALIGN(4);
175 __start_parainstructions = .;
176 .parainstructions : AT(ADDR(.parainstructions) - LOAD_OFFSET) {
177 *(.parainstructions)
178 }
179 __stop_parainstructions = .;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700180 /* .exit.text is discard at runtime, not link time, to deal with references
181 from .altinstructions and .eh_frame */
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700182 .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) { *(.exit.text) }
183 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) { *(.exit.data) }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184 . = ALIGN(4096);
Vivek Goyal65695802006-12-07 02:14:03 +0100185 .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) {
186 __initramfs_start = .;
187 *(.init.ramfs)
188 __initramfs_end = .;
189 }
Zach Brown379b5442006-01-27 14:02:47 -0800190 . = ALIGN(L1_CACHE_BYTES);
Vivek Goyal65695802006-12-07 02:14:03 +0100191 .data.percpu : AT(ADDR(.data.percpu) - LOAD_OFFSET) {
192 __per_cpu_start = .;
193 *(.data.percpu)
194 __per_cpu_end = .;
195 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196 . = ALIGN(4096);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197 /* freed after init ends here */
198
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700199 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100200 __init_end = .;
201 __bss_start = .; /* BSS */
202 *(.bss.page_aligned)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203 *(.bss)
Vivek Goyal65695802006-12-07 02:14:03 +0100204 . = ALIGN(4);
205 __bss_stop = .;
206 _end = . ;
207 /* This is where the kernel creates the early boot page tables */
208 . = ALIGN(4096);
209 pg0 = . ;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700211
212 /* Sections to be discarded */
213 /DISCARD/ : {
214 *(.exitcall.exit)
215 }
216
Paolo 'Blaisorblade' Giarrussoa7d0c212005-09-10 19:44:54 +0200217 STABS_DEBUG
218
219 DWARF_DEBUG
Jeremy Fitzhardinge9c9b8b32006-09-25 23:32:26 -0700220
221 NOTES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700222}