blob: aa0855471c797bde4ab6f7f1527a845c72a91a19 [file] [log] [blame]
Thomas Gleixnera60b7782007-10-11 11:12:11 +02001/* ld script to make i386 Linux kernel
2 * Written by Martin Mares <mj@atrey.karlin.mff.cuni.cz>;
3 *
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.
9 */
10
Thomas Gleixnera60b7782007-10-11 11:12:11 +020011#define LOAD_OFFSET __PAGE_OFFSET
12
13#include <asm-generic/vmlinux.lds.h>
14#include <asm/thread_info.h>
15#include <asm/page.h>
16#include <asm/cache.h>
17#include <asm/boot.h>
18
19OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
20OUTPUT_ARCH(i386)
21ENTRY(phys_startup_32)
22jiffies = jiffies_64;
23
24PHDRS {
25 text PT_LOAD FLAGS(5); /* R_E */
26 data PT_LOAD FLAGS(7); /* RWE */
27 note PT_NOTE FLAGS(0); /* ___ */
28}
29SECTIONS
30{
31 . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
32 phys_startup_32 = startup_32 - LOAD_OFFSET;
33
34 .text.head : AT(ADDR(.text.head) - LOAD_OFFSET) {
35 _text = .; /* Text and read-only data */
36 *(.text.head)
37 } :text = 0x9090
38
39 /* read-only */
40 .text : AT(ADDR(.text) - LOAD_OFFSET) {
Cyrill Gorcunov3cdac412008-02-17 18:17:17 +030041 . = ALIGN(PAGE_SIZE); /* not really needed, already page aligned */
Eric Dumazet4c491562008-01-30 13:32:50 +010042 *(.text.page_aligned)
Thomas Gleixnera60b7782007-10-11 11:12:11 +020043 TEXT_TEXT
44 SCHED_TEXT
45 LOCK_TEXT
46 KPROBES_TEXT
47 *(.fixup)
48 *(.gnu.warning)
49 _etext = .; /* End of text section */
50 } :text = 0x9090
51
Jan Beulich6360b1f2008-05-12 15:44:41 +020052 NOTES :text :note
53
Thomas Gleixnera60b7782007-10-11 11:12:11 +020054 . = ALIGN(16); /* Exception table */
55 __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {
56 __start___ex_table = .;
57 *(__ex_table)
58 __stop___ex_table = .;
Jan Beulich6360b1f2008-05-12 15:44:41 +020059 } :text = 0x9090
Thomas Gleixnera60b7782007-10-11 11:12:11 +020060
61 . = ALIGN(4);
62 .tracedata : AT(ADDR(.tracedata) - LOAD_OFFSET) {
63 __tracedata_start = .;
64 *(.tracedata)
65 __tracedata_end = .;
66 }
67
68 RODATA
69
70 /* writeable */
Cyrill Gorcunov3cdac412008-02-17 18:17:17 +030071 . = ALIGN(PAGE_SIZE);
Thomas Gleixnera60b7782007-10-11 11:12:11 +020072 .data : AT(ADDR(.data) - LOAD_OFFSET) { /* Data */
73 DATA_DATA
74 CONSTRUCTORS
75 } :data
76
Cyrill Gorcunov3cdac412008-02-17 18:17:17 +030077 . = ALIGN(PAGE_SIZE);
Thomas Gleixnera60b7782007-10-11 11:12:11 +020078 .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
79 __nosave_begin = .;
80 *(.data.nosave)
Cyrill Gorcunov3cdac412008-02-17 18:17:17 +030081 . = ALIGN(PAGE_SIZE);
Thomas Gleixnera60b7782007-10-11 11:12:11 +020082 __nosave_end = .;
83 }
84
Cyrill Gorcunov3cdac412008-02-17 18:17:17 +030085 . = ALIGN(PAGE_SIZE);
Thomas Gleixnera60b7782007-10-11 11:12:11 +020086 .data.page_aligned : AT(ADDR(.data.page_aligned) - LOAD_OFFSET) {
87 *(.data.page_aligned)
88 *(.data.idt)
89 }
90
91 . = ALIGN(32);
92 .data.cacheline_aligned : AT(ADDR(.data.cacheline_aligned) - LOAD_OFFSET) {
93 *(.data.cacheline_aligned)
94 }
95
96 /* rarely changed data like cpu maps */
97 . = ALIGN(32);
98 .data.read_mostly : AT(ADDR(.data.read_mostly) - LOAD_OFFSET) {
99 *(.data.read_mostly)
100 _edata = .; /* End of data section */
101 }
102
103 . = ALIGN(THREAD_SIZE); /* init_task */
104 .data.init_task : AT(ADDR(.data.init_task) - LOAD_OFFSET) {
105 *(.data.init_task)
106 }
107
108 /* might get freed after init */
Cyrill Gorcunov3cdac412008-02-17 18:17:17 +0300109 . = ALIGN(PAGE_SIZE);
Thomas Gleixnera60b7782007-10-11 11:12:11 +0200110 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
111 __smp_locks = .;
112 *(.smp_locks)
113 __smp_locks_end = .;
114 }
115 /* will be freed after init
116 * Following ALIGN() is required to make sure no other data falls on the
117 * same page where __smp_alt_end is pointing as that page might be freed
118 * after boot. Always make sure that ALIGN() directive is present after
119 * the section which contains __smp_alt_end.
120 */
Cyrill Gorcunov3cdac412008-02-17 18:17:17 +0300121 . = ALIGN(PAGE_SIZE);
Thomas Gleixnera60b7782007-10-11 11:12:11 +0200122
123 /* will be freed after init */
Cyrill Gorcunov3cdac412008-02-17 18:17:17 +0300124 . = ALIGN(PAGE_SIZE); /* Init code and data */
Thomas Gleixnera60b7782007-10-11 11:12:11 +0200125 .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) {
126 __init_begin = .;
127 _sinittext = .;
Sam Ravnborg01ba2bd2008-01-20 14:15:03 +0100128 INIT_TEXT
Thomas Gleixnera60b7782007-10-11 11:12:11 +0200129 _einittext = .;
130 }
Sam Ravnborg01ba2bd2008-01-20 14:15:03 +0100131 .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) {
132 INIT_DATA
133 }
Thomas Gleixnera60b7782007-10-11 11:12:11 +0200134 . = ALIGN(16);
135 .init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) {
136 __setup_start = .;
137 *(.init.setup)
138 __setup_end = .;
139 }
140 .initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET) {
141 __initcall_start = .;
142 INITCALLS
143 __initcall_end = .;
144 }
145 .con_initcall.init : AT(ADDR(.con_initcall.init) - LOAD_OFFSET) {
146 __con_initcall_start = .;
147 *(.con_initcall.init)
148 __con_initcall_end = .;
149 }
Thomas Petazzoni03ae5762008-02-15 12:00:23 +0100150 .x86cpuvendor.init : AT(ADDR(.x86cpuvendor.init) - LOAD_OFFSET) {
151 __x86cpuvendor_start = .;
152 *(.x86cpuvendor.init)
153 __x86cpuvendor_end = .;
154 }
Thomas Gleixnera60b7782007-10-11 11:12:11 +0200155 SECURITY_INIT
156 . = ALIGN(4);
157 .altinstructions : AT(ADDR(.altinstructions) - LOAD_OFFSET) {
158 __alt_instructions = .;
159 *(.altinstructions)
160 __alt_instructions_end = .;
161 }
162 .altinstr_replacement : AT(ADDR(.altinstr_replacement) - LOAD_OFFSET) {
163 *(.altinstr_replacement)
164 }
165 . = ALIGN(4);
166 .parainstructions : AT(ADDR(.parainstructions) - LOAD_OFFSET) {
167 __parainstructions = .;
168 *(.parainstructions)
169 __parainstructions_end = .;
170 }
171 /* .exit.text is discard at runtime, not link time, to deal with references
172 from .altinstructions and .eh_frame */
Sam Ravnborg01ba2bd2008-01-20 14:15:03 +0100173 .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
174 EXIT_TEXT
175 }
176 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
177 EXIT_DATA
178 }
Thomas Gleixnera60b7782007-10-11 11:12:11 +0200179#if defined(CONFIG_BLK_DEV_INITRD)
Cyrill Gorcunov3cdac412008-02-17 18:17:17 +0300180 . = ALIGN(PAGE_SIZE);
Thomas Gleixnera60b7782007-10-11 11:12:11 +0200181 .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) {
182 __initramfs_start = .;
183 *(.init.ramfs)
184 __initramfs_end = .;
185 }
186#endif
Cyrill Gorcunov3cdac412008-02-17 18:17:17 +0300187 . = ALIGN(PAGE_SIZE);
Thomas Gleixnera60b7782007-10-11 11:12:11 +0200188 .data.percpu : AT(ADDR(.data.percpu) - LOAD_OFFSET) {
189 __per_cpu_start = .;
190 *(.data.percpu)
191 *(.data.percpu.shared_aligned)
192 __per_cpu_end = .;
193 }
Cyrill Gorcunov3cdac412008-02-17 18:17:17 +0300194 . = ALIGN(PAGE_SIZE);
Thomas Gleixnera60b7782007-10-11 11:12:11 +0200195 /* freed after init ends here */
Cyrill Gorcunov3cdac412008-02-17 18:17:17 +0300196
Thomas Gleixnera60b7782007-10-11 11:12:11 +0200197 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
198 __init_end = .;
199 __bss_start = .; /* BSS */
200 *(.bss.page_aligned)
201 *(.bss)
202 . = ALIGN(4);
203 __bss_stop = .;
204 _end = . ;
205 /* This is where the kernel creates the early boot page tables */
Cyrill Gorcunov3cdac412008-02-17 18:17:17 +0300206 . = ALIGN(PAGE_SIZE);
Thomas Gleixnera60b7782007-10-11 11:12:11 +0200207 pg0 = . ;
208 }
209
210 /* Sections to be discarded */
211 /DISCARD/ : {
212 *(.exitcall.exit)
213 }
214
215 STABS_DEBUG
216
217 DWARF_DEBUG
218}