1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @ingroup bsp_linker |
---|
5 | * |
---|
6 | * @brief Linker command base file. |
---|
7 | */ |
---|
8 | |
---|
9 | /* |
---|
10 | * COPYRIGHT (c) 2014 Hesham ALMatary <heshamelmatary@gmail.com> |
---|
11 | * |
---|
12 | * The license and distribution terms for this file may be |
---|
13 | * found in the file LICENSE in this distribution or at |
---|
14 | * http://www.rtems.org/license/LICENSE |
---|
15 | */ |
---|
16 | |
---|
17 | OUTPUT_ARCH (or1k) |
---|
18 | |
---|
19 | ENTRY (_start) |
---|
20 | STARTUP (start.o) |
---|
21 | |
---|
22 | /* |
---|
23 | * Global symbols that may be defined externally |
---|
24 | */ |
---|
25 | |
---|
26 | bsp_start_vector_table_begin = 0x1F00; |
---|
27 | bsp_vector_table_size = DEFINED (bsp_vector_table_size) ? bsp_vector_table_size |
---|
28 | : 8260; |
---|
29 | /* 8192 for raw vector table, and 17 * 4 for handlers vector. */ |
---|
30 | |
---|
31 | bsp_section_xbarrier_align = DEFINED (bsp_section_xbarrier_align) ? bsp_section_xbarrier_align : 1; |
---|
32 | bsp_section_robarrier_align = DEFINED (bsp_section_robarrier_align) ? bsp_section_robarrier_align : 1; |
---|
33 | bsp_section_rwbarrier_align = DEFINED (bsp_section_rwbarrier_align) ? bsp_section_rwbarrier_align : 1; |
---|
34 | |
---|
35 | bsp_stack_align = DEFINED (bsp_stack_align) ? bsp_stack_align : 8; |
---|
36 | |
---|
37 | bsp_stack_main_size = DEFINED (bsp_stack_main_size) ? bsp_stack_main_size : 0; |
---|
38 | bsp_stack_main_size = ALIGN (bsp_stack_main_size, bsp_stack_align); |
---|
39 | |
---|
40 | SECTIONS { |
---|
41 | |
---|
42 | .vector : ALIGN_WITH_INPUT { |
---|
43 | *(.vector) |
---|
44 | . = ALIGN(bsp_vector_table_size); |
---|
45 | bsp_section_vector_end = .; |
---|
46 | } > REGION_VECTOR AT > REGION_VECTOR |
---|
47 | bsp_section_vector_size = bsp_section_vector_end - bsp_section_vector_begin; |
---|
48 | bsp_vector_table_begin = bsp_section_vector_begin; |
---|
49 | bsp_vector_table_end = bsp_vector_table_begin + bsp_vector_table_size; |
---|
50 | |
---|
51 | .start : ALIGN_WITH_INPUT { |
---|
52 | bsp_section_start_begin = .; |
---|
53 | KEEP (*(.bsp_start_text)) |
---|
54 | KEEP (*(.bsp_start_data)) |
---|
55 | bsp_section_start_end = .; |
---|
56 | } > REGION_START AT > REGION_START |
---|
57 | bsp_section_start_size = bsp_section_start_end - bsp_section_start_begin; |
---|
58 | |
---|
59 | .xbarrier : ALIGN_WITH_INPUT { |
---|
60 | . = ALIGN (bsp_section_xbarrier_align); |
---|
61 | } > REGION_VECTOR AT > REGION_VECTOR |
---|
62 | |
---|
63 | .text : ALIGN_WITH_INPUT { |
---|
64 | bsp_section_text_begin = .; |
---|
65 | *(.text.unlikely .text.*_unlikely) |
---|
66 | *(.text .stub .text.* .gnu.linkonce.t.*) |
---|
67 | /* .gnu.warning sections are handled specially by elf32.em. */ |
---|
68 | *(.gnu.warning) |
---|
69 | *(.glue_7t) *(.glue_7) *(.vfp11_veneer) *(.v4_bx) |
---|
70 | } > REGION_TEXT AT > REGION_TEXT_LOAD |
---|
71 | .init : ALIGN_WITH_INPUT { |
---|
72 | KEEP (*(.init)) |
---|
73 | } > REGION_TEXT AT > REGION_TEXT_LOAD |
---|
74 | .fini : ALIGN_WITH_INPUT { |
---|
75 | KEEP (*(.fini)) |
---|
76 | bsp_section_text_end = .; |
---|
77 | } > REGION_TEXT AT > REGION_TEXT_LOAD |
---|
78 | bsp_section_text_size = bsp_section_text_end - bsp_section_text_begin; |
---|
79 | bsp_section_text_load_begin = LOADADDR (.text); |
---|
80 | bsp_section_text_load_end = bsp_section_text_load_begin + bsp_section_text_size; |
---|
81 | |
---|
82 | .robarrier : ALIGN_WITH_INPUT { |
---|
83 | . = ALIGN (bsp_section_robarrier_align); |
---|
84 | } > REGION_RODATA AT > REGION_RODATA |
---|
85 | |
---|
86 | .rodata : ALIGN_WITH_INPUT { |
---|
87 | bsp_section_rodata_begin = .; |
---|
88 | *(.rodata .rodata.* .gnu.linkonce.r.*) |
---|
89 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
90 | .eh_frame : ALIGN_WITH_INPUT { |
---|
91 | KEEP (*(.eh_frame)) |
---|
92 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
93 | .gcc_except_table : ALIGN_WITH_INPUT { |
---|
94 | *(.gcc_except_table .gcc_except_table.*) |
---|
95 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
96 | .tdata : ALIGN_WITH_INPUT { |
---|
97 | _TLS_Data_begin = .; |
---|
98 | *(.tdata .tdata.* .gnu.linkonce.td.*) |
---|
99 | _TLS_Data_end = .; |
---|
100 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
101 | .tbss : ALIGN_WITH_INPUT { |
---|
102 | _TLS_BSS_begin = .; |
---|
103 | *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) |
---|
104 | _TLS_BSS_end = .; |
---|
105 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
106 | _TLS_Data_size = _TLS_Data_end - _TLS_Data_begin; |
---|
107 | _TLS_Data_begin = _TLS_Data_size != 0 ? _TLS_Data_begin : _TLS_BSS_begin; |
---|
108 | _TLS_Data_end = _TLS_Data_size != 0 ? _TLS_Data_end : _TLS_BSS_begin; |
---|
109 | _TLS_BSS_size = _TLS_BSS_end - _TLS_BSS_begin; |
---|
110 | _TLS_Size = _TLS_BSS_end - _TLS_Data_begin; |
---|
111 | _TLS_Alignment = MAX (ALIGNOF (.tdata), ALIGNOF (.tbss)); |
---|
112 | .preinit_array : ALIGN_WITH_INPUT { |
---|
113 | PROVIDE_HIDDEN (__preinit_array_start = .); |
---|
114 | KEEP (*(.preinit_array)) |
---|
115 | PROVIDE_HIDDEN (__preinit_array_end = .); |
---|
116 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
117 | .init_array : ALIGN_WITH_INPUT { |
---|
118 | PROVIDE_HIDDEN (__init_array_start = .); |
---|
119 | KEEP (*(SORT(.init_array.*))) |
---|
120 | KEEP (*(.init_array)) |
---|
121 | PROVIDE_HIDDEN (__init_array_end = .); |
---|
122 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
123 | .fini_array : ALIGN_WITH_INPUT { |
---|
124 | PROVIDE_HIDDEN (__fini_array_start = .); |
---|
125 | KEEP (*(.fini_array)) |
---|
126 | KEEP (*(SORT(.fini_array.*))) |
---|
127 | PROVIDE_HIDDEN (__fini_array_end = .); |
---|
128 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
129 | .ctors : ALIGN_WITH_INPUT { |
---|
130 | /* gcc uses crtbegin.o to find the start of |
---|
131 | the constructors, so we make sure it is |
---|
132 | first. Because this is a wildcard, it |
---|
133 | doesn't matter if the user does not |
---|
134 | actually link against crtbegin.o; the |
---|
135 | linker won't look for a file to match a |
---|
136 | wildcard. The wildcard also means that it |
---|
137 | doesn't matter which directory crtbegin.o |
---|
138 | is in. */ |
---|
139 | KEEP (*crtbegin.o(.ctors)) |
---|
140 | KEEP (*crtbegin?.o(.ctors)) |
---|
141 | /* We don't want to include the .ctor section from |
---|
142 | the crtend.o file until after the sorted ctors. |
---|
143 | The .ctor section from the crtend file contains the |
---|
144 | end of ctors marker and it must be last */ |
---|
145 | KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors)) |
---|
146 | KEEP (*(SORT(.ctors.*))) |
---|
147 | KEEP (*(.ctors)) |
---|
148 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
149 | .dtors : ALIGN_WITH_INPUT { |
---|
150 | KEEP (*crtbegin.o(.dtors)) |
---|
151 | KEEP (*crtbegin?.o(.dtors)) |
---|
152 | KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors)) |
---|
153 | KEEP (*(SORT(.dtors.*))) |
---|
154 | KEEP (*(.dtors)) |
---|
155 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
156 | .data.rel.ro : ALIGN_WITH_INPUT { |
---|
157 | *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) |
---|
158 | *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) |
---|
159 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
160 | .jcr : ALIGN_WITH_INPUT { |
---|
161 | KEEP (*(.jcr)) |
---|
162 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
163 | .interp : ALIGN_WITH_INPUT { |
---|
164 | *(.interp) |
---|
165 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
166 | .note.gnu.build-id : ALIGN_WITH_INPUT { |
---|
167 | *(.note.gnu.build-id) |
---|
168 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
169 | .hash : ALIGN_WITH_INPUT { |
---|
170 | *(.hash) |
---|
171 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
172 | .gnu.hash : ALIGN_WITH_INPUT { |
---|
173 | *(.gnu.hash) |
---|
174 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
175 | .dynsym : ALIGN_WITH_INPUT { |
---|
176 | *(.dynsym) |
---|
177 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
178 | .dynstr : ALIGN_WITH_INPUT { |
---|
179 | *(.dynstr) |
---|
180 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
181 | .gnu.version : ALIGN_WITH_INPUT { |
---|
182 | *(.gnu.version) |
---|
183 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
184 | .gnu.version_d : ALIGN_WITH_INPUT { |
---|
185 | *(.gnu.version_d) |
---|
186 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
187 | .gnu.version_r : ALIGN_WITH_INPUT { |
---|
188 | *(.gnu.version_r) |
---|
189 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
190 | .rel.dyn : ALIGN_WITH_INPUT { |
---|
191 | *(.rel.init) |
---|
192 | *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) |
---|
193 | *(.rel.fini) |
---|
194 | *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) |
---|
195 | *(.rel.data.rel.ro* .rel.gnu.linkonce.d.rel.ro.*) |
---|
196 | *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) |
---|
197 | *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) |
---|
198 | *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) |
---|
199 | *(.rel.ctors) |
---|
200 | *(.rel.dtors) |
---|
201 | *(.rel.got) |
---|
202 | *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) |
---|
203 | PROVIDE_HIDDEN (__rel_iplt_start = .); |
---|
204 | *(.rel.iplt) |
---|
205 | PROVIDE_HIDDEN (__rel_iplt_end = .); |
---|
206 | PROVIDE_HIDDEN (__rela_iplt_start = .); |
---|
207 | PROVIDE_HIDDEN (__rela_iplt_end = .); |
---|
208 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
209 | .rela.dyn : ALIGN_WITH_INPUT { |
---|
210 | *(.rela.init) |
---|
211 | *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) |
---|
212 | *(.rela.fini) |
---|
213 | *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) |
---|
214 | *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) |
---|
215 | *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) |
---|
216 | *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) |
---|
217 | *(.rela.ctors) |
---|
218 | *(.rela.dtors) |
---|
219 | *(.rela.got) |
---|
220 | *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) |
---|
221 | *(.rela.rtemsroset*) |
---|
222 | *(.rela.rtemsrwset*) |
---|
223 | PROVIDE_HIDDEN (__rel_iplt_start = .); |
---|
224 | PROVIDE_HIDDEN (__rel_iplt_end = .); |
---|
225 | PROVIDE_HIDDEN (__rela_iplt_start = .); |
---|
226 | *(.rela.iplt) |
---|
227 | PROVIDE_HIDDEN (__rela_iplt_end = .); |
---|
228 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
229 | .rel.plt : ALIGN_WITH_INPUT { |
---|
230 | *(.rel.plt) |
---|
231 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
232 | .rela.plt : ALIGN_WITH_INPUT { |
---|
233 | *(.rela.plt) |
---|
234 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
235 | .plt : ALIGN_WITH_INPUT { |
---|
236 | *(.plt) |
---|
237 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
238 | .iplt : ALIGN_WITH_INPUT { |
---|
239 | *(.iplt) |
---|
240 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
241 | .dynamic : ALIGN_WITH_INPUT { |
---|
242 | *(.dynamic) |
---|
243 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
244 | .got : ALIGN_WITH_INPUT { |
---|
245 | *(.got.plt) *(.igot.plt) *(.got) *(.igot) |
---|
246 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
247 | .rtemsroset : ALIGN_WITH_INPUT { |
---|
248 | /* Special FreeBSD linker set sections */ |
---|
249 | __start_set_sysctl_set = .; |
---|
250 | *(set_sysctl_*); |
---|
251 | __stop_set_sysctl_set = .; |
---|
252 | *(set_domain_*); |
---|
253 | *(set_pseudo_*); |
---|
254 | |
---|
255 | KEEP (*(SORT(.rtemsroset.*))) |
---|
256 | bsp_section_rodata_end = .; |
---|
257 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
258 | bsp_section_rodata_size = bsp_section_rodata_end - bsp_section_rodata_begin; |
---|
259 | bsp_section_rodata_load_begin = LOADADDR (.rodata); |
---|
260 | bsp_section_rodata_load_end = bsp_section_rodata_load_begin + bsp_section_rodata_size; |
---|
261 | |
---|
262 | .rwbarrier : ALIGN_WITH_INPUT { |
---|
263 | . = ALIGN (bsp_section_rwbarrier_align); |
---|
264 | } > REGION_DATA AT > REGION_DATA |
---|
265 | |
---|
266 | .data : ALIGN_WITH_INPUT { |
---|
267 | bsp_section_data_begin = .; |
---|
268 | *(.data .data.* .gnu.linkonce.d.*) |
---|
269 | SORT(CONSTRUCTORS) |
---|
270 | } > REGION_DATA AT > REGION_DATA_LOAD |
---|
271 | .data1 : ALIGN_WITH_INPUT { |
---|
272 | *(.data1) |
---|
273 | } > REGION_DATA AT > REGION_DATA_LOAD |
---|
274 | .rtemsrwset : ALIGN_WITH_INPUT { |
---|
275 | KEEP (*(SORT(.rtemsrwset.*))) |
---|
276 | bsp_section_data_end = .; |
---|
277 | } > REGION_DATA AT > REGION_DATA_LOAD |
---|
278 | bsp_section_data_size = bsp_section_data_end - bsp_section_data_begin; |
---|
279 | bsp_section_data_load_begin = LOADADDR (.data); |
---|
280 | bsp_section_data_load_end = bsp_section_data_load_begin + bsp_section_data_size; |
---|
281 | |
---|
282 | .bss : ALIGN_WITH_INPUT { |
---|
283 | bsp_section_bss_begin = .; |
---|
284 | *(.dynbss) |
---|
285 | *(.bss .bss.* .gnu.linkonce.b.*) |
---|
286 | *(COMMON) |
---|
287 | bsp_section_bss_end = .; |
---|
288 | } > REGION_BSS AT > REGION_BSS |
---|
289 | bsp_section_bss_size = bsp_section_bss_end - bsp_section_bss_begin; |
---|
290 | |
---|
291 | .rtemsstack (NOLOAD) : ALIGN_WITH_INPUT{ |
---|
292 | *(SORT(.rtemsstack.*)) |
---|
293 | } > REGION_WORK AT > REGION_WORK |
---|
294 | |
---|
295 | .work : ALIGN_WITH_INPUT { |
---|
296 | /* |
---|
297 | * The work section will occupy the remaining REGION_WORK region and |
---|
298 | * contains the RTEMS work space and heap. |
---|
299 | */ |
---|
300 | bsp_section_work_begin = .; |
---|
301 | . += ORIGIN (REGION_WORK) + LENGTH (REGION_WORK) - ABSOLUTE (.); |
---|
302 | bsp_section_work_end = .; |
---|
303 | } > REGION_WORK AT > REGION_WORK |
---|
304 | bsp_section_work_size = bsp_section_work_end - bsp_section_work_begin; |
---|
305 | |
---|
306 | .stack : ALIGN_WITH_INPUT { |
---|
307 | bsp_section_stack_end = .; |
---|
308 | } > REGION_STACK AT > REGION_STACK |
---|
309 | bsp_section_stack_size = bsp_section_stack_begin - bsp_section_stack_end; |
---|
310 | |
---|
311 | RamBase = ORIGIN (REGION_WORK); |
---|
312 | RamSize = LENGTH (REGION_WORK); |
---|
313 | RamEnd = RamBase + RamSize; |
---|
314 | WorkAreaBase = bsp_section_work_begin; |
---|
315 | HeapSize = 0; |
---|
316 | } |
---|