blob: 5038a73d554e18df68cc097c5f77431ddf50a5b5 [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;
Andi Kleen1bac3b32006-12-09 21:33:36 +010029_proxy_pda = 0;
Jeremy Fitzhardinge9c9b8b32006-09-25 23:32:26 -070030
31PHDRS {
32 text PT_LOAD FLAGS(5); /* R_E */
33 data PT_LOAD FLAGS(7); /* RWE */
34 note PT_NOTE FLAGS(4); /* R__ */
35}
Linus Torvalds1da177e2005-04-16 15:20:36 -070036SECTIONS
37{
Vivek Goyale69f2022006-12-07 02:14:04 +010038 . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -070039 phys_startup_32 = startup_32 - LOAD_OFFSET;
Linus Torvalds1da177e2005-04-16 15:20:36 -070040 /* read-only */
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -070041 .text : AT(ADDR(.text) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +010042 _text = .; /* Text and read-only data */
Linus Torvalds1da177e2005-04-16 15:20:36 -070043 *(.text)
44 SCHED_TEXT
45 LOCK_TEXT
Prasanna S Panchamukhi3d97ae52005-09-06 15:19:27 -070046 KPROBES_TEXT
Linus Torvalds1da177e2005-04-16 15:20:36 -070047 *(.fixup)
48 *(.gnu.warning)
Vivek Goyal65695802006-12-07 02:14:03 +010049 _etext = .; /* End of text section */
50 } :text = 0x9090
Linus Torvalds1da177e2005-04-16 15:20:36 -070051
52 . = ALIGN(16); /* Exception table */
Vivek Goyal65695802006-12-07 02:14:03 +010053 __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {
54 __start___ex_table = .;
55 *(__ex_table)
56 __stop___ex_table = .;
57 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070058
59 RODATA
60
Jeremy Fitzhardinge91768d62006-12-08 02:36:21 -080061 BUG_TABLE
62
Linus Torvaldseb71c872006-06-24 14:27:42 -070063 . = ALIGN(4);
Linus Torvaldseb71c872006-06-24 14:27:42 -070064 .tracedata : AT(ADDR(.tracedata) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +010065 __tracedata_start = .;
Linus Torvaldseb71c872006-06-24 14:27:42 -070066 *(.tracedata)
Vivek Goyal65695802006-12-07 02:14:03 +010067 __tracedata_end = .;
Linus Torvaldseb71c872006-06-24 14:27:42 -070068 }
Linus Torvaldseb71c872006-06-24 14:27:42 -070069
Linus Torvalds1da177e2005-04-16 15:20:36 -070070 /* writeable */
Vivek Goyalc06cb8b2006-11-08 17:44:41 -080071 . = ALIGN(4096);
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -070072 .data : AT(ADDR(.data) - LOAD_OFFSET) { /* Data */
Linus Torvalds1da177e2005-04-16 15:20:36 -070073 *(.data)
74 CONSTRUCTORS
Jeremy Fitzhardinge9c9b8b32006-09-25 23:32:26 -070075 } :data
Linus Torvalds1da177e2005-04-16 15:20:36 -070076
Rusty Russellc9ccf302006-12-07 02:14:08 +010077 .paravirtprobe : AT(ADDR(.paravirtprobe) - LOAD_OFFSET) {
Vivek Goyal79929fd2006-12-07 02:14:10 +010078 __start_paravirtprobe = .;
Rusty Russellc9ccf302006-12-07 02:14:08 +010079 *(.paravirtprobe)
Vivek Goyal79929fd2006-12-07 02:14:10 +010080 __stop_paravirtprobe = .;
Rusty Russellc9ccf302006-12-07 02:14:08 +010081 }
Rusty Russellc9ccf302006-12-07 02:14:08 +010082
Linus Torvalds1da177e2005-04-16 15:20:36 -070083 . = 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) {
93 *(.data.idt)
94 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070095
96 . = ALIGN(32);
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -070097 .data.cacheline_aligned : AT(ADDR(.data.cacheline_aligned) - LOAD_OFFSET) {
98 *(.data.cacheline_aligned)
99 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100
Christoph Lameter6c036522005-07-07 17:56:59 -0700101 /* rarely changed data like cpu maps */
102 . = ALIGN(32);
Vivek Goyal65695802006-12-07 02:14:03 +0100103 .data.read_mostly : AT(ADDR(.data.read_mostly) - LOAD_OFFSET) {
104 *(.data.read_mostly)
105 _edata = .; /* End of data section */
106 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107
108 . = ALIGN(THREAD_SIZE); /* init_task */
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700109 .data.init_task : AT(ADDR(.data.init_task) - LOAD_OFFSET) {
110 *(.data.init_task)
111 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800113 /* might get freed after init */
114 . = ALIGN(4096);
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800115 .smp_altinstructions : AT(ADDR(.smp_altinstructions) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100116 __smp_alt_begin = .;
117 __smp_alt_instructions = .;
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800118 *(.smp_altinstructions)
Vivek Goyal65695802006-12-07 02:14:03 +0100119 __smp_alt_instructions_end = .;
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800120 }
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800121 . = ALIGN(4);
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800122 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100123 __smp_locks = .;
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800124 *(.smp_locks)
Vivek Goyal65695802006-12-07 02:14:03 +0100125 __smp_locks_end = .;
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800126 }
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800127 .smp_altinstr_replacement : AT(ADDR(.smp_altinstr_replacement) - LOAD_OFFSET) {
128 *(.smp_altinstr_replacement)
Vivek Goyal65695802006-12-07 02:14:03 +0100129 __smp_alt_end = .;
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800130 }
Vivek Goyal6ed01882006-12-07 02:14:03 +0100131 /* will be freed after init
132 * Following ALIGN() is required to make sure no other data falls on the
133 * same page where __smp_alt_end is pointing as that page might be freed
134 * after boot. Always make sure that ALIGN() directive is present after
135 * the section which contains __smp_alt_end.
136 */
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800137 . = ALIGN(4096);
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800138
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139 /* will be freed after init */
140 . = ALIGN(4096); /* Init code and data */
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700141 .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100142 __init_begin = .;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143 _sinittext = .;
144 *(.init.text)
145 _einittext = .;
146 }
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700147 .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) { *(.init.data) }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148 . = ALIGN(16);
Vivek Goyal65695802006-12-07 02:14:03 +0100149 .init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) {
150 __setup_start = .;
151 *(.init.setup)
152 __setup_end = .;
153 }
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700154 .initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100155 __initcall_start = .;
Andrew Morton61ce1ef2006-10-27 11:41:44 -0700156 INITCALLS
Vivek Goyal65695802006-12-07 02:14:03 +0100157 __initcall_end = .;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700158 }
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700159 .con_initcall.init : AT(ADDR(.con_initcall.init) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100160 __con_initcall_start = .;
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700161 *(.con_initcall.init)
Vivek Goyal65695802006-12-07 02:14:03 +0100162 __con_initcall_end = .;
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700163 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164 SECURITY_INIT
165 . = ALIGN(4);
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700166 .altinstructions : AT(ADDR(.altinstructions) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100167 __alt_instructions = .;
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700168 *(.altinstructions)
Vivek Goyal65695802006-12-07 02:14:03 +0100169 __alt_instructions_end = .;
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700170 }
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700171 .altinstr_replacement : AT(ADDR(.altinstr_replacement) - LOAD_OFFSET) {
172 *(.altinstr_replacement)
173 }
Rusty Russell139ec7c2006-12-07 02:14:08 +0100174 . = ALIGN(4);
Rusty Russell139ec7c2006-12-07 02:14:08 +0100175 .parainstructions : AT(ADDR(.parainstructions) - LOAD_OFFSET) {
Vivek Goyal79929fd2006-12-07 02:14:10 +0100176 __start_parainstructions = .;
Rusty Russell139ec7c2006-12-07 02:14:08 +0100177 *(.parainstructions)
Vivek Goyal79929fd2006-12-07 02:14:10 +0100178 __stop_parainstructions = .;
Rusty Russell139ec7c2006-12-07 02:14:08 +0100179 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700180 /* .exit.text is discard at runtime, not link time, to deal with references
181 from .altinstructions and .eh_frame */
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700182 .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) { *(.exit.text) }
183 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) { *(.exit.data) }
Jean-Paul Saman67d38222007-02-10 01:44:44 -0800184#if defined(CONFIG_BLK_DEV_INITRD)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185 . = ALIGN(4096);
Vivek Goyal65695802006-12-07 02:14:03 +0100186 .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) {
187 __initramfs_start = .;
188 *(.init.ramfs)
189 __initramfs_end = .;
190 }
Jean-Paul Saman67d38222007-02-10 01:44:44 -0800191#endif
Zach Brown379b5442006-01-27 14:02:47 -0800192 . = ALIGN(L1_CACHE_BYTES);
Vivek Goyal65695802006-12-07 02:14:03 +0100193 .data.percpu : AT(ADDR(.data.percpu) - LOAD_OFFSET) {
194 __per_cpu_start = .;
195 *(.data.percpu)
196 __per_cpu_end = .;
197 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198 . = ALIGN(4096);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700199 /* freed after init ends here */
200
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700201 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100202 __init_end = .;
203 __bss_start = .; /* BSS */
204 *(.bss.page_aligned)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700205 *(.bss)
Vivek Goyal65695802006-12-07 02:14:03 +0100206 . = ALIGN(4);
207 __bss_stop = .;
208 _end = . ;
209 /* This is where the kernel creates the early boot page tables */
210 . = ALIGN(4096);
211 pg0 = . ;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213
214 /* Sections to be discarded */
215 /DISCARD/ : {
216 *(.exitcall.exit)
217 }
218
Paolo 'Blaisorblade' Giarrussoa7d0c212005-09-10 19:44:54 +0200219 STABS_DEBUG
220
221 DWARF_DEBUG
Jeremy Fitzhardinge9c9b8b32006-09-25 23:32:26 -0700222
223 NOTES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700224}