blob: 7d72cce0052946c93446eaa279c0d476da80af51 [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
Roland McGrathcbe87122007-07-19 01:48:36 -070063 NOTES :text :note
64
65 BUG_TABLE :text
Jeremy Fitzhardinge91768d62006-12-08 02:36:21 -080066
Linus Torvaldseb71c872006-06-24 14:27:42 -070067 . = ALIGN(4);
Linus Torvaldseb71c872006-06-24 14:27:42 -070068 .tracedata : AT(ADDR(.tracedata) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +010069 __tracedata_start = .;
Linus Torvaldseb71c872006-06-24 14:27:42 -070070 *(.tracedata)
Vivek Goyal65695802006-12-07 02:14:03 +010071 __tracedata_end = .;
Linus Torvaldseb71c872006-06-24 14:27:42 -070072 }
Linus Torvaldseb71c872006-06-24 14:27:42 -070073
Jan Beulich6fb14752007-05-02 19:27:10 +020074 RODATA
75
Linus Torvalds1da177e2005-04-16 15:20:36 -070076 /* writeable */
Vivek Goyalc06cb8b2006-11-08 17:44:41 -080077 . = ALIGN(4096);
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -070078 .data : AT(ADDR(.data) - LOAD_OFFSET) { /* Data */
Sam Ravnborgca967252007-05-17 13:38:44 +020079 DATA_DATA
Linus Torvalds1da177e2005-04-16 15:20:36 -070080 CONSTRUCTORS
Jeremy Fitzhardinge9c9b8b32006-09-25 23:32:26 -070081 } :data
Linus Torvalds1da177e2005-04-16 15:20:36 -070082
83 . = ALIGN(4096);
Vivek Goyal65695802006-12-07 02:14:03 +010084 .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
85 __nosave_begin = .;
86 *(.data.nosave)
87 . = ALIGN(4096);
88 __nosave_end = .;
89 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070090
91 . = ALIGN(4096);
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -070092 .data.page_aligned : AT(ADDR(.data.page_aligned) - LOAD_OFFSET) {
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -070093 *(.data.page_aligned)
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -070094 *(.data.idt)
95 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070096
97 . = ALIGN(32);
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -070098 .data.cacheline_aligned : AT(ADDR(.data.cacheline_aligned) - LOAD_OFFSET) {
99 *(.data.cacheline_aligned)
100 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101
Christoph Lameter6c036522005-07-07 17:56:59 -0700102 /* rarely changed data like cpu maps */
103 . = ALIGN(32);
Vivek Goyal65695802006-12-07 02:14:03 +0100104 .data.read_mostly : AT(ADDR(.data.read_mostly) - LOAD_OFFSET) {
105 *(.data.read_mostly)
106 _edata = .; /* End of data section */
107 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108
109 . = ALIGN(THREAD_SIZE); /* init_task */
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700110 .data.init_task : AT(ADDR(.data.init_task) - LOAD_OFFSET) {
111 *(.data.init_task)
112 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800114 /* might get freed after init */
115 . = ALIGN(4096);
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 }
Vivek Goyal6ed01882006-12-07 02:14:03 +0100121 /* will be freed after init
122 * Following ALIGN() is required to make sure no other data falls on the
123 * same page where __smp_alt_end is pointing as that page might be freed
124 * after boot. Always make sure that ALIGN() directive is present after
125 * the section which contains __smp_alt_end.
126 */
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800127 . = ALIGN(4096);
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800128
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129 /* will be freed after init */
130 . = ALIGN(4096); /* Init code and data */
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700131 .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100132 __init_begin = .;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133 _sinittext = .;
134 *(.init.text)
135 _einittext = .;
136 }
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700137 .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) { *(.init.data) }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138 . = ALIGN(16);
Vivek Goyal65695802006-12-07 02:14:03 +0100139 .init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) {
140 __setup_start = .;
141 *(.init.setup)
142 __setup_end = .;
143 }
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700144 .initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100145 __initcall_start = .;
Andrew Morton61ce1ef2006-10-27 11:41:44 -0700146 INITCALLS
Vivek Goyal65695802006-12-07 02:14:03 +0100147 __initcall_end = .;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148 }
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700149 .con_initcall.init : AT(ADDR(.con_initcall.init) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100150 __con_initcall_start = .;
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700151 *(.con_initcall.init)
Vivek Goyal65695802006-12-07 02:14:03 +0100152 __con_initcall_end = .;
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700153 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154 SECURITY_INIT
155 . = ALIGN(4);
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700156 .altinstructions : AT(ADDR(.altinstructions) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100157 __alt_instructions = .;
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700158 *(.altinstructions)
Vivek Goyal65695802006-12-07 02:14:03 +0100159 __alt_instructions_end = .;
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700160 }
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700161 .altinstr_replacement : AT(ADDR(.altinstr_replacement) - LOAD_OFFSET) {
162 *(.altinstr_replacement)
163 }
Rusty Russell139ec7c2006-12-07 02:14:08 +0100164 . = ALIGN(4);
Rusty Russell139ec7c2006-12-07 02:14:08 +0100165 .parainstructions : AT(ADDR(.parainstructions) - LOAD_OFFSET) {
Jeremy Fitzhardinge441d40d2007-05-02 19:27:16 +0200166 __parainstructions = .;
Rusty Russell139ec7c2006-12-07 02:14:08 +0100167 *(.parainstructions)
Jeremy Fitzhardinge441d40d2007-05-02 19:27:16 +0200168 __parainstructions_end = .;
Rusty Russell139ec7c2006-12-07 02:14:08 +0100169 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170 /* .exit.text is discard at runtime, not link time, to deal with references
171 from .altinstructions and .eh_frame */
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700172 .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) { *(.exit.text) }
173 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) { *(.exit.data) }
Jean-Paul Saman67d38222007-02-10 01:44:44 -0800174#if defined(CONFIG_BLK_DEV_INITRD)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700175 . = ALIGN(4096);
Vivek Goyal65695802006-12-07 02:14:03 +0100176 .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) {
177 __initramfs_start = .;
178 *(.init.ramfs)
179 __initramfs_end = .;
180 }
Jean-Paul Saman67d38222007-02-10 01:44:44 -0800181#endif
Jeremy Fitzhardingeb6e35902007-05-02 19:27:12 +0200182 . = ALIGN(4096);
Vivek Goyal65695802006-12-07 02:14:03 +0100183 .data.percpu : AT(ADDR(.data.percpu) - LOAD_OFFSET) {
184 __per_cpu_start = .;
185 *(.data.percpu)
Fenghua Yu5fb7dc32007-07-19 01:48:12 -0700186 *(.data.percpu.shared_aligned)
Vivek Goyal65695802006-12-07 02:14:03 +0100187 __per_cpu_end = .;
188 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700189 . = ALIGN(4096);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190 /* freed after init ends here */
191
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700192 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100193 __init_end = .;
194 __bss_start = .; /* BSS */
195 *(.bss.page_aligned)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196 *(.bss)
Vivek Goyal65695802006-12-07 02:14:03 +0100197 . = ALIGN(4);
198 __bss_stop = .;
199 _end = . ;
200 /* This is where the kernel creates the early boot page tables */
201 . = ALIGN(4096);
202 pg0 = . ;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700204
205 /* Sections to be discarded */
206 /DISCARD/ : {
207 *(.exitcall.exit)
208 }
209
Paolo 'Blaisorblade' Giarrussoa7d0c212005-09-10 19:44:54 +0200210 STABS_DEBUG
211
212 DWARF_DEBUG
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213}