blob: aa87b06c7c8233930358bcc613f2c10dcd764f61 [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;
Jeremy Fitzhardinge9c9b8b32006-09-25 23:32:26 -070029
30PHDRS {
31 text PT_LOAD FLAGS(5); /* R_E */
32 data PT_LOAD FLAGS(7); /* RWE */
Jeremy Fitzhardinge03df4f62007-05-02 19:27:17 +020033 note PT_NOTE FLAGS(0); /* ___ */
Jeremy Fitzhardinge9c9b8b32006-09-25 23:32:26 -070034}
Linus Torvalds1da177e2005-04-16 15:20:36 -070035SECTIONS
36{
Vivek Goyale69f2022006-12-07 02:14:04 +010037 . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -070038 phys_startup_32 = startup_32 - LOAD_OFFSET;
Vivek Goyalf8657e12007-02-13 13:26:22 +010039
40 .text.head : AT(ADDR(.text.head) - LOAD_OFFSET) {
41 _text = .; /* Text and read-only data */
42 *(.text.head)
43 } :text = 0x9090
44
Linus Torvalds1da177e2005-04-16 15:20:36 -070045 /* read-only */
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -070046 .text : AT(ADDR(.text) - LOAD_OFFSET) {
Sam Ravnborg76647092007-05-13 00:31:33 +020047 TEXT_TEXT
Linus Torvalds1da177e2005-04-16 15:20:36 -070048 SCHED_TEXT
49 LOCK_TEXT
Prasanna S Panchamukhi3d97ae52005-09-06 15:19:27 -070050 KPROBES_TEXT
Linus Torvalds1da177e2005-04-16 15:20:36 -070051 *(.fixup)
52 *(.gnu.warning)
Vivek Goyal65695802006-12-07 02:14:03 +010053 _etext = .; /* End of text section */
54 } :text = 0x9090
Linus Torvalds1da177e2005-04-16 15:20:36 -070055
56 . = ALIGN(16); /* Exception table */
Vivek Goyal65695802006-12-07 02:14:03 +010057 __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {
58 __start___ex_table = .;
59 *(__ex_table)
60 __stop___ex_table = .;
61 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070062
Jeremy Fitzhardinge91768d62006-12-08 02:36:21 -080063 BUG_TABLE
64
Linus Torvaldseb71c872006-06-24 14:27:42 -070065 . = ALIGN(4);
Linus Torvaldseb71c872006-06-24 14:27:42 -070066 .tracedata : AT(ADDR(.tracedata) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +010067 __tracedata_start = .;
Linus Torvaldseb71c872006-06-24 14:27:42 -070068 *(.tracedata)
Vivek Goyal65695802006-12-07 02:14:03 +010069 __tracedata_end = .;
Linus Torvaldseb71c872006-06-24 14:27:42 -070070 }
Linus Torvaldseb71c872006-06-24 14:27:42 -070071
Jan Beulich6fb14752007-05-02 19:27:10 +020072 RODATA
73
Linus Torvalds1da177e2005-04-16 15:20:36 -070074 /* writeable */
Vivek Goyalc06cb8b2006-11-08 17:44:41 -080075 . = ALIGN(4096);
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -070076 .data : AT(ADDR(.data) - LOAD_OFFSET) { /* Data */
Sam Ravnborgca967252007-05-17 13:38:44 +020077 DATA_DATA
Linus Torvalds1da177e2005-04-16 15:20:36 -070078 CONSTRUCTORS
Jeremy Fitzhardinge9c9b8b32006-09-25 23:32:26 -070079 } :data
Linus Torvalds1da177e2005-04-16 15:20:36 -070080
81 . = ALIGN(4096);
Vivek Goyal65695802006-12-07 02:14:03 +010082 .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
83 __nosave_begin = .;
84 *(.data.nosave)
85 . = ALIGN(4096);
86 __nosave_end = .;
87 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070088
89 . = ALIGN(4096);
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -070090 .data.page_aligned : AT(ADDR(.data.page_aligned) - LOAD_OFFSET) {
91 *(.data.idt)
92 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070093
94 . = ALIGN(32);
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -070095 .data.cacheline_aligned : AT(ADDR(.data.cacheline_aligned) - LOAD_OFFSET) {
96 *(.data.cacheline_aligned)
97 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070098
Christoph Lameter6c036522005-07-07 17:56:59 -070099 /* rarely changed data like cpu maps */
100 . = ALIGN(32);
Vivek Goyal65695802006-12-07 02:14:03 +0100101 .data.read_mostly : AT(ADDR(.data.read_mostly) - LOAD_OFFSET) {
102 *(.data.read_mostly)
103 _edata = .; /* End of data section */
104 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105
106 . = ALIGN(THREAD_SIZE); /* init_task */
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700107 .data.init_task : AT(ADDR(.data.init_task) - LOAD_OFFSET) {
108 *(.data.init_task)
109 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800111 /* might get freed after init */
112 . = ALIGN(4096);
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800113 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100114 __smp_locks = .;
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800115 *(.smp_locks)
Vivek Goyal65695802006-12-07 02:14:03 +0100116 __smp_locks_end = .;
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800117 }
Vivek Goyal6ed01882006-12-07 02:14:03 +0100118 /* will be freed after init
119 * Following ALIGN() is required to make sure no other data falls on the
120 * same page where __smp_alt_end is pointing as that page might be freed
121 * after boot. Always make sure that ALIGN() directive is present after
122 * the section which contains __smp_alt_end.
123 */
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800124 . = 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 }
Rusty Russell139ec7c2006-12-07 02:14:08 +0100161 . = ALIGN(4);
Rusty Russell139ec7c2006-12-07 02:14:08 +0100162 .parainstructions : AT(ADDR(.parainstructions) - LOAD_OFFSET) {
Jeremy Fitzhardinge441d40d2007-05-02 19:27:16 +0200163 __parainstructions = .;
Rusty Russell139ec7c2006-12-07 02:14:08 +0100164 *(.parainstructions)
Jeremy Fitzhardinge441d40d2007-05-02 19:27:16 +0200165 __parainstructions_end = .;
Rusty Russell139ec7c2006-12-07 02:14:08 +0100166 }
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) }
Jean-Paul Saman67d38222007-02-10 01:44:44 -0800171#if defined(CONFIG_BLK_DEV_INITRD)
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 }
Jean-Paul Saman67d38222007-02-10 01:44:44 -0800178#endif
Jeremy Fitzhardingeb6e35902007-05-02 19:27:12 +0200179 . = ALIGN(4096);
Vivek Goyal65695802006-12-07 02:14:03 +0100180 .data.percpu : AT(ADDR(.data.percpu) - LOAD_OFFSET) {
181 __per_cpu_start = .;
182 *(.data.percpu)
183 __per_cpu_end = .;
184 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185 . = ALIGN(4096);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700186 /* freed after init ends here */
187
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700188 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100189 __init_end = .;
190 __bss_start = .; /* BSS */
191 *(.bss.page_aligned)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192 *(.bss)
Vivek Goyal65695802006-12-07 02:14:03 +0100193 . = ALIGN(4);
194 __bss_stop = .;
195 _end = . ;
196 /* This is where the kernel creates the early boot page tables */
197 . = ALIGN(4096);
198 pg0 = . ;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700199 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700200
201 /* Sections to be discarded */
202 /DISCARD/ : {
203 *(.exitcall.exit)
204 }
205
Paolo 'Blaisorblade' Giarrussoa7d0c212005-09-10 19:44:54 +0200206 STABS_DEBUG
207
208 DWARF_DEBUG
Jeremy Fitzhardinge9c9b8b32006-09-25 23:32:26 -0700209
210 NOTES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700211}