blob: 27735a7ac12b6709d1dd04e51a7871e1bce33232 [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>
Tim Abbott62bef282009-09-24 10:36:24 -04009#include <asm/thread_info.h>
Paul Mackerras14cf11a2005-09-26 16:04:21 +100010
Michael Ellermane19e4ab2005-11-03 16:03:06 +110011ENTRY(_stext)
12
Segher Boessenkoolc69cccc2008-07-22 09:03:45 +100013PHDRS {
14 kernel PT_LOAD FLAGS(7); /* RWX */
15 notes PT_NOTE FLAGS(0);
16 dummy PT_NOTE FLAGS(0);
17
18 /* binutils < 2.18 has a bug that makes it misbehave when taking an
19 ELF file with all segments at load address 0 as input. This
20 happens when running "strip" on vmlinux, because of the AT() magic
21 in this linker script. People using GCC >= 4.2 won't run into
22 this problem, because the "build-id" support will put some data
23 into the "notes" segment (at a non-zero load address).
24
25 To work around this, we force some data into both the "dummy"
26 segment and the kernel segment, so the dummy segment will get a
27 non-zero load address. It's not enough to always create the
28 "notes" segment, since if nothing gets assigned to it, its load
29 address will be zero. */
30}
31
Stephen Rothwellcabb5582005-09-30 16:16:52 +100032#ifdef CONFIG_PPC64
33OUTPUT_ARCH(powerpc:common64)
34jiffies = jiffies_64;
35#else
Paul Mackerras14cf11a2005-09-26 16:04:21 +100036OUTPUT_ARCH(powerpc:common)
37jiffies = jiffies_64 + 4;
Stephen Rothwellcabb5582005-09-30 16:16:52 +100038#endif
Paul Mackerras14cf11a2005-09-26 16:04:21 +100039SECTIONS
40{
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +110041 . = KERNELBASE;
Stephen Rothwellcabb5582005-09-30 16:16:52 +100042
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +110043/*
44 * Text, read only data and other permanent read-only sections
45 */
46
47 /* Text and gots */
Kumar Gala366234f2008-04-16 05:52:28 +100048 .text : AT(ADDR(.text) - LOAD_OFFSET) {
Kumar Gala748a7682007-09-13 15:42:35 -050049 ALIGN_FUNCTION();
Tim Abbotte7039842009-04-25 22:11:05 -040050 HEAD_TEXT
Eric W. Biedermanfd593d12006-12-07 02:14:04 +010051 _text = .;
Tim Abbott13beadd2009-04-28 11:47:15 -040052 /* careful! __ftr_alt_* sections need to be close to .text */
53 *(.text .fixup __ftr_alt_* .ref.text)
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +110054 SCHED_TEXT
55 LOCK_TEXT
56 KPROBES_TEXT
Steven Rostedt6794c782009-02-09 21:10:27 -080057 IRQENTRY_TEXT
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +110058
Stephen Rothwellcabb5582005-09-30 16:16:52 +100059#ifdef CONFIG_PPC32
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +110060 *(.got1)
61 __got2_start = .;
62 *(.got2)
63 __got2_end = .;
64#endif /* CONFIG_PPC32 */
Paul Mackerras14cf11a2005-09-26 16:04:21 +100065
Segher Boessenkoolc69cccc2008-07-22 09:03:45 +100066 } :kernel
Paul Mackerras14cf11a2005-09-26 16:04:21 +100067
Stephen Rothwell303996d2008-09-02 15:04:09 +100068 . = ALIGN(PAGE_SIZE);
69 _etext = .;
70 PROVIDE32 (etext = .);
71
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +110072 /* Read-only data */
73 RODATA
Paul Mackerras14cf11a2005-09-26 16:04:21 +100074
Tim Abbott62bef282009-09-24 10:36:24 -040075 EXCEPTION_TABLE(0)
Paul Mackerras14cf11a2005-09-26 16:04:21 +100076
Segher Boessenkoolc69cccc2008-07-22 09:03:45 +100077 NOTES :kernel :notes
78
79 /* The dummy segment contents for the bug workaround mentioned above
80 near PHDRS. */
Segher Boessenkool80c60bf2008-07-25 10:08:41 +100081 .dummy : AT(ADDR(.dummy) - LOAD_OFFSET) {
Milton Millere16459c2009-01-02 10:46:04 +000082 LONG(0)
83 LONG(0)
84 LONG(0)
Segher Boessenkoolc69cccc2008-07-22 09:03:45 +100085 } :kernel :dummy
Roland McGrath8fb775e2007-07-19 01:48:38 -070086
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +110087/*
88 * Init sections discarded at runtime
89 */
90 . = ALIGN(PAGE_SIZE);
91 __init_begin = .;
Tim Abbott62bef282009-09-24 10:36:24 -040092 INIT_TEXT_SECTION(PAGE_SIZE) :kernel
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +110093
94 /* .exit.text is discarded at runtime, not link time,
95 * to deal with references from __bug_table
96 */
Kumar Gala366234f2008-04-16 05:52:28 +100097 .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
Sam Ravnborg01ba2bd2008-01-20 14:15:03 +010098 EXIT_TEXT
99 }
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100100
Kumar Gala366234f2008-04-16 05:52:28 +1000101 .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) {
Sam Ravnborg01ba2bd2008-01-20 14:15:03 +0100102 INIT_DATA
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100103 __vtop_table_begin = .;
104 *(.vtop_fixup);
105 __vtop_table_end = .;
106 __ptov_table_begin = .;
107 *(.ptov_fixup);
108 __ptov_table_end = .;
Stephen Rothwellc4e3ea22006-05-19 17:04:48 +1000109#ifdef CONFIG_PPC_ISERIES
110 __dt_strings_start = .;
111 *(.dt_strings);
112 __dt_strings_end = .;
113#endif
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100114 }
115
Kumar Gala366234f2008-04-16 05:52:28 +1000116 .init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) {
Tim Abbott62bef282009-09-24 10:36:24 -0400117 INIT_SETUP(16)
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100118 }
119
Kumar Gala366234f2008-04-16 05:52:28 +1000120 .initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET) {
Tim Abbott62bef282009-09-24 10:36:24 -0400121 INIT_CALLS
122 }
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100123
Kumar Gala366234f2008-04-16 05:52:28 +1000124 .con_initcall.init : AT(ADDR(.con_initcall.init) - LOAD_OFFSET) {
Tim Abbott62bef282009-09-24 10:36:24 -0400125 CON_INITCALL
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100126 }
127
128 SECURITY_INIT
129
130 . = ALIGN(8);
Kumar Gala366234f2008-04-16 05:52:28 +1000131 __ftr_fixup : AT(ADDR(__ftr_fixup) - LOAD_OFFSET) {
Stephen Rothwellcabb5582005-09-30 16:16:52 +1000132 __start___ftr_fixup = .;
133 *(__ftr_fixup)
134 __stop___ftr_fixup = .;
135 }
Kumar Gala2d1b2022008-07-02 01:16:40 +1000136 . = ALIGN(8);
Benjamin Herrenschmidt7c03d652008-12-18 19:13:32 +0000137 __mmu_ftr_fixup : AT(ADDR(__mmu_ftr_fixup) - LOAD_OFFSET) {
138 __start___mmu_ftr_fixup = .;
139 *(__mmu_ftr_fixup)
140 __stop___mmu_ftr_fixup = .;
141 }
142 . = ALIGN(8);
Kumar Gala2d1b2022008-07-02 01:16:40 +1000143 __lwsync_fixup : AT(ADDR(__lwsync_fixup) - LOAD_OFFSET) {
144 __start___lwsync_fixup = .;
145 *(__lwsync_fixup)
146 __stop___lwsync_fixup = .;
147 }
Stephen Rothwell3f639ee2006-09-25 18:19:00 +1000148#ifdef CONFIG_PPC64
149 . = ALIGN(8);
Kumar Gala366234f2008-04-16 05:52:28 +1000150 __fw_ftr_fixup : AT(ADDR(__fw_ftr_fixup) - LOAD_OFFSET) {
Stephen Rothwell3f639ee2006-09-25 18:19:00 +1000151 __start___fw_ftr_fixup = .;
152 *(__fw_ftr_fixup)
153 __stop___fw_ftr_fixup = .;
154 }
155#endif
Kumar Gala366234f2008-04-16 05:52:28 +1000156 .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) {
Tim Abbott62bef282009-09-24 10:36:24 -0400157 INIT_RAM_FS
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100158 }
Tim Abbott62bef282009-09-24 10:36:24 -0400159
Tejun Heo19390c42009-03-10 16:27:48 +0900160 PERCPU(PAGE_SIZE)
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100161
162 . = ALIGN(8);
Kumar Gala366234f2008-04-16 05:52:28 +1000163 .machine.desc : AT(ADDR(.machine.desc) - LOAD_OFFSET) {
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100164 __machine_desc_start = . ;
165 *(.machine.desc)
166 __machine_desc_end = . ;
167 }
Paul Mackerras2a4b9c52008-10-22 18:43:45 +0000168#ifdef CONFIG_RELOCATABLE
Paul Mackerras549e8152008-08-30 11:43:47 +1000169 . = ALIGN(8);
170 .dynsym : AT(ADDR(.dynsym) - LOAD_OFFSET) { *(.dynsym) }
171 .dynstr : AT(ADDR(.dynstr) - LOAD_OFFSET) { *(.dynstr) }
172 .dynamic : AT(ADDR(.dynamic) - LOAD_OFFSET)
173 {
174 __dynamic_start = .;
175 *(.dynamic)
176 }
177 .hash : AT(ADDR(.hash) - LOAD_OFFSET) { *(.hash) }
178 .interp : AT(ADDR(.interp) - LOAD_OFFSET) { *(.interp) }
179 .rela.dyn : AT(ADDR(.rela.dyn) - LOAD_OFFSET)
180 {
181 __rela_dyn_start = .;
182 *(.rela*)
183 }
Paul Mackerras2a4b9c52008-10-22 18:43:45 +0000184#endif
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100185
186 /* freed after init ends here */
187 . = ALIGN(PAGE_SIZE);
188 __init_end = .;
189
190/*
191 * And now the various read/write data
192 */
193
194 . = ALIGN(PAGE_SIZE);
195 _sdata = .;
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000196
Stephen Rothwellcabb5582005-09-30 16:16:52 +1000197#ifdef CONFIG_PPC32
Kumar Gala366234f2008-04-16 05:52:28 +1000198 .data : AT(ADDR(.data) - LOAD_OFFSET) {
Sam Ravnborgca967252007-05-17 13:38:44 +0200199 DATA_DATA
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100200 *(.sdata)
201 *(.got.plt) *(.got)
202 }
Stephen Rothwellcabb5582005-09-30 16:16:52 +1000203#else
Kumar Gala366234f2008-04-16 05:52:28 +1000204 .data : AT(ADDR(.data) - LOAD_OFFSET) {
Mathieu Desnoyers3ae0aa92007-06-16 22:29:04 -0400205 DATA_DATA
206 *(.data.rel*)
207 *(.toc1)
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100208 *(.branch_lt)
209 }
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000210
Kumar Gala366234f2008-04-16 05:52:28 +1000211 .opd : AT(ADDR(.opd) - LOAD_OFFSET) {
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100212 *(.opd)
213 }
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000214
Kumar Gala366234f2008-04-16 05:52:28 +1000215 .got : AT(ADDR(.got) - LOAD_OFFSET) {
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100216 __toc_start = .;
217 *(.got)
218 *(.toc)
219 }
Stephen Rothwellcabb5582005-09-30 16:16:52 +1000220#endif
Paul Mackerras4a288562005-10-10 22:38:46 +1000221
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100222 /* The initial task and kernel stack */
Kumar Gala366234f2008-04-16 05:52:28 +1000223 .data.init_task : AT(ADDR(.data.init_task) - LOAD_OFFSET) {
Tim Abbott62bef282009-09-24 10:36:24 -0400224 INIT_TASK_DATA(THREAD_SIZE)
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100225 }
226
Kumar Gala366234f2008-04-16 05:52:28 +1000227 .data.page_aligned : AT(ADDR(.data.page_aligned) - LOAD_OFFSET) {
Tim Abbott62bef282009-09-24 10:36:24 -0400228 PAGE_ALIGNED_DATA(PAGE_SIZE)
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100229 }
230
Kumar Gala366234f2008-04-16 05:52:28 +1000231 .data.cacheline_aligned : AT(ADDR(.data.cacheline_aligned) - LOAD_OFFSET) {
Tim Abbott62bef282009-09-24 10:36:24 -0400232 CACHELINE_ALIGNED_DATA(L1_CACHE_BYTES)
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100233 }
234
Kumar Gala366234f2008-04-16 05:52:28 +1000235 .data.read_mostly : AT(ADDR(.data.read_mostly) - LOAD_OFFSET) {
Tim Abbott62bef282009-09-24 10:36:24 -0400236 READ_MOSTLY_DATA(L1_CACHE_BYTES)
Tony Breedsbd67fcf2007-07-04 14:04:31 +1000237 }
238
Sean MacLennan5be2a212009-09-29 06:00:06 +0000239 . = ALIGN(PAGE_SIZE);
Kumar Gala366234f2008-04-16 05:52:28 +1000240 .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
Tim Abbott62bef282009-09-24 10:36:24 -0400241 NOSAVE_DATA
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100242 }
243
Michael Ellerman903444e2009-08-09 19:06:24 +0000244 . = ALIGN(PAGE_SIZE);
245 _edata = .;
246 PROVIDE32 (edata = .);
247
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100248/*
249 * And finally the bss
250 */
251
Tim Abbott62bef282009-09-24 10:36:24 -0400252 BSS_SECTION(0, 0, 0)
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100253
254 . = ALIGN(PAGE_SIZE);
255 _end = . ;
256 PROVIDE32 (end = .);
Tejun Heo023bf6f2009-07-09 11:27:40 +0900257
258 /* Sections to be discarded. */
259 DISCARDS
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000260}