blob: 4a8ce62fe1121c1a774f04a9af6223a96f945c23 [file] [log] [blame]
Paul Mackerrasc51e3a42005-11-05 10:36:59 +11001#ifdef CONFIG_PPC64
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +11002#define PROVIDE32(x) PROVIDE(__unused__##x)
Paul Mackerrasc51e3a42005-11-05 10:36:59 +11003#else
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +11004#define PROVIDE32(x) PROVIDE(x)
Paul Mackerrasc51e3a42005-11-05 10:36:59 +11005#endif
Kumar Gala4846c5d2008-04-16 05:52:26 +10006#include <asm/page.h>
Paul Mackerras14cf11a2005-09-26 16:04:21 +10007#include <asm-generic/vmlinux.lds.h>
Tony Breedsbd67fcf2007-07-04 14:04:31 +10008#include <asm/cache.h>
Paul Mackerras14cf11a2005-09-26 16:04:21 +10009
Michael Ellermane19e4ab2005-11-03 16:03:06 +110010ENTRY(_stext)
11
Segher Boessenkoolc69cccc2008-07-22 09:03:45 +100012PHDRS {
13 kernel PT_LOAD FLAGS(7); /* RWX */
14 notes PT_NOTE FLAGS(0);
15 dummy PT_NOTE FLAGS(0);
16
17 /* binutils < 2.18 has a bug that makes it misbehave when taking an
18 ELF file with all segments at load address 0 as input. This
19 happens when running "strip" on vmlinux, because of the AT() magic
20 in this linker script. People using GCC >= 4.2 won't run into
21 this problem, because the "build-id" support will put some data
22 into the "notes" segment (at a non-zero load address).
23
24 To work around this, we force some data into both the "dummy"
25 segment and the kernel segment, so the dummy segment will get a
26 non-zero load address. It's not enough to always create the
27 "notes" segment, since if nothing gets assigned to it, its load
28 address will be zero. */
29}
30
Stephen Rothwellcabb5582005-09-30 16:16:52 +100031#ifdef CONFIG_PPC64
32OUTPUT_ARCH(powerpc:common64)
33jiffies = jiffies_64;
34#else
Paul Mackerras14cf11a2005-09-26 16:04:21 +100035OUTPUT_ARCH(powerpc:common)
36jiffies = jiffies_64 + 4;
Stephen Rothwellcabb5582005-09-30 16:16:52 +100037#endif
Paul Mackerras14cf11a2005-09-26 16:04:21 +100038SECTIONS
39{
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +110040 /* Sections to be discarded. */
41 /DISCARD/ : {
42 *(.exitcall.exit)
Sam Ravnborg01ba2bd2008-01-20 14:15:03 +010043 EXIT_DATA
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +110044 }
Stephen Rothwellcabb5582005-09-30 16:16:52 +100045
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +110046 . = KERNELBASE;
Stephen Rothwellcabb5582005-09-30 16:16:52 +100047
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +110048/*
49 * Text, read only data and other permanent read-only sections
50 */
51
52 /* Text and gots */
Kumar Gala366234f2008-04-16 05:52:28 +100053 .text : AT(ADDR(.text) - LOAD_OFFSET) {
Kumar Gala748a7682007-09-13 15:42:35 -050054 ALIGN_FUNCTION();
55 *(.text.head)
Eric W. Biedermanfd593d12006-12-07 02:14:04 +010056 _text = .;
Michael Ellermanfac23fe2008-06-24 11:32:54 +100057 *(.text .fixup .text.init.refok .exit.text.refok __ftr_alt_*)
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +110058 SCHED_TEXT
59 LOCK_TEXT
60 KPROBES_TEXT
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +110061
Stephen Rothwellcabb5582005-09-30 16:16:52 +100062#ifdef CONFIG_PPC32
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +110063 *(.got1)
64 __got2_start = .;
65 *(.got2)
66 __got2_end = .;
67#endif /* CONFIG_PPC32 */
Paul Mackerras14cf11a2005-09-26 16:04:21 +100068
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +110069 . = ALIGN(PAGE_SIZE);
70 _etext = .;
71 PROVIDE32 (etext = .);
Segher Boessenkoolc69cccc2008-07-22 09:03:45 +100072 } :kernel
Paul Mackerras14cf11a2005-09-26 16:04:21 +100073
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +110074 /* Read-only data */
75 RODATA
Paul Mackerras14cf11a2005-09-26 16:04:21 +100076
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +110077 /* Exception & bug tables */
Kumar Gala366234f2008-04-16 05:52:28 +100078 __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {
Paul Mackerras14cf11a2005-09-26 16:04:21 +100079 __start___ex_table = .;
80 *(__ex_table)
81 __stop___ex_table = .;
82 }
83
Segher Boessenkoolc69cccc2008-07-22 09:03:45 +100084 NOTES :kernel :notes
85
86 /* The dummy segment contents for the bug workaround mentioned above
87 near PHDRS. */
Segher Boessenkool80c60bf2008-07-25 10:08:41 +100088 .dummy : AT(ADDR(.dummy) - LOAD_OFFSET) {
Segher Boessenkoolc69cccc2008-07-22 09:03:45 +100089 LONG(0xf177)
90 } :kernel :dummy
Roland McGrath8fb775e2007-07-19 01:48:38 -070091
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +110092/*
93 * Init sections discarded at runtime
94 */
95 . = ALIGN(PAGE_SIZE);
96 __init_begin = .;
97
Kumar Gala366234f2008-04-16 05:52:28 +100098 .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) {
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +110099 _sinittext = .;
Sam Ravnborg01ba2bd2008-01-20 14:15:03 +0100100 INIT_TEXT
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100101 _einittext = .;
Segher Boessenkoolc69cccc2008-07-22 09:03:45 +1000102 } :kernel
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100103
104 /* .exit.text is discarded at runtime, not link time,
105 * to deal with references from __bug_table
106 */
Kumar Gala366234f2008-04-16 05:52:28 +1000107 .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
Sam Ravnborg01ba2bd2008-01-20 14:15:03 +0100108 EXIT_TEXT
109 }
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100110
Kumar Gala366234f2008-04-16 05:52:28 +1000111 .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) {
Sam Ravnborg01ba2bd2008-01-20 14:15:03 +0100112 INIT_DATA
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100113 __vtop_table_begin = .;
114 *(.vtop_fixup);
115 __vtop_table_end = .;
116 __ptov_table_begin = .;
117 *(.ptov_fixup);
118 __ptov_table_end = .;
Stephen Rothwellc4e3ea22006-05-19 17:04:48 +1000119#ifdef CONFIG_PPC_ISERIES
120 __dt_strings_start = .;
121 *(.dt_strings);
122 __dt_strings_end = .;
123#endif
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100124 }
125
126 . = ALIGN(16);
Kumar Gala366234f2008-04-16 05:52:28 +1000127 .init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) {
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100128 __setup_start = .;
129 *(.init.setup)
130 __setup_end = .;
131 }
132
Kumar Gala366234f2008-04-16 05:52:28 +1000133 .initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET) {
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100134 __initcall_start = .;
Andrew Morton61ce1ef2006-10-27 11:41:44 -0700135 INITCALLS
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100136 __initcall_end = .;
137 }
138
Kumar Gala366234f2008-04-16 05:52:28 +1000139 .con_initcall.init : AT(ADDR(.con_initcall.init) - LOAD_OFFSET) {
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100140 __con_initcall_start = .;
141 *(.con_initcall.init)
142 __con_initcall_end = .;
143 }
144
145 SECURITY_INIT
146
147 . = ALIGN(8);
Kumar Gala366234f2008-04-16 05:52:28 +1000148 __ftr_fixup : AT(ADDR(__ftr_fixup) - LOAD_OFFSET) {
Stephen Rothwellcabb5582005-09-30 16:16:52 +1000149 __start___ftr_fixup = .;
150 *(__ftr_fixup)
151 __stop___ftr_fixup = .;
152 }
Kumar Gala2d1b2022008-07-02 01:16:40 +1000153 . = ALIGN(8);
154 __lwsync_fixup : AT(ADDR(__lwsync_fixup) - LOAD_OFFSET) {
155 __start___lwsync_fixup = .;
156 *(__lwsync_fixup)
157 __stop___lwsync_fixup = .;
158 }
Stephen Rothwell3f639ee2006-09-25 18:19:00 +1000159#ifdef CONFIG_PPC64
160 . = ALIGN(8);
Kumar Gala366234f2008-04-16 05:52:28 +1000161 __fw_ftr_fixup : AT(ADDR(__fw_ftr_fixup) - LOAD_OFFSET) {
Stephen Rothwell3f639ee2006-09-25 18:19:00 +1000162 __start___fw_ftr_fixup = .;
163 *(__fw_ftr_fixup)
164 __stop___fw_ftr_fixup = .;
165 }
166#endif
Jean-Paul Saman67d38222007-02-10 01:44:44 -0800167#ifdef CONFIG_BLK_DEV_INITRD
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100168 . = ALIGN(PAGE_SIZE);
Kumar Gala366234f2008-04-16 05:52:28 +1000169 .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) {
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100170 __initramfs_start = .;
171 *(.init.ramfs)
172 __initramfs_end = .;
173 }
Jean-Paul Saman67d38222007-02-10 01:44:44 -0800174#endif
Jeremy Fitzhardingeb6e35902007-05-02 19:27:12 +0200175 . = ALIGN(PAGE_SIZE);
Kumar Gala366234f2008-04-16 05:52:28 +1000176 .data.percpu : AT(ADDR(.data.percpu) - LOAD_OFFSET) {
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100177 __per_cpu_start = .;
178 *(.data.percpu)
Fenghua Yu5fb7dc32007-07-19 01:48:12 -0700179 *(.data.percpu.shared_aligned)
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100180 __per_cpu_end = .;
181 }
182
183 . = ALIGN(8);
Kumar Gala366234f2008-04-16 05:52:28 +1000184 .machine.desc : AT(ADDR(.machine.desc) - LOAD_OFFSET) {
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100185 __machine_desc_start = . ;
186 *(.machine.desc)
187 __machine_desc_end = . ;
188 }
189
190 /* freed after init ends here */
191 . = ALIGN(PAGE_SIZE);
192 __init_end = .;
193
194/*
195 * And now the various read/write data
196 */
197
198 . = ALIGN(PAGE_SIZE);
199 _sdata = .;
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000200
Stephen Rothwellcabb5582005-09-30 16:16:52 +1000201#ifdef CONFIG_PPC32
Kumar Gala366234f2008-04-16 05:52:28 +1000202 .data : AT(ADDR(.data) - LOAD_OFFSET) {
Sam Ravnborgca967252007-05-17 13:38:44 +0200203 DATA_DATA
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100204 *(.sdata)
205 *(.got.plt) *(.got)
206 }
Stephen Rothwellcabb5582005-09-30 16:16:52 +1000207#else
Kumar Gala366234f2008-04-16 05:52:28 +1000208 .data : AT(ADDR(.data) - LOAD_OFFSET) {
Mathieu Desnoyers3ae0aa92007-06-16 22:29:04 -0400209 DATA_DATA
210 *(.data.rel*)
211 *(.toc1)
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100212 *(.branch_lt)
213 }
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000214
Kumar Gala366234f2008-04-16 05:52:28 +1000215 .opd : AT(ADDR(.opd) - LOAD_OFFSET) {
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100216 *(.opd)
217 }
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000218
Kumar Gala366234f2008-04-16 05:52:28 +1000219 .got : AT(ADDR(.got) - LOAD_OFFSET) {
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100220 __toc_start = .;
221 *(.got)
222 *(.toc)
223 }
Stephen Rothwellcabb5582005-09-30 16:16:52 +1000224#endif
Paul Mackerras4a288562005-10-10 22:38:46 +1000225
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100226 . = ALIGN(PAGE_SIZE);
227 _edata = .;
228 PROVIDE32 (edata = .);
Stephen Rothwellcabb5582005-09-30 16:16:52 +1000229
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100230 /* The initial task and kernel stack */
Stephen Rothwellcabb5582005-09-30 16:16:52 +1000231#ifdef CONFIG_PPC32
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100232 . = ALIGN(8192);
233#else
234 . = ALIGN(16384);
Stephen Rothwellcabb5582005-09-30 16:16:52 +1000235#endif
Kumar Gala366234f2008-04-16 05:52:28 +1000236 .data.init_task : AT(ADDR(.data.init_task) - LOAD_OFFSET) {
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100237 *(.data.init_task)
238 }
239
240 . = ALIGN(PAGE_SIZE);
Kumar Gala366234f2008-04-16 05:52:28 +1000241 .data.page_aligned : AT(ADDR(.data.page_aligned) - LOAD_OFFSET) {
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100242 *(.data.page_aligned)
243 }
244
Kumar Gala366234f2008-04-16 05:52:28 +1000245 .data.cacheline_aligned : AT(ADDR(.data.cacheline_aligned) - LOAD_OFFSET) {
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100246 *(.data.cacheline_aligned)
247 }
248
Tony Breedsbd67fcf2007-07-04 14:04:31 +1000249 . = ALIGN(L1_CACHE_BYTES);
Kumar Gala366234f2008-04-16 05:52:28 +1000250 .data.read_mostly : AT(ADDR(.data.read_mostly) - LOAD_OFFSET) {
Tony Breedsbd67fcf2007-07-04 14:04:31 +1000251 *(.data.read_mostly)
252 }
253
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100254 . = ALIGN(PAGE_SIZE);
Kumar Gala366234f2008-04-16 05:52:28 +1000255 .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100256 __nosave_begin = .;
257 *(.data.nosave)
258 . = ALIGN(PAGE_SIZE);
259 __nosave_end = .;
260 }
261
262/*
263 * And finally the bss
264 */
265
Kumar Gala366234f2008-04-16 05:52:28 +1000266 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100267 __bss_start = .;
268 *(.sbss) *(.scommon)
269 *(.dynbss)
270 *(.bss)
271 *(COMMON)
272 __bss_stop = .;
273 }
274
275 . = ALIGN(PAGE_SIZE);
276 _end = . ;
277 PROVIDE32 (end = .);
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000278}