blob: 16d3c7133ad79364a9c1a805a84e3fa9abf20ade [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;
Linus Torvalds1da177e2005-04-16 15:20:36 -070039 /* read-only */
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -070040 .text : AT(ADDR(.text) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +010041 _text = .; /* Text and read-only data */
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 *(.text)
43 SCHED_TEXT
44 LOCK_TEXT
Prasanna S Panchamukhi3d97ae52005-09-06 15:19:27 -070045 KPROBES_TEXT
Linus Torvalds1da177e2005-04-16 15:20:36 -070046 *(.fixup)
47 *(.gnu.warning)
Vivek Goyal65695802006-12-07 02:14:03 +010048 _etext = .; /* End of text section */
49 } :text = 0x9090
Linus Torvalds1da177e2005-04-16 15:20:36 -070050
51 . = ALIGN(16); /* Exception table */
Vivek Goyal65695802006-12-07 02:14:03 +010052 __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {
53 __start___ex_table = .;
54 *(__ex_table)
55 __stop___ex_table = .;
56 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070057
58 RODATA
59
Jeremy Fitzhardinge91768d62006-12-08 02:36:21 -080060 BUG_TABLE
61
Linus Torvaldseb71c872006-06-24 14:27:42 -070062 . = ALIGN(4);
Linus Torvaldseb71c872006-06-24 14:27:42 -070063 .tracedata : AT(ADDR(.tracedata) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +010064 __tracedata_start = .;
Linus Torvaldseb71c872006-06-24 14:27:42 -070065 *(.tracedata)
Vivek Goyal65695802006-12-07 02:14:03 +010066 __tracedata_end = .;
Linus Torvaldseb71c872006-06-24 14:27:42 -070067 }
Linus Torvaldseb71c872006-06-24 14:27:42 -070068
Linus Torvalds1da177e2005-04-16 15:20:36 -070069 /* writeable */
Vivek Goyalc06cb8b2006-11-08 17:44:41 -080070 . = ALIGN(4096);
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -070071 .data : AT(ADDR(.data) - LOAD_OFFSET) { /* Data */
Linus Torvalds1da177e2005-04-16 15:20:36 -070072 *(.data)
73 CONSTRUCTORS
Jeremy Fitzhardinge9c9b8b32006-09-25 23:32:26 -070074 } :data
Linus Torvalds1da177e2005-04-16 15:20:36 -070075
Rusty Russellc9ccf302006-12-07 02:14:08 +010076 .paravirtprobe : AT(ADDR(.paravirtprobe) - LOAD_OFFSET) {
Vivek Goyal79929fd2006-12-07 02:14:10 +010077 __start_paravirtprobe = .;
Rusty Russellc9ccf302006-12-07 02:14:08 +010078 *(.paravirtprobe)
Vivek Goyal79929fd2006-12-07 02:14:10 +010079 __stop_paravirtprobe = .;
Rusty Russellc9ccf302006-12-07 02:14:08 +010080 }
Rusty Russellc9ccf302006-12-07 02:14:08 +010081
Linus Torvalds1da177e2005-04-16 15:20:36 -070082 . = ALIGN(4096);
Vivek Goyal65695802006-12-07 02:14:03 +010083 .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
84 __nosave_begin = .;
85 *(.data.nosave)
86 . = ALIGN(4096);
87 __nosave_end = .;
88 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070089
90 . = ALIGN(4096);
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -070091 .data.page_aligned : AT(ADDR(.data.page_aligned) - LOAD_OFFSET) {
92 *(.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_altinstructions : AT(ADDR(.smp_altinstructions) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100115 __smp_alt_begin = .;
116 __smp_alt_instructions = .;
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800117 *(.smp_altinstructions)
Vivek Goyal65695802006-12-07 02:14:03 +0100118 __smp_alt_instructions_end = .;
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800119 }
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800120 . = ALIGN(4);
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800121 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100122 __smp_locks = .;
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800123 *(.smp_locks)
Vivek Goyal65695802006-12-07 02:14:03 +0100124 __smp_locks_end = .;
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800125 }
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800126 .smp_altinstr_replacement : AT(ADDR(.smp_altinstr_replacement) - LOAD_OFFSET) {
127 *(.smp_altinstr_replacement)
Vivek Goyal65695802006-12-07 02:14:03 +0100128 __smp_alt_end = .;
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800129 }
Vivek Goyal6ed01882006-12-07 02:14:03 +0100130 /* will be freed after init
131 * Following ALIGN() is required to make sure no other data falls on the
132 * same page where __smp_alt_end is pointing as that page might be freed
133 * after boot. Always make sure that ALIGN() directive is present after
134 * the section which contains __smp_alt_end.
135 */
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800136 . = ALIGN(4096);
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800137
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138 /* will be freed after init */
139 . = ALIGN(4096); /* Init code and data */
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700140 .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100141 __init_begin = .;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142 _sinittext = .;
143 *(.init.text)
144 _einittext = .;
145 }
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700146 .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) { *(.init.data) }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147 . = ALIGN(16);
Vivek Goyal65695802006-12-07 02:14:03 +0100148 .init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) {
149 __setup_start = .;
150 *(.init.setup)
151 __setup_end = .;
152 }
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700153 .initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100154 __initcall_start = .;
Andrew Morton61ce1ef2006-10-27 11:41:44 -0700155 INITCALLS
Vivek Goyal65695802006-12-07 02:14:03 +0100156 __initcall_end = .;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157 }
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700158 .con_initcall.init : AT(ADDR(.con_initcall.init) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100159 __con_initcall_start = .;
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700160 *(.con_initcall.init)
Vivek Goyal65695802006-12-07 02:14:03 +0100161 __con_initcall_end = .;
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700162 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163 SECURITY_INIT
164 . = ALIGN(4);
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700165 .altinstructions : AT(ADDR(.altinstructions) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100166 __alt_instructions = .;
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700167 *(.altinstructions)
Vivek Goyal65695802006-12-07 02:14:03 +0100168 __alt_instructions_end = .;
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700169 }
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700170 .altinstr_replacement : AT(ADDR(.altinstr_replacement) - LOAD_OFFSET) {
171 *(.altinstr_replacement)
172 }
Rusty Russell139ec7c2006-12-07 02:14:08 +0100173 . = ALIGN(4);
Rusty Russell139ec7c2006-12-07 02:14:08 +0100174 .parainstructions : AT(ADDR(.parainstructions) - LOAD_OFFSET) {
Vivek Goyal79929fd2006-12-07 02:14:10 +0100175 __start_parainstructions = .;
Rusty Russell139ec7c2006-12-07 02:14:08 +0100176 *(.parainstructions)
Vivek Goyal79929fd2006-12-07 02:14:10 +0100177 __stop_parainstructions = .;
Rusty Russell139ec7c2006-12-07 02:14:08 +0100178 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179 /* .exit.text is discard at runtime, not link time, to deal with references
180 from .altinstructions and .eh_frame */
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700181 .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) { *(.exit.text) }
182 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) { *(.exit.data) }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700183 . = ALIGN(4096);
Vivek Goyal65695802006-12-07 02:14:03 +0100184 .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) {
185 __initramfs_start = .;
186 *(.init.ramfs)
187 __initramfs_end = .;
188 }
Zach Brown379b5442006-01-27 14:02:47 -0800189 . = ALIGN(L1_CACHE_BYTES);
Vivek Goyal65695802006-12-07 02:14:03 +0100190 .data.percpu : AT(ADDR(.data.percpu) - LOAD_OFFSET) {
191 __per_cpu_start = .;
192 *(.data.percpu)
193 __per_cpu_end = .;
194 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195 . = ALIGN(4096);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196 /* freed after init ends here */
197
Eric W. Biedermanad0d75e2005-06-25 14:57:47 -0700198 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
Vivek Goyal65695802006-12-07 02:14:03 +0100199 __init_end = .;
200 __bss_start = .; /* BSS */
201 *(.bss.page_aligned)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700202 *(.bss)
Vivek Goyal65695802006-12-07 02:14:03 +0100203 . = ALIGN(4);
204 __bss_stop = .;
205 _end = . ;
206 /* This is where the kernel creates the early boot page tables */
207 . = ALIGN(4096);
208 pg0 = . ;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210
211 /* Sections to be discarded */
212 /DISCARD/ : {
213 *(.exitcall.exit)
214 }
215
Paolo 'Blaisorblade' Giarrussoa7d0c212005-09-10 19:44:54 +0200216 STABS_DEBUG
217
218 DWARF_DEBUG
Jeremy Fitzhardinge9c9b8b32006-09-25 23:32:26 -0700219
220 NOTES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700221}