blob: c217e18f10812bb6cc2fb72ed97dccdd28fad05d [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 }
Vivek Goyal6ed01882006-12-07 02:14:03 +0100124 /* will be freed after init
125 * Following ALIGN() is required to make sure no other data falls on the
126 * same page where __smp_alt_end is pointing as that page might be freed
127 * after boot. Always make sure that ALIGN() directive is present after
128 * the section which contains __smp_alt_end.
129 */
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800130 . = ALIGN(4096);
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800131
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132 /* will be freed after init */
133 . = ALIGN(4096); /* Init code and data */
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700134 .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100135 __init_begin = .;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136 _sinittext = .;
137 *(.init.text)
138 _einittext = .;
139 }
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700140 .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) { *(.init.data) }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141 . = ALIGN(16);
Vivek Goyal65695802006-12-07 02:14:03 +0100142 .init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) {
143 __setup_start = .;
144 *(.init.setup)
145 __setup_end = .;
146 }
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700147 .initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100148 __initcall_start = .;
Andrew Morton61ce1ef2006-10-27 11:41:44 -0700149 INITCALLS
Vivek Goyal65695802006-12-07 02:14:03 +0100150 __initcall_end = .;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151 }
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700152 .con_initcall.init : AT(ADDR(.con_initcall.init) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100153 __con_initcall_start = .;
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700154 *(.con_initcall.init)
Vivek Goyal65695802006-12-07 02:14:03 +0100155 __con_initcall_end = .;
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700156 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157 SECURITY_INIT
158 . = ALIGN(4);
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700159 .altinstructions : AT(ADDR(.altinstructions) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100160 __alt_instructions = .;
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700161 *(.altinstructions)
Vivek Goyal65695802006-12-07 02:14:03 +0100162 __alt_instructions_end = .;
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700163 }
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700164 .altinstr_replacement : AT(ADDR(.altinstr_replacement) - LOAD_OFFSET) {
165 *(.altinstr_replacement)
166 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700167 /* .exit.text is discard at runtime, not link time, to deal with references
168 from .altinstructions and .eh_frame */
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700169 .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) { *(.exit.text) }
170 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) { *(.exit.data) }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171 . = ALIGN(4096);
Vivek Goyal65695802006-12-07 02:14:03 +0100172 .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) {
173 __initramfs_start = .;
174 *(.init.ramfs)
175 __initramfs_end = .;
176 }
Zach Brown379b5442006-01-27 14:02:47 -0800177 . = ALIGN(L1_CACHE_BYTES);
Vivek Goyal65695802006-12-07 02:14:03 +0100178 .data.percpu : AT(ADDR(.data.percpu) - LOAD_OFFSET) {
179 __per_cpu_start = .;
180 *(.data.percpu)
181 __per_cpu_end = .;
182 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700183 . = ALIGN(4096);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184 /* freed after init ends here */
185
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700186 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100187 __init_end = .;
188 __bss_start = .; /* BSS */
189 *(.bss.page_aligned)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190 *(.bss)
Vivek Goyal65695802006-12-07 02:14:03 +0100191 . = ALIGN(4);
192 __bss_stop = .;
193 _end = . ;
194 /* This is where the kernel creates the early boot page tables */
195 . = ALIGN(4096);
196 pg0 = . ;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198
199 /* Sections to be discarded */
200 /DISCARD/ : {
201 *(.exitcall.exit)
202 }
203
Paolo 'Blaisorblade' Giarrussoa7d0c212005-09-10 19:44:54 +0200204 STABS_DEBUG
205
206 DWARF_DEBUG
Jeremy Fitzhardinge9c9b8b32006-09-25 23:32:26 -0700207
208 NOTES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209}