blob: 1db685104ffc2b298375c9062590ae1c2f811db9 [file] [log] [blame]
Paul Mackerrasc51e3a412005-11-05 10:36:59 +11001#ifdef CONFIG_PPC64
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +11002#define PROVIDE32(x) PROVIDE(__unused__##x)
Paul Mackerrasc51e3a412005-11-05 10:36:59 +11003#else
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +11004#define PROVIDE32(x) PROVIDE(x)
Paul Mackerrasc51e3a412005-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 Abbott13beadd92009-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 Millere16459c6b2009-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 = .;
109 }
110
Kumar Gala366234f2008-04-16 05:52:28 +1000111 .init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) {
Tim Abbott62bef282009-09-24 10:36:24 -0400112 INIT_SETUP(16)
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100113 }
114
Kumar Gala366234f2008-04-16 05:52:28 +1000115 .initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET) {
Tim Abbott62bef282009-09-24 10:36:24 -0400116 INIT_CALLS
117 }
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100118
Kumar Gala366234f2008-04-16 05:52:28 +1000119 .con_initcall.init : AT(ADDR(.con_initcall.init) - LOAD_OFFSET) {
Tim Abbott62bef282009-09-24 10:36:24 -0400120 CON_INITCALL
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100121 }
122
123 SECURITY_INIT
124
125 . = ALIGN(8);
Kumar Gala366234f2008-04-16 05:52:28 +1000126 __ftr_fixup : AT(ADDR(__ftr_fixup) - LOAD_OFFSET) {
Stephen Rothwellcabb5582005-09-30 16:16:52 +1000127 __start___ftr_fixup = .;
128 *(__ftr_fixup)
129 __stop___ftr_fixup = .;
130 }
Kumar Gala2d1b2022008-07-02 01:16:40 +1000131 . = ALIGN(8);
Benjamin Herrenschmidt7c03d652008-12-18 19:13:32 +0000132 __mmu_ftr_fixup : AT(ADDR(__mmu_ftr_fixup) - LOAD_OFFSET) {
133 __start___mmu_ftr_fixup = .;
134 *(__mmu_ftr_fixup)
135 __stop___mmu_ftr_fixup = .;
136 }
137 . = ALIGN(8);
Kumar Gala2d1b2022008-07-02 01:16:40 +1000138 __lwsync_fixup : AT(ADDR(__lwsync_fixup) - LOAD_OFFSET) {
139 __start___lwsync_fixup = .;
140 *(__lwsync_fixup)
141 __stop___lwsync_fixup = .;
142 }
Stephen Rothwell3f639ee2006-09-25 18:19:00 +1000143#ifdef CONFIG_PPC64
144 . = ALIGN(8);
Kumar Gala366234f2008-04-16 05:52:28 +1000145 __fw_ftr_fixup : AT(ADDR(__fw_ftr_fixup) - LOAD_OFFSET) {
Stephen Rothwell3f639ee2006-09-25 18:19:00 +1000146 __start___fw_ftr_fixup = .;
147 *(__fw_ftr_fixup)
148 __stop___fw_ftr_fixup = .;
149 }
150#endif
Kumar Gala366234f2008-04-16 05:52:28 +1000151 .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) {
Tim Abbott62bef282009-09-24 10:36:24 -0400152 INIT_RAM_FS
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100153 }
Tim Abbott62bef282009-09-24 10:36:24 -0400154
Tejun Heo0415b00d12011-03-24 18:50:09 +0100155 PERCPU_SECTION(L1_CACHE_BYTES)
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100156
157 . = ALIGN(8);
Kumar Gala366234f2008-04-16 05:52:28 +1000158 .machine.desc : AT(ADDR(.machine.desc) - LOAD_OFFSET) {
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100159 __machine_desc_start = . ;
160 *(.machine.desc)
161 __machine_desc_end = . ;
162 }
Paul Mackerras2a4b9c52008-10-22 18:43:45 +0000163#ifdef CONFIG_RELOCATABLE
Paul Mackerras549e8152008-08-30 11:43:47 +1000164 . = ALIGN(8);
Suzuki Poulose9c5f7d32011-12-14 22:58:12 +0000165 .dynsym : AT(ADDR(.dynsym) - LOAD_OFFSET)
166 {
167#ifdef CONFIG_RELOCATABLE_PPC32
168 __dynamic_symtab = .;
169#endif
170 *(.dynsym)
171 }
Paul Mackerras549e8152008-08-30 11:43:47 +1000172 .dynstr : AT(ADDR(.dynstr) - LOAD_OFFSET) { *(.dynstr) }
173 .dynamic : AT(ADDR(.dynamic) - LOAD_OFFSET)
174 {
175 __dynamic_start = .;
176 *(.dynamic)
177 }
178 .hash : AT(ADDR(.hash) - LOAD_OFFSET) { *(.hash) }
179 .interp : AT(ADDR(.interp) - LOAD_OFFSET) { *(.interp) }
180 .rela.dyn : AT(ADDR(.rela.dyn) - LOAD_OFFSET)
181 {
182 __rela_dyn_start = .;
183 *(.rela*)
184 }
Paul Mackerras2a4b9c52008-10-22 18:43:45 +0000185#endif
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100186
187 /* freed after init ends here */
188 . = ALIGN(PAGE_SIZE);
189 __init_end = .;
190
191/*
192 * And now the various read/write data
193 */
194
195 . = ALIGN(PAGE_SIZE);
196 _sdata = .;
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000197
Stephen Rothwellcabb5582005-09-30 16:16:52 +1000198#ifdef CONFIG_PPC32
Kumar Gala366234f2008-04-16 05:52:28 +1000199 .data : AT(ADDR(.data) - LOAD_OFFSET) {
Sam Ravnborgca967252007-05-17 13:38:44 +0200200 DATA_DATA
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100201 *(.sdata)
202 *(.got.plt) *(.got)
203 }
Stephen Rothwellcabb5582005-09-30 16:16:52 +1000204#else
Kumar Gala366234f2008-04-16 05:52:28 +1000205 .data : AT(ADDR(.data) - LOAD_OFFSET) {
Mathieu Desnoyers3ae0aa92007-06-16 22:29:04 -0400206 DATA_DATA
207 *(.data.rel*)
208 *(.toc1)
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100209 *(.branch_lt)
210 }
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000211
Kumar Gala366234f2008-04-16 05:52:28 +1000212 .opd : AT(ADDR(.opd) - LOAD_OFFSET) {
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100213 *(.opd)
214 }
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000215
Anton Blanchard5e952352015-05-14 14:45:40 +1000216 . = ALIGN(256);
Kumar Gala366234f2008-04-16 05:52:28 +1000217 .got : AT(ADDR(.got) - LOAD_OFFSET) {
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100218 __toc_start = .;
Anton Blanchard5ac47f72012-11-26 17:39:03 +0000219#ifndef CONFIG_RELOCATABLE
220 __prom_init_toc_start = .;
221 arch/powerpc/kernel/prom_init.o*(.toc .got)
222 __prom_init_toc_end = .;
223#endif
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100224 *(.got)
225 *(.toc)
226 }
Stephen Rothwellcabb5582005-09-30 16:16:52 +1000227#endif
Paul Mackerras4a288562005-10-10 22:38:46 +1000228
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100229 /* The initial task and kernel stack */
Tim Abbott2af76872010-02-20 01:03:35 +0100230 INIT_TASK_DATA_SECTION(THREAD_SIZE)
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100231
Tim Abbott75b13482010-02-20 01:03:37 +0100232 .data..page_aligned : AT(ADDR(.data..page_aligned) - LOAD_OFFSET) {
Tim Abbott62bef282009-09-24 10:36:24 -0400233 PAGE_ALIGNED_DATA(PAGE_SIZE)
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100234 }
235
Tim Abbott4af57b72010-02-20 01:03:34 +0100236 .data..cacheline_aligned : AT(ADDR(.data..cacheline_aligned) - LOAD_OFFSET) {
Tim Abbott62bef282009-09-24 10:36:24 -0400237 CACHELINE_ALIGNED_DATA(L1_CACHE_BYTES)
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100238 }
239
Denys Vlasenko54cb27a2010-02-20 01:03:44 +0100240 .data..read_mostly : AT(ADDR(.data..read_mostly) - LOAD_OFFSET) {
Tim Abbott62bef282009-09-24 10:36:24 -0400241 READ_MOSTLY_DATA(L1_CACHE_BYTES)
Tony Breedsbd67fcf2007-07-04 14:04:31 +1000242 }
243
Sean MacLennan5be2a212009-09-29 06:00:06 +0000244 . = ALIGN(PAGE_SIZE);
Kumar Gala366234f2008-04-16 05:52:28 +1000245 .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
Tim Abbott62bef282009-09-24 10:36:24 -0400246 NOSAVE_DATA
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100247 }
248
Michael Ellerman903444e2009-08-09 19:06:24 +0000249 . = ALIGN(PAGE_SIZE);
250 _edata = .;
251 PROVIDE32 (edata = .);
252
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100253/*
254 * And finally the bss
255 */
256
Tim Abbott62bef282009-09-24 10:36:24 -0400257 BSS_SECTION(0, 0, 0)
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100258
259 . = ALIGN(PAGE_SIZE);
260 _end = . ;
261 PROVIDE32 (end = .);
Tejun Heo023bf6f2009-07-09 11:27:40 +0900262
263 /* Sections to be discarded. */
264 DISCARDS
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000265}