blob: 6860f20aa5791c8a67483d3313118dc5f6e88624 [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
68 . = ALIGN(4096);
Vivek Goyal65695802006-12-07 02:14:03 +010069 .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
70 __nosave_begin = .;
71 *(.data.nosave)
72 . = ALIGN(4096);
73 __nosave_end = .;
74 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070075
76 . = ALIGN(4096);
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -070077 .data.page_aligned : AT(ADDR(.data.page_aligned) - LOAD_OFFSET) {
78 *(.data.idt)
79 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070080
81 . = ALIGN(32);
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -070082 .data.cacheline_aligned : AT(ADDR(.data.cacheline_aligned) - LOAD_OFFSET) {
83 *(.data.cacheline_aligned)
84 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070085
Christoph Lameter6c036522005-07-07 17:56:59 -070086 /* rarely changed data like cpu maps */
87 . = ALIGN(32);
Vivek Goyal65695802006-12-07 02:14:03 +010088 .data.read_mostly : AT(ADDR(.data.read_mostly) - LOAD_OFFSET) {
89 *(.data.read_mostly)
90 _edata = .; /* End of data section */
91 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070092
Jan Beulich176a2712006-06-26 13:57:41 +020093#ifdef CONFIG_STACK_UNWIND
94 . = ALIGN(4);
95 .eh_frame : AT(ADDR(.eh_frame) - LOAD_OFFSET) {
96 __start_unwind = .;
97 *(.eh_frame)
98 __end_unwind = .;
99 }
100#endif
101
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102 . = ALIGN(THREAD_SIZE); /* init_task */
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700103 .data.init_task : AT(ADDR(.data.init_task) - LOAD_OFFSET) {
104 *(.data.init_task)
105 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800107 /* might get freed after init */
108 . = ALIGN(4096);
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800109 .smp_altinstructions : AT(ADDR(.smp_altinstructions) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100110 __smp_alt_begin = .;
111 __smp_alt_instructions = .;
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800112 *(.smp_altinstructions)
Vivek Goyal65695802006-12-07 02:14:03 +0100113 __smp_alt_instructions_end = .;
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800114 }
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800115 . = ALIGN(4);
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800116 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100117 __smp_locks = .;
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800118 *(.smp_locks)
Vivek Goyal65695802006-12-07 02:14:03 +0100119 __smp_locks_end = .;
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800120 }
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800121 .smp_altinstr_replacement : AT(ADDR(.smp_altinstr_replacement) - LOAD_OFFSET) {
122 *(.smp_altinstr_replacement)
Vivek Goyal65695802006-12-07 02:14:03 +0100123 __smp_alt_end = .;
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800124 }
Vivek Goyal6ed01882006-12-07 02:14:03 +0100125 /* will be freed after init
126 * Following ALIGN() is required to make sure no other data falls on the
127 * same page where __smp_alt_end is pointing as that page might be freed
128 * after boot. Always make sure that ALIGN() directive is present after
129 * the section which contains __smp_alt_end.
130 */
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800131 . = ALIGN(4096);
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800132
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133 /* will be freed after init */
134 . = ALIGN(4096); /* Init code and data */
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700135 .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100136 __init_begin = .;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137 _sinittext = .;
138 *(.init.text)
139 _einittext = .;
140 }
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700141 .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) { *(.init.data) }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142 . = ALIGN(16);
Vivek Goyal65695802006-12-07 02:14:03 +0100143 .init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) {
144 __setup_start = .;
145 *(.init.setup)
146 __setup_end = .;
147 }
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700148 .initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100149 __initcall_start = .;
Andrew Morton61ce1ef2006-10-27 11:41:44 -0700150 INITCALLS
Vivek Goyal65695802006-12-07 02:14:03 +0100151 __initcall_end = .;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152 }
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700153 .con_initcall.init : AT(ADDR(.con_initcall.init) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100154 __con_initcall_start = .;
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700155 *(.con_initcall.init)
Vivek Goyal65695802006-12-07 02:14:03 +0100156 __con_initcall_end = .;
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700157 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700158 SECURITY_INIT
159 . = ALIGN(4);
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700160 .altinstructions : AT(ADDR(.altinstructions) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100161 __alt_instructions = .;
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700162 *(.altinstructions)
Vivek Goyal65695802006-12-07 02:14:03 +0100163 __alt_instructions_end = .;
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700164 }
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700165 .altinstr_replacement : AT(ADDR(.altinstr_replacement) - LOAD_OFFSET) {
166 *(.altinstr_replacement)
167 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168 /* .exit.text is discard at runtime, not link time, to deal with references
169 from .altinstructions and .eh_frame */
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700170 .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) { *(.exit.text) }
171 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) { *(.exit.data) }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172 . = ALIGN(4096);
Vivek Goyal65695802006-12-07 02:14:03 +0100173 .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) {
174 __initramfs_start = .;
175 *(.init.ramfs)
176 __initramfs_end = .;
177 }
Zach Brown379b5442006-01-27 14:02:47 -0800178 . = ALIGN(L1_CACHE_BYTES);
Vivek Goyal65695802006-12-07 02:14:03 +0100179 .data.percpu : AT(ADDR(.data.percpu) - LOAD_OFFSET) {
180 __per_cpu_start = .;
181 *(.data.percpu)
182 __per_cpu_end = .;
183 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184 . = ALIGN(4096);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185 /* freed after init ends here */
186
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700187 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100188 __init_end = .;
189 __bss_start = .; /* BSS */
190 *(.bss.page_aligned)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191 *(.bss)
Vivek Goyal65695802006-12-07 02:14:03 +0100192 . = ALIGN(4);
193 __bss_stop = .;
194 _end = . ;
195 /* This is where the kernel creates the early boot page tables */
196 . = ALIGN(4096);
197 pg0 = . ;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700199
200 /* Sections to be discarded */
201 /DISCARD/ : {
202 *(.exitcall.exit)
203 }
204
Paolo 'Blaisorblade' Giarrussoa7d0c212005-09-10 19:44:54 +0200205 STABS_DEBUG
206
207 DWARF_DEBUG
Jeremy Fitzhardinge9c9b8b32006-09-25 23:32:26 -0700208
209 NOTES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210}