blob: 4dc44b8007ccbe9ea8c44f5e96e33f50b2da4b50 [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) {
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -070091 *(.data.page_aligned)
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -070092 *(.data.idt)
93 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070094
95 . = ALIGN(32);
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -070096 .data.cacheline_aligned : AT(ADDR(.data.cacheline_aligned) - LOAD_OFFSET) {
97 *(.data.cacheline_aligned)
98 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070099
Christoph Lameter6c036522005-07-07 17:56:59 -0700100 /* rarely changed data like cpu maps */
101 . = ALIGN(32);
Vivek Goyal65695802006-12-07 02:14:03 +0100102 .data.read_mostly : AT(ADDR(.data.read_mostly) - LOAD_OFFSET) {
103 *(.data.read_mostly)
104 _edata = .; /* End of data section */
105 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106
107 . = ALIGN(THREAD_SIZE); /* init_task */
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700108 .data.init_task : AT(ADDR(.data.init_task) - LOAD_OFFSET) {
109 *(.data.init_task)
110 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800112 /* might get freed after init */
113 . = ALIGN(4096);
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800114 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100115 __smp_locks = .;
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800116 *(.smp_locks)
Vivek Goyal65695802006-12-07 02:14:03 +0100117 __smp_locks_end = .;
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800118 }
Vivek Goyal6ed01882006-12-07 02:14:03 +0100119 /* will be freed after init
120 * Following ALIGN() is required to make sure no other data falls on the
121 * same page where __smp_alt_end is pointing as that page might be freed
122 * after boot. Always make sure that ALIGN() directive is present after
123 * the section which contains __smp_alt_end.
124 */
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800125 . = ALIGN(4096);
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800126
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127 /* will be freed after init */
128 . = ALIGN(4096); /* Init code and data */
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700129 .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100130 __init_begin = .;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131 _sinittext = .;
132 *(.init.text)
133 _einittext = .;
134 }
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700135 .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) { *(.init.data) }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136 . = ALIGN(16);
Vivek Goyal65695802006-12-07 02:14:03 +0100137 .init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) {
138 __setup_start = .;
139 *(.init.setup)
140 __setup_end = .;
141 }
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700142 .initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100143 __initcall_start = .;
Andrew Morton61ce1ef2006-10-27 11:41:44 -0700144 INITCALLS
Vivek Goyal65695802006-12-07 02:14:03 +0100145 __initcall_end = .;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146 }
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700147 .con_initcall.init : AT(ADDR(.con_initcall.init) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100148 __con_initcall_start = .;
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700149 *(.con_initcall.init)
Vivek Goyal65695802006-12-07 02:14:03 +0100150 __con_initcall_end = .;
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700151 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152 SECURITY_INIT
153 . = ALIGN(4);
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700154 .altinstructions : AT(ADDR(.altinstructions) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100155 __alt_instructions = .;
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700156 *(.altinstructions)
Vivek Goyal65695802006-12-07 02:14:03 +0100157 __alt_instructions_end = .;
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700158 }
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700159 .altinstr_replacement : AT(ADDR(.altinstr_replacement) - LOAD_OFFSET) {
160 *(.altinstr_replacement)
161 }
Rusty Russell139ec7c2006-12-07 02:14:08 +0100162 . = ALIGN(4);
Rusty Russell139ec7c2006-12-07 02:14:08 +0100163 .parainstructions : AT(ADDR(.parainstructions) - LOAD_OFFSET) {
Jeremy Fitzhardinge441d40d2007-05-02 19:27:16 +0200164 __parainstructions = .;
Rusty Russell139ec7c2006-12-07 02:14:08 +0100165 *(.parainstructions)
Jeremy Fitzhardinge441d40d2007-05-02 19:27:16 +0200166 __parainstructions_end = .;
Rusty Russell139ec7c2006-12-07 02:14:08 +0100167 }
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) }
Jean-Paul Saman67d38222007-02-10 01:44:44 -0800172#if defined(CONFIG_BLK_DEV_INITRD)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173 . = ALIGN(4096);
Vivek Goyal65695802006-12-07 02:14:03 +0100174 .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) {
175 __initramfs_start = .;
176 *(.init.ramfs)
177 __initramfs_end = .;
178 }
Jean-Paul Saman67d38222007-02-10 01:44:44 -0800179#endif
Jeremy Fitzhardingeb6e35902007-05-02 19:27:12 +0200180 . = ALIGN(4096);
Vivek Goyal65695802006-12-07 02:14:03 +0100181 .data.percpu : AT(ADDR(.data.percpu) - LOAD_OFFSET) {
182 __per_cpu_start = .;
183 *(.data.percpu)
Fenghua Yu5fb7dc32007-07-19 01:48:12 -0700184 *(.data.percpu.shared_aligned)
Vivek Goyal65695802006-12-07 02:14:03 +0100185 __per_cpu_end = .;
186 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700187 . = ALIGN(4096);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188 /* freed after init ends here */
189
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700190 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100191 __init_end = .;
192 __bss_start = .; /* BSS */
193 *(.bss.page_aligned)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194 *(.bss)
Vivek Goyal65695802006-12-07 02:14:03 +0100195 . = ALIGN(4);
196 __bss_stop = .;
197 _end = . ;
198 /* This is where the kernel creates the early boot page tables */
199 . = ALIGN(4096);
200 pg0 = . ;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700201 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700202
203 /* Sections to be discarded */
204 /DISCARD/ : {
205 *(.exitcall.exit)
206 }
207
Paolo 'Blaisorblade' Giarrussoa7d0c212005-09-10 19:44:54 +0200208 STABS_DEBUG
209
210 DWARF_DEBUG
Jeremy Fitzhardinge9c9b8b32006-09-25 23:32:26 -0700211
212 NOTES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213}