1/* Copyright 2013-2018 IBM Corp.
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * 	http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12 * implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include <config.h>
18#include <mem-map.h>
19
20/* Debug sections from binutils `ld --verbose` */
21
22#define DEBUG_SECTIONS							\
23  /* Stabs debugging sections.  */					\
24  .stab          0 : { *(.stab) }					\
25  .stabstr       0 : { *(.stabstr) }					\
26  .stab.excl     0 : { *(.stab.excl) }					\
27  .stab.exclstr  0 : { *(.stab.exclstr) }				\
28  .stab.index    0 : { *(.stab.index) }					\
29  .stab.indexstr 0 : { *(.stab.indexstr) }				\
30  .comment       0 : { *(.comment) }					\
31  /* DWARF debug sections.						\
32     Symbols in the DWARF debugging sections are relative to the beginning \
33     of the section so we begin them at 0.  */				\
34  /* DWARF 1 */								\
35  .debug          0 : { *(.debug) }					\
36  .line           0 : { *(.line) }					\
37  /* GNU DWARF 1 extensions */						\
38  .debug_srcinfo  0 : { *(.debug_srcinfo) }				\
39  .debug_sfnames  0 : { *(.debug_sfnames) }				\
40  /* DWARF 1.1 and DWARF 2 */						\
41  .debug_aranges  0 : { *(.debug_aranges) }				\
42  .debug_pubnames 0 : { *(.debug_pubnames) }				\
43  /* DWARF 2 */								\
44  .debug_info     0 : { *(.debug_info .gnu.linkonce.wi.*) }		\
45  .debug_abbrev   0 : { *(.debug_abbrev) }				\
46  .debug_line     0 : { *(.debug_line .debug_line.* .debug_line_end ) }	\
47  .debug_frame    0 : { *(.debug_frame) }				\
48  .debug_str      0 : { *(.debug_str) }					\
49  .debug_loc      0 : { *(.debug_loc) }					\
50  .debug_macinfo  0 : { *(.debug_macinfo) }				\
51  /* SGI/MIPS DWARF 2 extensions */					\
52  .debug_weaknames 0 : { *(.debug_weaknames) }				\
53  .debug_funcnames 0 : { *(.debug_funcnames) }				\
54  .debug_typenames 0 : { *(.debug_typenames) }				\
55  .debug_varnames  0 : { *(.debug_varnames) }				\
56  /* DWARF 3 */								\
57  .debug_pubtypes 0 : { *(.debug_pubtypes) }				\
58  .debug_ranges   0 : { *(.debug_ranges) }				\
59  /* DWARF Extension.  */						\
60  .debug_macro    0 : { *(.debug_macro) }				\
61  .debug_addr     0 : { *(.debug_addr) }
62
63ENTRY(boot_entry);
64SECTIONS
65{
66	_start = .;
67	. = 0;
68
69	.head : {
70		KEEP(*(.head))
71	}
72
73	. = SPIRA_OFF;
74	.spira : {
75		KEEP(*(.spira.data))
76	}
77
78	. = SPIRAH_OFF;
79	.spirah : {
80		KEEP(*(.spirah.data))
81	}
82
83	. = PROCIN_OFF;
84	.procin.data : {
85		KEEP(*(.procin.data))
86	}
87
88	. = MDST_TABLE_OFF;
89	.mdst : {
90		KEEP(*(.mdst.data))
91	}
92
93	. = CPU_CTL_OFF;
94	.cpuctrl : {
95		KEEP(*(.cpuctrl.data))
96	}
97
98	. = ALIGN(0x10);
99	_stext = .;
100 	.text : {
101		*(.text*)
102		*(.sfpr .glink)
103	}
104	_etext = .;
105
106	.rodata : {
107		__rodata_start = .;
108		*(.rodata .rodata.*)
109		__rodata_end = .;
110	}
111
112	. = ALIGN(0x10);
113	.init : {
114		__ctors_start = .;
115		KEEP(*(.ctors*))
116		KEEP(*(SORT(.init_array.*)))
117		KEEP(*(.init_array))
118		__ctors_end = .;
119	}
120
121	. = ALIGN(0x10);
122	.opd : {
123		*(.opd)
124	}
125
126	. = ALIGN(0x100);
127	.got : {
128		__toc_start = . + 0x8000;
129		*(.got)
130		*(.toc)
131	}
132
133	. = ALIGN(0x10);
134	.opal_table : {
135		__opal_table_start = .;
136		KEEP(*(.opal_table))
137		__opal_table_end = .;
138	}
139
140	.platforms : {
141		__platforms_start = .;
142		KEEP(*(.platforms))
143		__platforms_end = .;
144	}
145
146	/* Do I need to keep these ? */
147	.dynsym : { *(.dynsym)	}
148	.dynstr : { *(.dynstr)	}
149
150	/* Relocations */
151	. = ALIGN(0x10);
152	.dynamic : {
153		__dynamic_start = .;
154		*(.dynamic)
155		__dynamic_end = .;
156	}
157
158	. = ALIGN(0x10);
159	.rela.dyn : {
160		__rela_dyn_start = .;
161		*(.rela*)
162		__rela_dyn_end = .;
163	}
164	.plt    : { *(.plt) *(.iplt) }
165
166	.hash          : { *(.hash)   }
167	.gnu.hash      : { *(.gnu.hash) }
168	.dynsym        : { *(.dynsym) }
169	.dynstr        : { *(.dynstr) }
170	.gnu.version   : { *(.gnu.version) }
171	.gnu.version_d : { *(.gnu.version_d) }
172	.gnu.version_r : { *(.gnu.version_r) }
173
174	. = ALIGN(0x10);
175	.sym_map : {
176		__sym_map_start = . ;
177		KEEP(*(.sym_map))
178		__sym_map_end = . ;
179	}
180
181	/*
182	 * Memory above this point should be un-changing after the OS
183	 * boots, and is verified with a checksum upon fast reboot.
184	 */
185	_romem_end = .;
186
187	.data : {
188		/*
189		 * A couple of things that need to be 4K aligned and
190		 * to reside in their own pages for the sake of TCE
191		 * mappings
192		 */
193		. = ALIGN(0x1000);
194		*(.data.memcons);
195		. = ALIGN(0x10000);
196		*(.data.boot_trace);
197		. = ALIGN(0x10000);
198		*(.data*)
199		*(.force.data)
200		*(.toc1)
201		*(.branch_lt)
202	}
203
204	/* We locate the BSS at 4M to leave room for the symbol map */
205	. = 0x400000;
206
207	_sbss = .;
208	.bss : {
209		*(.dynbss)
210		*(.bss*)
211	}
212	. = ALIGN(0x10000);
213	_ebss = .;
214	_end = .;
215
216	DEBUG_SECTIONS
217
218	/* Optional kernel image */
219       . = ALIGN(0x10000);
220       .builtin_kernel : {
221		__builtin_kernel_start = .;
222		KEEP(*(.builtin_kernel))
223		__builtin_kernel_end = .;
224	}
225
226	/* Discards */
227	/DISCARD/ : {
228		*(.note.GNU-stack)
229		*(.comment)
230		*(.eh_frame)
231		*(.interp)
232		*(.fini_array.*)
233	}
234}
235