blob: 654e479802f2098afb74c0fea0bb0b68e25707f5 [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{
Rusty Russelld4703ae2009-12-15 16:28:32 -060041 . = 0;
42 reloc_start = .;
43
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +110044 . = KERNELBASE;
Stephen Rothwellcabb5582005-09-30 16:16:52 +100045
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +110046/*
47 * Text, read only data and other permanent read-only sections
48 */
49
50 /* Text and gots */
Kumar Gala366234f2008-04-16 05:52:28 +100051 .text : AT(ADDR(.text) - LOAD_OFFSET) {
Kumar Gala748a7682007-09-13 15:42:35 -050052 ALIGN_FUNCTION();
Tim Abbotte7039842009-04-25 22:11:05 -040053 HEAD_TEXT
Eric W. Biedermanfd593d12006-12-07 02:14:04 +010054 _text = .;
Tim Abbott13beadd92009-04-28 11:47:15 -040055 /* careful! __ftr_alt_* sections need to be close to .text */
56 *(.text .fixup __ftr_alt_* .ref.text)
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +110057 SCHED_TEXT
58 LOCK_TEXT
59 KPROBES_TEXT
Steven Rostedt6794c782009-02-09 21:10:27 -080060 IRQENTRY_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
Segher Boessenkoolc69cccc2008-07-22 09:03:45 +100069 } :kernel
Paul Mackerras14cf11a2005-09-26 16:04:21 +100070
Stephen Rothwell303996d2008-09-02 15:04:09 +100071 . = ALIGN(PAGE_SIZE);
72 _etext = .;
73 PROVIDE32 (etext = .);
74
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +110075 /* Read-only data */
76 RODATA
Paul Mackerras14cf11a2005-09-26 16:04:21 +100077
Tim Abbott62bef282009-09-24 10:36:24 -040078 EXCEPTION_TABLE(0)
Paul Mackerras14cf11a2005-09-26 16:04:21 +100079
Segher Boessenkoolc69cccc2008-07-22 09:03:45 +100080 NOTES :kernel :notes
81
82 /* The dummy segment contents for the bug workaround mentioned above
83 near PHDRS. */
Segher Boessenkool80c60bf2008-07-25 10:08:41 +100084 .dummy : AT(ADDR(.dummy) - LOAD_OFFSET) {
Milton Millere16459c6b2009-01-02 10:46:04 +000085 LONG(0)
86 LONG(0)
87 LONG(0)
Segher Boessenkoolc69cccc2008-07-22 09:03:45 +100088 } :kernel :dummy
Roland McGrath8fb775e2007-07-19 01:48:38 -070089
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +110090/*
91 * Init sections discarded at runtime
92 */
93 . = ALIGN(PAGE_SIZE);
94 __init_begin = .;
Tim Abbott62bef282009-09-24 10:36:24 -040095 INIT_TEXT_SECTION(PAGE_SIZE) :kernel
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +110096
97 /* .exit.text is discarded at runtime, not link time,
98 * to deal with references from __bug_table
99 */
Kumar Gala366234f2008-04-16 05:52:28 +1000100 .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
Sam Ravnborg01ba2bd2008-01-20 14:15:03 +0100101 EXIT_TEXT
102 }
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100103
Kumar Gala366234f2008-04-16 05:52:28 +1000104 .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) {
Sam Ravnborg01ba2bd2008-01-20 14:15:03 +0100105 INIT_DATA
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100106 __vtop_table_begin = .;
107 *(.vtop_fixup);
108 __vtop_table_end = .;
109 __ptov_table_begin = .;
110 *(.ptov_fixup);
111 __ptov_table_end = .;
112 }
113
Kumar Gala366234f2008-04-16 05:52:28 +1000114 .init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) {
Tim Abbott62bef282009-09-24 10:36:24 -0400115 INIT_SETUP(16)
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100116 }
117
Kumar Gala366234f2008-04-16 05:52:28 +1000118 .initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET) {
Tim Abbott62bef282009-09-24 10:36:24 -0400119 INIT_CALLS
120 }
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100121
Kumar Gala366234f2008-04-16 05:52:28 +1000122 .con_initcall.init : AT(ADDR(.con_initcall.init) - LOAD_OFFSET) {
Tim Abbott62bef282009-09-24 10:36:24 -0400123 CON_INITCALL
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100124 }
125
126 SECURITY_INIT
127
128 . = ALIGN(8);
Kumar Gala366234f2008-04-16 05:52:28 +1000129 __ftr_fixup : AT(ADDR(__ftr_fixup) - LOAD_OFFSET) {
Stephen Rothwellcabb5582005-09-30 16:16:52 +1000130 __start___ftr_fixup = .;
131 *(__ftr_fixup)
132 __stop___ftr_fixup = .;
133 }
Kumar Gala2d1b2022008-07-02 01:16:40 +1000134 . = ALIGN(8);
Benjamin Herrenschmidt7c03d652008-12-18 19:13:32 +0000135 __mmu_ftr_fixup : AT(ADDR(__mmu_ftr_fixup) - LOAD_OFFSET) {
136 __start___mmu_ftr_fixup = .;
137 *(__mmu_ftr_fixup)
138 __stop___mmu_ftr_fixup = .;
139 }
140 . = ALIGN(8);
Kumar Gala2d1b2022008-07-02 01:16:40 +1000141 __lwsync_fixup : AT(ADDR(__lwsync_fixup) - LOAD_OFFSET) {
142 __start___lwsync_fixup = .;
143 *(__lwsync_fixup)
144 __stop___lwsync_fixup = .;
145 }
Stephen Rothwell3f639ee2006-09-25 18:19:00 +1000146#ifdef CONFIG_PPC64
147 . = ALIGN(8);
Kumar Gala366234f2008-04-16 05:52:28 +1000148 __fw_ftr_fixup : AT(ADDR(__fw_ftr_fixup) - LOAD_OFFSET) {
Stephen Rothwell3f639ee2006-09-25 18:19:00 +1000149 __start___fw_ftr_fixup = .;
150 *(__fw_ftr_fixup)
151 __stop___fw_ftr_fixup = .;
152 }
153#endif
Kumar Gala366234f2008-04-16 05:52:28 +1000154 .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) {
Tim Abbott62bef282009-09-24 10:36:24 -0400155 INIT_RAM_FS
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100156 }
Tim Abbott62bef282009-09-24 10:36:24 -0400157
Tejun Heo0415b00d12011-03-24 18:50:09 +0100158 PERCPU_SECTION(L1_CACHE_BYTES)
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100159
160 . = ALIGN(8);
Kumar Gala366234f2008-04-16 05:52:28 +1000161 .machine.desc : AT(ADDR(.machine.desc) - LOAD_OFFSET) {
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100162 __machine_desc_start = . ;
163 *(.machine.desc)
164 __machine_desc_end = . ;
165 }
Paul Mackerras2a4b9c52008-10-22 18:43:45 +0000166#ifdef CONFIG_RELOCATABLE
Paul Mackerras549e8152008-08-30 11:43:47 +1000167 . = ALIGN(8);
Suzuki Poulose9c5f7d32011-12-14 22:58:12 +0000168 .dynsym : AT(ADDR(.dynsym) - LOAD_OFFSET)
169 {
170#ifdef CONFIG_RELOCATABLE_PPC32
171 __dynamic_symtab = .;
172#endif
173 *(.dynsym)
174 }
Paul Mackerras549e8152008-08-30 11:43:47 +1000175 .dynstr : AT(ADDR(.dynstr) - LOAD_OFFSET) { *(.dynstr) }
176 .dynamic : AT(ADDR(.dynamic) - LOAD_OFFSET)
177 {
178 __dynamic_start = .;
179 *(.dynamic)
180 }
181 .hash : AT(ADDR(.hash) - LOAD_OFFSET) { *(.hash) }
182 .interp : AT(ADDR(.interp) - LOAD_OFFSET) { *(.interp) }
183 .rela.dyn : AT(ADDR(.rela.dyn) - LOAD_OFFSET)
184 {
185 __rela_dyn_start = .;
186 *(.rela*)
187 }
Paul Mackerras2a4b9c52008-10-22 18:43:45 +0000188#endif
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100189
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 = .;
Anton Blanchard5ac47f72012-11-26 17:39:03 +0000221#ifndef CONFIG_RELOCATABLE
222 __prom_init_toc_start = .;
223 arch/powerpc/kernel/prom_init.o*(.toc .got)
224 __prom_init_toc_end = .;
225#endif
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100226 *(.got)
227 *(.toc)
228 }
Stephen Rothwellcabb5582005-09-30 16:16:52 +1000229#endif
Paul Mackerras4a288562005-10-10 22:38:46 +1000230
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100231 /* The initial task and kernel stack */
Tim Abbott2af76872010-02-20 01:03:35 +0100232 INIT_TASK_DATA_SECTION(THREAD_SIZE)
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100233
Tim Abbott75b13482010-02-20 01:03:37 +0100234 .data..page_aligned : AT(ADDR(.data..page_aligned) - LOAD_OFFSET) {
Tim Abbott62bef282009-09-24 10:36:24 -0400235 PAGE_ALIGNED_DATA(PAGE_SIZE)
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100236 }
237
Tim Abbott4af57b72010-02-20 01:03:34 +0100238 .data..cacheline_aligned : AT(ADDR(.data..cacheline_aligned) - LOAD_OFFSET) {
Tim Abbott62bef282009-09-24 10:36:24 -0400239 CACHELINE_ALIGNED_DATA(L1_CACHE_BYTES)
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100240 }
241
Denys Vlasenko54cb27a2010-02-20 01:03:44 +0100242 .data..read_mostly : AT(ADDR(.data..read_mostly) - LOAD_OFFSET) {
Tim Abbott62bef282009-09-24 10:36:24 -0400243 READ_MOSTLY_DATA(L1_CACHE_BYTES)
Tony Breedsbd67fcf2007-07-04 14:04:31 +1000244 }
245
Sean MacLennan5be2a212009-09-29 06:00:06 +0000246 . = ALIGN(PAGE_SIZE);
Kumar Gala366234f2008-04-16 05:52:28 +1000247 .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
Tim Abbott62bef282009-09-24 10:36:24 -0400248 NOSAVE_DATA
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100249 }
250
Michael Ellerman903444e2009-08-09 19:06:24 +0000251 . = ALIGN(PAGE_SIZE);
252 _edata = .;
253 PROVIDE32 (edata = .);
254
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100255/*
256 * And finally the bss
257 */
258
Tim Abbott62bef282009-09-24 10:36:24 -0400259 BSS_SECTION(0, 0, 0)
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100260
261 . = ALIGN(PAGE_SIZE);
262 _end = . ;
263 PROVIDE32 (end = .);
Tejun Heo023bf6f2009-07-09 11:27:40 +0900264
265 /* Sections to be discarded. */
266 DISCARDS
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000267}