]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - ld/scripttempl/elfm68hc12.sc
* gas/all/gas.exp (incbin): Fix condition.
[thirdparty/binutils-gdb.git] / ld / scripttempl / elfm68hc12.sc
CommitLineData
60bcf0fa
NC
1#
2# Unusual variables checked by this code:
563e308f 3# NOP - four byte opcode for no-op (defaults to 0)
60bcf0fa
NC
4# DATA_ADDR - if end-of-text-plus-one-page isn't right for data start
5# OTHER_READWRITE_SECTIONS - other than .data .bss .ctors .sdata ...
6# (e.g., .PARISC.global)
7# OTHER_SECTIONS - at the end
8# EXECUTABLE_SYMBOLS - symbols that must be defined for an
9# executable (e.g., _DYNAMIC_LINK)
10# TEXT_START_SYMBOLS - symbols that appear at the start of the
11# .text section.
12# DATA_START_SYMBOLS - symbols that appear at the start of the
13# .data section.
14# OTHER_BSS_SYMBOLS - symbols that appear at the start of the
15# .bss section besides __bss_start.
16# EMBEDDED - whether this is for an embedded system.
17#
18# When adding sections, do note that the names of some sections are used
19# when specifying the start address of the next.
20#
21test -z "$ENTRY" && ENTRY=_start
22test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT}
23test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT}
24if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi
25test "$LD_FLAG" = "N" && DATA_ADDR=.
26
27CTOR=".ctors ${CONSTRUCTING-0} :
28 {
de0b1853 29 ${CONSTRUCTING+ PROVIDE (__CTOR_LIST__ = .); }
60bcf0fa
NC
30 ${CONSTRUCTING+${CTOR_START}}
31 *(.ctors)
32 /* We don't want to include the .ctor section from
33 from the crtend.o file until after the sorted ctors.
34 The .ctor section from the crtend file contains the
35 end of ctors marker and it must be last
36
37 KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
38 KEEP (*(SORT(.ctors.*)))
39 KEEP (*(.ctors)) */
40
41 ${CONSTRUCTING+${CTOR_END}}
de0b1853 42 ${CONSTRUCTING+ PROVIDE(__CTOR_END__ = .); }
60bcf0fa
NC
43 } ${RELOCATING+ > ${DATA_MEMORY}}"
44
45DTOR=" .dtors ${CONSTRUCTING-0} :
46 {
de0b1853 47 ${CONSTRUCTING+ PROVIDE(__DTOR_LIST__ = .); }
60bcf0fa
NC
48 *(.dtors)
49 /*
50 KEEP (*crtbegin.o(.dtors))
51 KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
52 KEEP (*(SORT(.dtors.*)))
53 KEEP (*(.dtors)) */
de0b1853 54 ${CONSTRUCTING+ PROVIDE(__DTOR_END__ = .); }
60bcf0fa
NC
55 } ${RELOCATING+ > ${DATA_MEMORY}}"
56
57
58VECTORS="
59 /* If the 'vectors_addr' symbol is defined, it indicates the start address
60 of interrupt vectors. This depends on the 68HC11 operating mode:
61
62 Addr
63 Single chip 0xffc0
64 Extended mode 0xffc0
65 Bootstrap 0x00c0
66 Test 0xbfc0
67
68 In general, the vectors address is 0xffc0. This can be overriden
69 with the '-defsym vectors_addr=0xbfc0' ld option.
70
71 Note: for the bootstrap mode, the interrupt vectors are at 0xbfc0 but
72 they are redirected to 0x00c0 by the internal PROM. Application's vectors
73 must also consist of jump instructions (see Motorola's manual). */
74
75 PROVIDE (_vectors_addr = DEFINED (vectors_addr) ? vectors_addr : 0xffc0);
76 .vectors DEFINED (vectors_addr) ? vectors_addr : 0xffc0 :
77 {
78 *(.vectors)
79 }"
80
81#
82# We provide two emulations: a fixed on that defines some memory banks
83# and a configurable one that includes a user provided memory definition.
84#
85case $GENERIC_BOARD in
86 yes|1|YES)
87 MEMORY_DEF="
88/* Get memory banks definition from some user configuration file.
89 This file must be located in some linker directory (search path
90 with -L<dir>). See fixed memory banks emulation script. */
91INCLUDE memory.x;
92"
93 ;;
94 *)
95MEMORY_DEF="
96/* Fixed definition of the available memory banks.
97 See generic emulation script for a user defined configuration. */
98MEMORY
99{
100 page0 (rwx) : ORIGIN = 0x0, LENGTH = 256
101 text (rx) : ORIGIN = ${ROM_START_ADDR}, LENGTH = ${ROM_SIZE}
102 data : ORIGIN = ${RAM_START_ADDR}, LENGTH = ${RAM_SIZE}
103}
104
105/* Setup the stack on the top of the data memory bank. */
106PROVIDE (_stack = ${RAM_START_ADDR} + ${RAM_SIZE} - 1);
107"
108 ;;
109esac
110
111STARTUP_CODE="
112 /* Startup code. */
113 *(.install0) /* Section should setup the stack pointer. */
114 *(.install1) /* Place holder for applications. */
115 *(.install2) /* Optional installation of data sections in RAM. */
116 *(.install3) /* Place holder for applications. */
117 *(.install4) /* Section that calls the main. */
118"
119
de0b1853
SC
120FINISH_CODE="
121 /* Finish code. */
122 *(.fini0) /* Beginning of finish code (_exit symbol). */
123 *(.fini1) /* Place holder for applications. */
124 *(.fini2) /* C++ destructors. */
125 *(.fini3) /* Place holder for applications. */
126 *(.fini4) /* Runtime exit. */
127"
128
60bcf0fa
NC
129PRE_COMPUTE_DATA_SIZE="
130/* SCz: this does not work yet... This is supposed to force the loading
131 of _map_data.o (from libgcc.a) when the .data section is not empty.
132 By doing so, this should bring the code that copies the .data section
133 from ROM to RAM at init time.
134
135 ___pre_comp_data_size = SIZEOF(.data);
136 __install_data_sections = ___pre_comp_data_size > 0 ?
137 __map_data_sections : 0;
138*/
139"
140
141INSTALL_RELOC="
142 .install0 0 : { *(.install0) }
143 .install1 0 : { *(.install1) }
144 .install2 0 : { *(.install2) }
145 .install3 0 : { *(.install3) }
146 .install4 0 : { *(.install4) }
147"
148
de0b1853
SC
149FINISH_RELOC="
150 .fini0 0 : { *(.fini0) }
151 .fini1 0 : { *(.fini1) }
152 .fini2 0 : { *(.fini2) }
153 .fini3 0 : { *(.fini3) }
154 .fini4 0 : { *(.fini4) }
155"
156
60bcf0fa
NC
157BSS_DATA_RELOC="
158 .data1 0 : { *(.data1) }
159
160 /* We want the small data sections together, so single-instruction offsets
161 can access them all, and initialized data all before uninitialized, so
162 we can shorten the on-disk segment size. */
163 .sdata 0 : { *(.sdata) }
164 .sbss 0 : { *(.sbss) }
165 .scommon 0 : { *(.scommon) }
166"
167
168cat <<EOF
169${RELOCATING+/* Linker script for 68HC12 executable (PROM). */}
170${RELOCATING-/* Linker script for 68HC12 object file (ld -r). */}
171
172OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}",
173 "${LITTLE_OUTPUT_FORMAT}")
174OUTPUT_ARCH(${OUTPUT_ARCH})
175ENTRY(${ENTRY})
176
177${RELOCATING+${LIB_SEARCH_DIRS}}
178${RELOCATING+${EXECUTABLE_SYMBOLS}}
179${RELOCATING+${MEMORY_DEF}}
180
181SECTIONS
182{
183 .hash ${RELOCATING-0} : { *(.hash) }
184 .dynsym ${RELOCATING-0} : { *(.dynsym) }
185 .dynstr ${RELOCATING-0} : { *(.dynstr) }
186 .gnu.version ${RELOCATING-0} : { *(.gnu.version) }
187 .gnu.version_d ${RELOCATING-0} : { *(.gnu.version_d) }
188 .gnu.version_r ${RELOCATING-0} : { *(.gnu.version_r) }
189
de0b1853
SC
190 .rel.text ${RELOCATING-0} :
191 {
192 *(.rel.text)
193 ${RELOCATING+*(.rel.text.*)}
194 ${RELOCATING+*(.rel.gnu.linkonce.t.*)}
195 }
196 .rela.text ${RELOCATING-0} :
197 {
198 *(.rela.text)
199 ${RELOCATING+*(.rela.text.*)}
200 ${RELOCATING+*(.rela.gnu.linkonce.t.*)}
201 }
202 .rel.data ${RELOCATING-0} :
203 {
204 *(.rel.data)
205 ${RELOCATING+*(.rel.data.*)}
206 ${RELOCATING+*(.rel.gnu.linkonce.d.*)}
207 }
208 .rela.data ${RELOCATING-0} :
209 {
210 *(.rela.data)
211 ${RELOCATING+*(.rela.data.*)}
212 ${RELOCATING+*(.rela.gnu.linkonce.d.*)}
213 }
214 .rel.rodata ${RELOCATING-0} :
215 {
216 *(.rel.rodata)
217 ${RELOCATING+*(.rel.rodata.*)}
218 ${RELOCATING+*(.rel.gnu.linkonce.r.*)}
219 }
220 .rela.rodata ${RELOCATING-0} :
221 {
222 *(.rela.rodata)
223 ${RELOCATING+*(.rela.rodata.*)}
224 ${RELOCATING+*(.rela.gnu.linkonce.r.*)}
225 }
226 .rel.sdata ${RELOCATING-0} :
227 {
228 *(.rel.sdata)
229 ${RELOCATING+*(.rel.sdata.*)}
230 ${RELOCATING+*(.rel.gnu.linkonce.s.*)}
231 }
232 .rela.sdata ${RELOCATING-0} :
233 {
234 *(.rela.sdata)
235 ${RELOCATING+*(.rela.sdata.*)}
236 ${RELOCATING+*(.rela.gnu.linkonce.s.*)}
237 }
238 .rel.sbss ${RELOCATING-0} :
239 {
240 *(.rel.sbss)
241 ${RELOCATING+*(.rel.sbss.*)}
242 ${RELOCATING+*(.rel.gnu.linkonce.sb.*)}
243 }
244 .rela.sbss ${RELOCATING-0} :
245 {
246 *(.rela.sbss)
247 ${RELOCATING+*(.rela.sbss.*)}
248 ${RELOCATING+*(.rel.gnu.linkonce.sb.*)}
249 }
250 .rel.bss ${RELOCATING-0} :
251 {
252 *(.rel.bss)
253 ${RELOCATING+*(.rel.bss.*)}
254 ${RELOCATING+*(.rel.gnu.linkonce.b.*)}
255 }
256 .rela.bss ${RELOCATING-0} :
257 {
258 *(.rela.bss)
259 ${RELOCATING+*(.rela.bss.*)}
260 ${RELOCATING+*(.rela.gnu.linkonce.b.*)}
261 }
60bcf0fa
NC
262 .rela.stext ${RELOCATING-0} : { *(.rela.stest) }
263 .rela.etext ${RELOCATING-0} : { *(.rela.etest) }
264 .rela.sdata ${RELOCATING-0} : { *(.rela.sdata) }
265 .rela.edata ${RELOCATING-0} : { *(.rela.edata) }
266 .rela.eit_v ${RELOCATING-0} : { *(.rela.eit_v) }
60bcf0fa
NC
267 .rela.ebss ${RELOCATING-0} : { *(.rela.ebss) }
268 .rela.srodata ${RELOCATING-0} : { *(.rela.srodata) }
269 .rela.erodata ${RELOCATING-0} : { *(.rela.erodata) }
270 .rela.got ${RELOCATING-0} : { *(.rela.got) }
271 .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) }
272 .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) }
273 .rela.init ${RELOCATING-0} : { *(.rela.init) }
274 .rela.fini ${RELOCATING-0} : { *(.rela.fini) }
60bcf0fa
NC
275 .rela.plt ${RELOCATING-0} : { *(.rela.plt) }
276
60bcf0fa
NC
277 .rel.stext ${RELOCATING-0} : { *(.rel.stest) }
278 .rel.etext ${RELOCATING-0} : { *(.rel.etest) }
279 .rel.sdata ${RELOCATING-0} : { *(.rel.sdata) }
280 .rel.edata ${RELOCATING-0} : { *(.rel.edata) }
60bcf0fa
NC
281 .rel.ebss ${RELOCATING-0} : { *(.rel.ebss) }
282 .rel.eit_v ${RELOCATING-0} : { *(.rel.eit_v) }
283 .rel.srodata ${RELOCATING-0} : { *(.rel.srodata) }
284 .rel.erodata ${RELOCATING-0} : { *(.rel.erodata) }
285 .rel.got ${RELOCATING-0} : { *(.rel.got) }
286 .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) }
287 .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) }
288 .rel.init ${RELOCATING-0} : { *(.rel.init) }
289 .rel.fini ${RELOCATING-0} : { *(.rel.fini) }
60bcf0fa
NC
290 .rel.plt ${RELOCATING-0} : { *(.rel.plt) }
291
292 /* Concatenate .page0 sections. Put them in the page0 memory bank
293 unless we are creating a relocatable file. */
294 .page0 :
295 {
296 *(.page0)
297 } ${RELOCATING+ > page0}
298
299 /* Start of text section. */
300 .stext ${RELOCATING-0} :
301 {
302 *(.stext)
303 } ${RELOCATING+ > ${TEXT_MEMORY}}
304
305 .init ${RELOCATING-0} :
306 {
307 *(.init)
308 } ${RELOCATING+=${NOP-0}}
309
310 ${RELOCATING-${INSTALL_RELOC}}
de0b1853 311 ${RELOCATING-${FINISH_RELOC}}
60bcf0fa
NC
312
313 .text ${RELOCATING-0}:
314 {
315 /* Put startup code at beginning so that _start keeps same address. */
316 ${RELOCATING+${STARTUP_CODE}}
317
318 ${RELOCATING+*(.init)}
319 *(.text)
de0b1853 320 ${RELOCATING+*(.text.*)}
60bcf0fa
NC
321 /* .gnu.warning sections are handled specially by elf32.em. */
322 *(.gnu.warning)
de0b1853
SC
323 ${RELOCATING+*(.gnu.linkonce.t.*)}
324
325 ${RELOCATING+${FINISH_CODE}}
60bcf0fa
NC
326
327 ${RELOCATING+_etext = .;}
328 ${RELOCATING+PROVIDE (etext = .);}
329
330 } ${RELOCATING+ > ${TEXT_MEMORY}}
331
332 .eh_frame ${RELOCATING-0} :
333 {
24098abb 334 KEEP (*(.eh_frame))
60bcf0fa
NC
335 } ${RELOCATING+ > ${TEXT_MEMORY}}
336
337 .rodata ${RELOCATING-0} :
338 {
339 *(.rodata)
de0b1853
SC
340 ${RELOCATING+*(.rodata.*)}
341 ${RELOCATING+*(.gnu.linkonce.r*)}
60bcf0fa
NC
342 } ${RELOCATING+ > ${TEXT_MEMORY}}
343
344 .rodata1 ${RELOCATING-0} :
345 {
346 *(.rodata1)
347 } ${RELOCATING+ > ${TEXT_MEMORY}}
348
de0b1853
SC
349 /* Constructor and destructor tables are in ROM. */
350 ${RELOCATING+${CTOR}}
351 ${RELOCATING+${DTOR}}
352
24098abb
RH
353 .jcr ${RELOCATING-0} :
354 {
355 KEEP (*(.jcr))
356 } ${RELOCATING+ > ${TEXT_MEMORY}}
357
60bcf0fa
NC
358 /* Start of the data section image in ROM. */
359 ${RELOCATING+__data_image = .;}
360 ${RELOCATING+PROVIDE (__data_image = .);}
361
362 /* All read-only sections that normally go in PROM must be above.
363 We construct the DATA image section in PROM at end of all these
364 read-only sections. The data image must be copied at init time.
365 Refer to GNU ld, Section 3.6.8.2 Output Section LMA. */
366 .data ${RELOCATING-0} : ${RELOCATING+AT (__data_image)}
367 {
368 ${RELOCATING+__data_section_start = .;}
369 ${RELOCATING+PROVIDE (__data_section_start = .);}
370
371 ${RELOCATING+${DATA_START_SYMBOLS}}
372 ${RELOCATING+*(.sdata)}
373 *(.data)
de0b1853 374 ${RELOCATING+*(.data.*)}
60bcf0fa 375 ${RELOCATING+*(.data1)}
de0b1853 376 ${RELOCATING+*(.gnu.linkonce.d.*)}
60bcf0fa
NC
377 ${CONSTRUCTING+CONSTRUCTORS}
378
379 ${RELOCATING+_edata = .;}
380 ${RELOCATING+PROVIDE (edata = .);}
381 } ${RELOCATING+ > ${DATA_MEMORY}}
382
383 ${RELOCATING+__data_section_size = SIZEOF(.data);}
384 ${RELOCATING+PROVIDE (__data_section_size = SIZEOF(.data));}
385 ${RELOCATING+__data_image_end = __data_image + __data_section_size;}
386
387 ${RELOCATING+${PRE_COMPUTE_DATA_SIZE}}
388
389 /* .install ${RELOCATING-0}:
390 {
391 . = _data_image_end;
392 } ${RELOCATING+ > ${TEXT_MEMORY}} */
393
394 /* Relocation for some bss and data sections. */
395 ${RELOCATING-${BSS_DATA_RELOC}}
396
397 .bss ${RELOCATING-0} :
398 {
399 ${RELOCATING+__bss_start = .;}
400 ${RELOCATING+*(.sbss)}
401 ${RELOCATING+*(.scommon)}
402
403 *(.dynbss)
404 *(.bss)
de0b1853
SC
405 ${RELOCATING+*(.bss.*)}
406 ${RELOCATING+*(.gnu.linkonce.b.*)}
60bcf0fa
NC
407 *(COMMON)
408 ${RELOCATING+PROVIDE (_end = .);}
409 } ${RELOCATING+ > ${DATA_MEMORY}}
236d5abf
NC
410 ${RELOCATING+__bss_size = SIZEOF(.bss);}
411 ${RELOCATING+PROVIDE (__bss_size = SIZEOF(.bss));}
60bcf0fa 412
60bcf0fa
NC
413 ${RELOCATING+${VECTORS}}
414
415 /* Stabs debugging sections. */
416 .stab 0 : { *(.stab) }
417 .stabstr 0 : { *(.stabstr) }
418 .stab.excl 0 : { *(.stab.excl) }
419 .stab.exclstr 0 : { *(.stab.exclstr) }
420 .stab.index 0 : { *(.stab.index) }
421 .stab.indexstr 0 : { *(.stab.indexstr) }
422
423 .comment 0 : { *(.comment) }
424
425 /* DWARF debug sections.
426 Symbols in the DWARF debugging sections are relative to the beginning
427 of the section so we begin them at 0.
428 Treatment of DWARF debug section must be at end of the linker
429 script to avoid problems when there are undefined symbols. It's necessary
430 to avoid that the DWARF section is relocated before such undefined
431 symbols are found. */
432
433 /* DWARF 1 */
434 .debug 0 : { *(.debug) }
435 .line 0 : { *(.line) }
436
437 /* GNU DWARF 1 extensions */
438 .debug_srcinfo 0 : { *(.debug_srcinfo) }
439 .debug_sfnames 0 : { *(.debug_sfnames) }
440
441 /* DWARF 1.1 and DWARF 2 */
442 .debug_aranges 0 : { *(.debug_aranges) }
443 .debug_pubnames 0 : { *(.debug_pubnames) }
444
445 /* DWARF 2 */
3a9d486c 446 .debug_info 0 : { *(.debug_info) *(.gnu.linkonce.wi.*) }
60bcf0fa
NC
447 .debug_abbrev 0 : { *(.debug_abbrev) }
448 .debug_line 0 : { *(.debug_line) }
449 .debug_frame 0 : { *(.debug_frame) }
450 .debug_str 0 : { *(.debug_str) }
451 .debug_loc 0 : { *(.debug_loc) }
452 .debug_macinfo 0 : { *(.debug_macinfo) }
453}
454EOF