blob: 568caca877156d354c3c2e20e43c7f91e756d5d9 [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 */
33 note PT_NOTE FLAGS(4); /* R__ */
34}
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) {
Linus Torvalds1da177e2005-04-16 15:20:36 -070047 *(.text)
48 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 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070077 *(.data)
78 CONSTRUCTORS
Jeremy Fitzhardinge9c9b8b32006-09-25 23:32:26 -070079 } :data
Linus Torvalds1da177e2005-04-16 15:20:36 -070080
Rusty Russellc9ccf302006-12-07 02:14:08 +010081 .paravirtprobe : AT(ADDR(.paravirtprobe) - LOAD_OFFSET) {
Vivek Goyal79929fd2006-12-07 02:14:10 +010082 __start_paravirtprobe = .;
Rusty Russellc9ccf302006-12-07 02:14:08 +010083 *(.paravirtprobe)
Vivek Goyal79929fd2006-12-07 02:14:10 +010084 __stop_paravirtprobe = .;
Rusty Russellc9ccf302006-12-07 02:14:08 +010085 }
Rusty Russellc9ccf302006-12-07 02:14:08 +010086
Linus Torvalds1da177e2005-04-16 15:20:36 -070087 . = ALIGN(4096);
Vivek Goyal65695802006-12-07 02:14:03 +010088 .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
89 __nosave_begin = .;
90 *(.data.nosave)
91 . = ALIGN(4096);
92 __nosave_end = .;
93 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070094
95 . = ALIGN(4096);
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -070096 .data.page_aligned : AT(ADDR(.data.page_aligned) - LOAD_OFFSET) {
97 *(.data.idt)
98 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070099
100 . = ALIGN(32);
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700101 .data.cacheline_aligned : AT(ADDR(.data.cacheline_aligned) - LOAD_OFFSET) {
102 *(.data.cacheline_aligned)
103 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104
Christoph Lameter6c036522005-07-07 17:56:59 -0700105 /* rarely changed data like cpu maps */
106 . = ALIGN(32);
Vivek Goyal65695802006-12-07 02:14:03 +0100107 .data.read_mostly : AT(ADDR(.data.read_mostly) - LOAD_OFFSET) {
108 *(.data.read_mostly)
109 _edata = .; /* End of data section */
110 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111
112 . = ALIGN(THREAD_SIZE); /* init_task */
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700113 .data.init_task : AT(ADDR(.data.init_task) - LOAD_OFFSET) {
114 *(.data.init_task)
115 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800117 /* might get freed after init */
118 . = ALIGN(4096);
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800119 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100120 __smp_locks = .;
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800121 *(.smp_locks)
Vivek Goyal65695802006-12-07 02:14:03 +0100122 __smp_locks_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 }
Rusty Russell139ec7c2006-12-07 02:14:08 +0100167 . = ALIGN(4);
Rusty Russell139ec7c2006-12-07 02:14:08 +0100168 .parainstructions : AT(ADDR(.parainstructions) - LOAD_OFFSET) {
Jeremy Fitzhardinge441d40d2007-05-02 19:27:16 +0200169 __parainstructions = .;
Rusty Russell139ec7c2006-12-07 02:14:08 +0100170 *(.parainstructions)
Jeremy Fitzhardinge441d40d2007-05-02 19:27:16 +0200171 __parainstructions_end = .;
Rusty Russell139ec7c2006-12-07 02:14:08 +0100172 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173 /* .exit.text is discard at runtime, not link time, to deal with references
174 from .altinstructions and .eh_frame */
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700175 .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) { *(.exit.text) }
176 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) { *(.exit.data) }
Jean-Paul Saman67d38222007-02-10 01:44:44 -0800177#if defined(CONFIG_BLK_DEV_INITRD)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700178 . = ALIGN(4096);
Vivek Goyal65695802006-12-07 02:14:03 +0100179 .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) {
180 __initramfs_start = .;
181 *(.init.ramfs)
182 __initramfs_end = .;
183 }
Jean-Paul Saman67d38222007-02-10 01:44:44 -0800184#endif
Jeremy Fitzhardingeb6e35902007-05-02 19:27:12 +0200185 . = ALIGN(4096);
Vivek Goyal65695802006-12-07 02:14:03 +0100186 .data.percpu : AT(ADDR(.data.percpu) - LOAD_OFFSET) {
187 __per_cpu_start = .;
188 *(.data.percpu)
189 __per_cpu_end = .;
190 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191 . = ALIGN(4096);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192 /* freed after init ends here */
193
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700194 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100195 __init_end = .;
196 __bss_start = .; /* BSS */
197 *(.bss.page_aligned)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198 *(.bss)
Vivek Goyal65695802006-12-07 02:14:03 +0100199 . = ALIGN(4);
200 __bss_stop = .;
201 _end = . ;
202 /* This is where the kernel creates the early boot page tables */
203 . = ALIGN(4096);
204 pg0 = . ;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700205 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700206
207 /* Sections to be discarded */
208 /DISCARD/ : {
209 *(.exitcall.exit)
210 }
211
Paolo 'Blaisorblade' Giarrussoa7d0c212005-09-10 19:44:54 +0200212 STABS_DEBUG
213
214 DWARF_DEBUG
Jeremy Fitzhardinge9c9b8b32006-09-25 23:32:26 -0700215
216 NOTES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700217}