1 # Copyright (C) 2014-2019 Free Software Foundation, Inc.
3 # Copying and distribution of this file, with or without modification,
4 # are permitted in any medium without royalty provided the copyright
5 # notice and this notice are preserved.
7 # Unusual variables checked by this code:
8 # NOP - four byte opcode for no-op (defaults to 0)
9 # DATA_ADDR - if end-of-text-plus-one-page isn't right for data start
10 # OTHER_READWRITE_SECTIONS - other than .data .bss .ctors .sdata ...
11 # (e.g., .PARISC.global)
12 # OTHER_SECTIONS - at the end
13 # EXECUTABLE_SYMBOLS - symbols that must be defined for an
14 # executable (e.g., _DYNAMIC_LINK)
15 # TEXT_START_SYMBOLS - symbols that appear at the start of the
17 # DATA_START_SYMBOLS - symbols that appear at the start of the
19 # OTHER_BSS_SYMBOLS - symbols that appear at the start of the
20 # .bss section besides __bss_start.
21 # EMBEDDED - whether this is for an embedded system.
23 # When adding sections, do note that the names of some sections are used
24 # when specifying the start address of the next.
26 test -z "$ENTRY" && ENTRY=_start
27 test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT}
28 test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT}
29 if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi
30 test "$LD_FLAG" = "N" && DATA_ADDR=.
32 CTOR=".ctors ${CONSTRUCTING-0} :
34 ${CONSTRUCTING+ PROVIDE (__CTOR_LIST__ = .); }
35 ${CONSTRUCTING+${CTOR_START}}
38 ${CONSTRUCTING+${CTOR_END}}
39 ${CONSTRUCTING+ PROVIDE(__CTOR_END__ = .); }
40 } ${RELOCATING+ > ${TEXT_MEMORY}}"
42 DTOR=" .dtors ${CONSTRUCTING-0} :
44 ${CONSTRUCTING+ PROVIDE(__DTOR_LIST__ = .); }
46 ${CONSTRUCTING+ PROVIDE(__DTOR_END__ = .); }
47 } ${RELOCATING+ > ${TEXT_MEMORY}}"
51 /* If the 'vectors_addr' symbol is defined, it indicates the start address
54 In general, the vectors address is 0xfffe00. This can be overriden
55 with the '-defsym vectors_addr=0xbfc000' ld option. If you do this,
56 then your startup code should also set the IVBR register accordingly.
59 PROVIDE (_vectors_addr = DEFINED (vectors_addr) ? vectors_addr : 0xfffe00);
60 .vectors DEFINED (vectors_addr) ? vectors_addr : 0xfffe00 :
66 # We provide two emulations: a fixed on that defines some memory banks
67 # and a configurable one that includes a user provided memory definition.
69 case $GENERIC_BOARD in
72 /* Get memory banks definition from some user configuration file.
73 This file must be located in some linker directory (search path
74 with -L<dir>). See fixed memory banks emulation script. */
80 /* Fixed definition of the available memory banks.
81 See generic emulation script for a user defined configuration. */
84 text (rx) : ORIGIN = $[$ROM_TOP - $ROM_SIZE + 1], LENGTH = ${ROM_SIZE} - 4
85 data : ORIGIN = ${RAM_START_ADDR}, LENGTH = ${RAM_SIZE}
86 eeprom : ORIGIN = ${EEPROM_START_ADDR}, LENGTH = ${EEPROM_SIZE}
87 rvec : ORIGIN = 0xFFFFFC, LENGTH = 4
90 /* Setup the stack on the top of the data memory bank. */
91 PROVIDE (_stack = ${RAM_START_ADDR} + ${RAM_SIZE} - 1);
98 KEEP (*(.install0)) /* Section should setup the stack pointer. */
99 KEEP (*(.install1)) /* Place holder for applications. */
100 KEEP (*(.install2)) /* Optional installation of data sections in RAM. */
101 KEEP (*(.install3)) /* Place holder for applications. */
102 KEEP (*(.install4)) /* Section that calls the main. */
107 KEEP (*(.fini0)) /* Beginning of finish code (_exit symbol). */
108 KEEP (*(.fini1)) /* Place holder for applications. */
109 KEEP (*(.fini2)) /* C++ destructors. */
110 KEEP (*(.fini3)) /* Place holder for applications. */
111 KEEP (*(.fini4)) /* Runtime exit. */
114 PRE_COMPUTE_DATA_SIZE="
115 /* SCz: this does not work yet... This is supposed to force the loading
116 of _map_data.o (from libgcc.a) when the .data section is not empty.
117 By doing so, this should bring the code that copies the .data section
118 from ROM to RAM at init time.
120 ___pre_comp_data_size = SIZEOF(.data);
121 __install_data_sections = ___pre_comp_data_size > 0 ?
122 __map_data_sections : 0;
127 .install0 0 : { *(.install0) }
128 .install1 0 : { *(.install1) }
129 .install2 0 : { *(.install2) }
130 .install3 0 : { *(.install3) }
131 .install4 0 : { *(.install4) }
135 .fini0 0 : { *(.fini0) }
136 .fini1 0 : { *(.fini1) }
137 .fini2 0 : { *(.fini2) }
138 .fini3 0 : { *(.fini3) }
139 .fini4 0 : { *(.fini4) }
143 .data1 0 : { *(.data1) }
145 /* We want the small data sections together, so single-instruction offsets
146 can access them all, and initialized data all before uninitialized, so
147 we can shorten the on-disk segment size. */
148 .sdata 0 : { *(.sdata) }
149 .sbss 0 : { *(.sbss) }
150 .scommon 0 : { *(.scommon) }
154 .softregs 0 : { *(.softregs) }
158 /* Copyright (C) 2014-2019 Free Software Foundation, Inc.
160 Copying and distribution of this script, with or without modification,
161 are permitted in any medium without royalty provided the copyright
162 notice and this notice are preserved. */
164 ${RELOCATING+/* Linker script for HCS12Z executable (PROM). */}
165 ${RELOCATING-/* Linker script for HCS12Z object file (ld -r). */}
167 OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}",
168 "${LITTLE_OUTPUT_FORMAT}")
169 OUTPUT_ARCH(${OUTPUT_ARCH})
170 ${RELOCATING+ENTRY(${ENTRY})}
172 ${RELOCATING+${LIB_SEARCH_DIRS}}
173 ${RELOCATING+${EXECUTABLE_SYMBOLS}}
174 ${RELOCATING+${MEMORY_DEF}}
176 ${RELOCATING+PROVIDE (_start = $[$ROM_TOP - $ROM_SIZE + 1]);}
179 .hash ${RELOCATING-0} : { *(.hash) }
180 .dynsym ${RELOCATING-0} : { *(.dynsym) }
181 .dynstr ${RELOCATING-0} : { *(.dynstr) }
182 .gnu.version ${RELOCATING-0} : { *(.gnu.version) }
183 .gnu.version_d ${RELOCATING-0} : { *(.gnu.version_d) }
184 .gnu.version_r ${RELOCATING-0} : { *(.gnu.version_r) }
186 .rel.text ${RELOCATING-0} :
189 ${RELOCATING+*(.rel.text.*)}
190 ${RELOCATING+*(.rel.gnu.linkonce.t.*)}
192 .rela.text ${RELOCATING-0} :
195 ${RELOCATING+*(.rela.text.*)}
196 ${RELOCATING+*(.rela.gnu.linkonce.t.*)}
198 .rel.data ${RELOCATING-0} :
201 ${RELOCATING+*(.rel.data.*)}
202 ${RELOCATING+*(.rel.gnu.linkonce.d.*)}
204 .rela.data ${RELOCATING-0} :
207 ${RELOCATING+*(.rela.data.*)}
208 ${RELOCATING+*(.rela.gnu.linkonce.d.*)}
210 .rel.rodata ${RELOCATING-0} :
213 ${RELOCATING+*(.rel.rodata.*)}
214 ${RELOCATING+*(.rel.gnu.linkonce.r.*)}
216 .rela.rodata ${RELOCATING-0} :
219 ${RELOCATING+*(.rela.rodata.*)}
220 ${RELOCATING+*(.rela.gnu.linkonce.r.*)}
222 .rel.sdata ${RELOCATING-0} :
225 ${RELOCATING+*(.rel.sdata.*)}
226 ${RELOCATING+*(.rel.gnu.linkonce.s.*)}
228 .rela.sdata ${RELOCATING-0} :
231 ${RELOCATING+*(.rela.sdata.*)}
232 ${RELOCATING+*(.rela.gnu.linkonce.s.*)}
234 .rel.sbss ${RELOCATING-0} :
237 ${RELOCATING+*(.rel.sbss.*)}
238 ${RELOCATING+*(.rel.gnu.linkonce.sb.*)}
240 .rela.sbss ${RELOCATING-0} :
243 ${RELOCATING+*(.rela.sbss.*)}
244 ${RELOCATING+*(.rel.gnu.linkonce.sb.*)}
246 .rel.bss ${RELOCATING-0} :
249 ${RELOCATING+*(.rel.bss.*)}
250 ${RELOCATING+*(.rel.gnu.linkonce.b.*)}
252 .rela.bss ${RELOCATING-0} :
255 ${RELOCATING+*(.rela.bss.*)}
256 ${RELOCATING+*(.rela.gnu.linkonce.b.*)}
258 .rel.stext ${RELOCATING-0} : { *(.rel.stest) }
259 .rela.stext ${RELOCATING-0} : { *(.rela.stest) }
260 .rel.etext ${RELOCATING-0} : { *(.rel.etest) }
261 .rela.etext ${RELOCATING-0} : { *(.rela.etest) }
262 .rel.sdata ${RELOCATING-0} : { *(.rel.sdata) }
263 .rela.sdata ${RELOCATING-0} : { *(.rela.sdata) }
264 .rel.edata ${RELOCATING-0} : { *(.rel.edata) }
265 .rela.edata ${RELOCATING-0} : { *(.rela.edata) }
266 .rel.eit_v ${RELOCATING-0} : { *(.rel.eit_v) }
267 .rela.eit_v ${RELOCATING-0} : { *(.rela.eit_v) }
268 .rel.ebss ${RELOCATING-0} : { *(.rel.ebss) }
269 .rela.ebss ${RELOCATING-0} : { *(.rela.ebss) }
270 .rel.srodata ${RELOCATING-0} : { *(.rel.srodata) }
271 .rela.srodata ${RELOCATING-0} : { *(.rela.srodata) }
272 .rel.erodata ${RELOCATING-0} : { *(.rel.erodata) }
273 .rela.erodata ${RELOCATING-0} : { *(.rela.erodata) }
274 .rel.got ${RELOCATING-0} : { *(.rel.got) }
275 .rela.got ${RELOCATING-0} : { *(.rela.got) }
276 .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) }
277 .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) }
278 .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) }
279 .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) }
280 .rel.init ${RELOCATING-0} : { *(.rel.init) }
281 .rela.init ${RELOCATING-0} : { *(.rela.init) }
282 .rel.fini ${RELOCATING-0} : { *(.rel.fini) }
283 .rela.fini ${RELOCATING-0} : { *(.rela.fini) }
284 .rel.plt ${RELOCATING-0} : { *(.rel.plt) }
285 .rela.plt ${RELOCATING-0} : { *(.rela.plt) }
287 /* Start of text section. */
288 .stext ${RELOCATING-0} :
291 } ${RELOCATING+ > ${TEXT_MEMORY}}
293 .init ${RELOCATING-0} :
296 } ${RELOCATING+=${NOP-0}}
298 ${RELOCATING-${INSTALL_RELOC}}
299 ${RELOCATING-${FINISH_RELOC}}
301 .text ${RELOCATING-0}:
303 /* Put startup code at beginning so that _start keeps same address. */
304 ${RELOCATING+${STARTUP_CODE}}
306 ${RELOCATING+*(.init)}
308 ${RELOCATING+*(.text.*)}
309 /* .gnu.warning sections are handled specially by elf32.em. */
311 ${RELOCATING+*(.gnu.linkonce.t.*)}
312 ${RELOCATING+*(.tramp)}
313 ${RELOCATING+*(.tramp.*)}
315 ${RELOCATING+${FINISH_CODE}}
317 ${RELOCATING+_etext = .;}
318 ${RELOCATING+PROVIDE (etext = .);}
319 ${RELOCATING+. = ALIGN(2);}
320 } ${RELOCATING+ > ${TEXT_MEMORY} =${NOP}}
321 .rvec ${RELOCATING-0} :
323 ${RELOCATING+LONG(_start);}
324 } ${RELOCATING+ > rvec}
325 .eh_frame ${RELOCATING-0} :
328 } ${RELOCATING+ > ${TEXT_MEMORY}}
330 .gcc_except_table ${RELOCATING-0} :
333 } ${RELOCATING+ > ${TEXT_MEMORY}}
335 .rodata ${RELOCATING-0} :
338 ${RELOCATING+*(.rodata.*)}
339 ${RELOCATING+*(.gnu.linkonce.r*)}
340 ${RELOCATING+. = ALIGN(2);}
341 } ${RELOCATING+ > ${TEXT_MEMORY} =0xffffffff}
343 .rodata1 ${RELOCATING-0} :
346 ${RELOCATING+. = ALIGN(2);}
347 } ${RELOCATING+ > ${TEXT_MEMORY} =0xffffffff}
349 /* Constructor and destructor tables are in ROM. */
350 ${RELOCATING+${CTOR}}
351 ${RELOCATING+${DTOR}}
353 .jcr ${RELOCATING-0} :
356 } ${RELOCATING+ > ${TEXT_MEMORY}}
358 /* Start of the data section image in ROM. */
359 ${RELOCATING+__data_image = .;}
360 ${RELOCATING+PROVIDE (__data_image = .);}
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)}
368 ${RELOCATING+__data_section_start = .;}
369 ${RELOCATING+PROVIDE (__data_section_start = .);}
371 ${RELOCATING+${DATA_START_SYMBOLS}}
372 ${RELOCATING+*(.sdata)}
374 ${RELOCATING+*(.data.*)}
375 ${RELOCATING+*(.data1)}
376 ${RELOCATING+*(.gnu.linkonce.d.*)}
377 ${CONSTRUCTING+CONSTRUCTORS}
379 ${RELOCATING+_edata = .;}
380 ${RELOCATING+PROVIDE (edata = .);}
381 ${RELOCATING+. = ALIGN(2);}
382 } ${RELOCATING+ > ${DATA_MEMORY} =0xffffffff}
384 ${RELOCATING+__data_section_size = SIZEOF(.data);}
385 ${RELOCATING+PROVIDE (__data_section_size = SIZEOF(.data));}
386 ${RELOCATING+__data_image_end = __data_image + __data_section_size;}
388 ${RELOCATING+${PRE_COMPUTE_DATA_SIZE}}
390 .install ${RELOCATING-0}:
392 ${RELOCATING+. = __data_section_size;}
393 } ${RELOCATING+ > ${TEXT_MEMORY}}
395 /* Relocation for some bss and data sections. */
396 ${RELOCATING-${BSS_DATA_RELOC}}
397 ${RELOCATING-${SOFT_REGS_RELOC}}
399 .bss ${RELOCATING-0} :
401 ${RELOCATING+__bss_start = .;}
402 ${RELOCATING+*(.softregs)}
403 ${RELOCATING+*(.sbss)}
404 ${RELOCATING+*(.common)}
405 ${RELOCATING+*(.scommon)}
406 ${RELOCATING+*(.dynbss)}
408 ${RELOCATING+*(.bss.*)}
409 ${RELOCATING+*(.gnu.linkonce.b.*)}
410 ${RELOCATING+*(COMMON)}
411 ${RELOCATING+PROVIDE (_end = .);}
412 } ${RELOCATING+ > ${DATA_MEMORY}}
413 ${RELOCATING+__bss_size = SIZEOF(.bss);}
414 ${RELOCATING+PROVIDE (__bss_size = SIZEOF(.bss));}
416 .eeprom ${RELOCATING-0} :
419 ${RELOCATING+*(.eeprom.*)}
420 } ${RELOCATING+ > ${EEPROM_MEMORY}}
422 ${RELOCATING+${VECTORS}}
424 /* Stabs debugging sections. */
425 .stab 0 : { *(.stab) }
426 .stabstr 0 : { *(.stabstr) }
427 .stab.excl 0 : { *(.stab.excl) }
428 .stab.exclstr 0 : { *(.stab.exclstr) }
429 .stab.index 0 : { *(.stab.index) }
430 .stab.indexstr 0 : { *(.stab.indexstr) }
432 .comment 0 : { *(.comment) }
434 /* Treatment of DWARF debug section must be at end of the linker
435 script to avoid problems when there are undefined symbols. It's necessary
436 to avoid that the DWARF section is relocated before such undefined
437 symbols are found. */
440 . $srcdir/scripttempl/DWARF.sc