1 # Copyright (C) 2014-2016 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
52 of interrupt vectors. This depends on the 68HC11 operating mode:
60 In general, the vectors address is 0xffc0. This can be overriden
61 with the '-defsym vectors_addr=0xbfc0' ld option.
63 Note: for the bootstrap mode, the interrupt vectors are at 0xbfc0 but
64 they are redirected to 0x00c0 by the internal PROM. Application's vectors
65 must also consist of jump instructions (see Motorola's manual). */
67 PROVIDE (_vectors_addr = DEFINED (vectors_addr) ? vectors_addr : 0xffc0);
68 .vectors DEFINED (vectors_addr) ? vectors_addr : 0xffc0 :
74 # We provide two emulations: a fixed on that defines some memory banks
75 # and a configurable one that includes a user provided memory definition.
77 case $GENERIC_BOARD in
80 /* Get memory banks definition from some user configuration file.
81 This file must be located in some linker directory (search path
82 with -L<dir>). See fixed memory banks emulation script. */
88 /* Fixed definition of the available memory banks.
89 See generic emulation script for a user defined configuration. */
92 page0 (rwx) : ORIGIN = 0x0, LENGTH = 256
93 text (rx) : ORIGIN = ${ROM_START_ADDR}, LENGTH = ${ROM_SIZE}
94 data : ORIGIN = ${RAM_START_ADDR}, LENGTH = ${RAM_SIZE}
95 eeprom : ORIGIN = ${EEPROM_START_ADDR}, LENGTH = ${EEPROM_SIZE}
98 /* Setup the stack on the top of the data memory bank. */
99 PROVIDE (_stack = ${RAM_START_ADDR} + ${RAM_SIZE} - 1);
106 KEEP (*(.install0)) /* Section should setup the stack pointer. */
107 KEEP (*(.install1)) /* Place holder for applications. */
108 KEEP (*(.install2)) /* Optional installation of data sections in RAM. */
109 KEEP (*(.install3)) /* Place holder for applications. */
110 KEEP (*(.install4)) /* Section that calls the main. */
115 KEEP (*(.fini0)) /* Beginning of finish code (_exit symbol). */
116 KEEP (*(.fini1)) /* Place holder for applications. */
117 KEEP (*(.fini2)) /* C++ destructors. */
118 KEEP (*(.fini3)) /* Place holder for applications. */
119 KEEP (*(.fini4)) /* Runtime exit. */
122 PRE_COMPUTE_DATA_SIZE="
123 /* SCz: this does not work yet... This is supposed to force the loading
124 of _map_data.o (from libgcc.a) when the .data section is not empty.
125 By doing so, this should bring the code that copies the .data section
126 from ROM to RAM at init time.
128 ___pre_comp_data_size = SIZEOF(.data);
129 __install_data_sections = ___pre_comp_data_size > 0 ?
130 __map_data_sections : 0;
135 .install0 0 : { *(.install0) }
136 .install1 0 : { *(.install1) }
137 .install2 0 : { *(.install2) }
138 .install3 0 : { *(.install3) }
139 .install4 0 : { *(.install4) }
143 .fini0 0 : { *(.fini0) }
144 .fini1 0 : { *(.fini1) }
145 .fini2 0 : { *(.fini2) }
146 .fini3 0 : { *(.fini3) }
147 .fini4 0 : { *(.fini4) }
151 .data1 0 : { *(.data1) }
153 /* We want the small data sections together, so single-instruction offsets
154 can access them all, and initialized data all before uninitialized, so
155 we can shorten the on-disk segment size. */
156 .sdata 0 : { *(.sdata) }
157 .sbss 0 : { *(.sbss) }
158 .scommon 0 : { *(.scommon) }
162 .softregs 0 : { *(.softregs) }
166 /* Copyright (C) 2014-2016 Free Software Foundation, Inc.
168 Copying and distribution of this script, with or without modification,
169 are permitted in any medium without royalty provided the copyright
170 notice and this notice are preserved. */
172 ${RELOCATING+/* Linker script for 68HC12 executable (PROM). */}
173 ${RELOCATING-/* Linker script for 68HC12 object file (ld -r). */}
175 OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}",
176 "${LITTLE_OUTPUT_FORMAT}")
177 OUTPUT_ARCH(${OUTPUT_ARCH})
178 ${RELOCATING+ENTRY(${ENTRY})}
180 ${RELOCATING+${LIB_SEARCH_DIRS}}
181 ${RELOCATING+${EXECUTABLE_SYMBOLS}}
182 ${RELOCATING+${MEMORY_DEF}}
186 .hash ${RELOCATING-0} : { *(.hash) }
187 .dynsym ${RELOCATING-0} : { *(.dynsym) }
188 .dynstr ${RELOCATING-0} : { *(.dynstr) }
189 .gnu.version ${RELOCATING-0} : { *(.gnu.version) }
190 .gnu.version_d ${RELOCATING-0} : { *(.gnu.version_d) }
191 .gnu.version_r ${RELOCATING-0} : { *(.gnu.version_r) }
193 .rel.text ${RELOCATING-0} :
196 ${RELOCATING+*(.rel.text.*)}
197 ${RELOCATING+*(.rel.gnu.linkonce.t.*)}
199 .rela.text ${RELOCATING-0} :
202 ${RELOCATING+*(.rela.text.*)}
203 ${RELOCATING+*(.rela.gnu.linkonce.t.*)}
205 .rel.data ${RELOCATING-0} :
208 ${RELOCATING+*(.rel.data.*)}
209 ${RELOCATING+*(.rel.gnu.linkonce.d.*)}
211 .rela.data ${RELOCATING-0} :
214 ${RELOCATING+*(.rela.data.*)}
215 ${RELOCATING+*(.rela.gnu.linkonce.d.*)}
217 .rel.rodata ${RELOCATING-0} :
220 ${RELOCATING+*(.rel.rodata.*)}
221 ${RELOCATING+*(.rel.gnu.linkonce.r.*)}
223 .rela.rodata ${RELOCATING-0} :
226 ${RELOCATING+*(.rela.rodata.*)}
227 ${RELOCATING+*(.rela.gnu.linkonce.r.*)}
229 .rel.sdata ${RELOCATING-0} :
232 ${RELOCATING+*(.rel.sdata.*)}
233 ${RELOCATING+*(.rel.gnu.linkonce.s.*)}
235 .rela.sdata ${RELOCATING-0} :
238 ${RELOCATING+*(.rela.sdata.*)}
239 ${RELOCATING+*(.rela.gnu.linkonce.s.*)}
241 .rel.sbss ${RELOCATING-0} :
244 ${RELOCATING+*(.rel.sbss.*)}
245 ${RELOCATING+*(.rel.gnu.linkonce.sb.*)}
247 .rela.sbss ${RELOCATING-0} :
250 ${RELOCATING+*(.rela.sbss.*)}
251 ${RELOCATING+*(.rel.gnu.linkonce.sb.*)}
253 .rel.bss ${RELOCATING-0} :
256 ${RELOCATING+*(.rel.bss.*)}
257 ${RELOCATING+*(.rel.gnu.linkonce.b.*)}
259 .rela.bss ${RELOCATING-0} :
262 ${RELOCATING+*(.rela.bss.*)}
263 ${RELOCATING+*(.rela.gnu.linkonce.b.*)}
265 .rel.stext ${RELOCATING-0} : { *(.rel.stest) }
266 .rela.stext ${RELOCATING-0} : { *(.rela.stest) }
267 .rel.etext ${RELOCATING-0} : { *(.rel.etest) }
268 .rela.etext ${RELOCATING-0} : { *(.rela.etest) }
269 .rel.sdata ${RELOCATING-0} : { *(.rel.sdata) }
270 .rela.sdata ${RELOCATING-0} : { *(.rela.sdata) }
271 .rel.edata ${RELOCATING-0} : { *(.rel.edata) }
272 .rela.edata ${RELOCATING-0} : { *(.rela.edata) }
273 .rel.eit_v ${RELOCATING-0} : { *(.rel.eit_v) }
274 .rela.eit_v ${RELOCATING-0} : { *(.rela.eit_v) }
275 .rel.ebss ${RELOCATING-0} : { *(.rel.ebss) }
276 .rela.ebss ${RELOCATING-0} : { *(.rela.ebss) }
277 .rel.srodata ${RELOCATING-0} : { *(.rel.srodata) }
278 .rela.srodata ${RELOCATING-0} : { *(.rela.srodata) }
279 .rel.erodata ${RELOCATING-0} : { *(.rel.erodata) }
280 .rela.erodata ${RELOCATING-0} : { *(.rela.erodata) }
281 .rel.got ${RELOCATING-0} : { *(.rel.got) }
282 .rela.got ${RELOCATING-0} : { *(.rela.got) }
283 .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) }
284 .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) }
285 .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) }
286 .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) }
287 .rel.init ${RELOCATING-0} : { *(.rel.init) }
288 .rela.init ${RELOCATING-0} : { *(.rela.init) }
289 .rel.fini ${RELOCATING-0} : { *(.rel.fini) }
290 .rela.fini ${RELOCATING-0} : { *(.rela.fini) }
291 .rel.plt ${RELOCATING-0} : { *(.rel.plt) }
292 .rela.plt ${RELOCATING-0} : { *(.rela.plt) }
294 /* Concatenate .page0 sections. Put them in the page0 memory bank
295 unless we are creating a relocatable file. */
299 } ${RELOCATING+ > page0}
301 /* Start of text section. */
302 .stext ${RELOCATING-0} :
305 } ${RELOCATING+ > ${TEXT_MEMORY}}
307 .init ${RELOCATING-0} :
310 } ${RELOCATING+=${NOP-0}}
312 ${RELOCATING-${INSTALL_RELOC}}
313 ${RELOCATING-${FINISH_RELOC}}
315 .text ${RELOCATING-0}:
317 /* Put startup code at beginning so that _start keeps same address. */
318 ${RELOCATING+${STARTUP_CODE}}
320 ${RELOCATING+*(.init)}
322 ${RELOCATING+*(.text.*)}
323 /* .gnu.warning sections are handled specially by elf32.em. */
325 ${RELOCATING+*(.gnu.linkonce.t.*)}
326 ${RELOCATING+*(.tramp)}
327 ${RELOCATING+*(.tramp.*)}
329 ${RELOCATING+${FINISH_CODE}}
331 ${RELOCATING+_etext = .;}
332 ${RELOCATING+PROVIDE (etext = .);}
333 ${RELOCATING+. = ALIGN(2);}
334 } ${RELOCATING+ > ${TEXT_MEMORY} =0xa7a7a7a7}
336 .eh_frame ${RELOCATING-0} :
339 } ${RELOCATING+ > ${TEXT_MEMORY}}
341 .gcc_except_table ${RELOCATING-0} :
344 } ${RELOCATING+ > ${TEXT_MEMORY}}
346 .rodata ${RELOCATING-0} :
349 ${RELOCATING+*(.rodata.*)}
350 ${RELOCATING+*(.gnu.linkonce.r*)}
351 ${RELOCATING+. = ALIGN(2);}
352 } ${RELOCATING+ > ${TEXT_MEMORY} =0xffffffff}
354 .rodata1 ${RELOCATING-0} :
357 ${RELOCATING+. = ALIGN(2);}
358 } ${RELOCATING+ > ${TEXT_MEMORY} =0xffffffff}
360 /* Constructor and destructor tables are in ROM. */
361 ${RELOCATING+${CTOR}}
362 ${RELOCATING+${DTOR}}
364 .jcr ${RELOCATING-0} :
367 } ${RELOCATING+ > ${TEXT_MEMORY}}
369 /* Start of the data section image in ROM. */
370 ${RELOCATING+__data_image = .;}
371 ${RELOCATING+PROVIDE (__data_image = .);}
373 /* All read-only sections that normally go in PROM must be above.
374 We construct the DATA image section in PROM at end of all these
375 read-only sections. The data image must be copied at init time.
376 Refer to GNU ld, Section 3.6.8.2 Output Section LMA. */
377 .data ${RELOCATING-0} : ${RELOCATING+AT (__data_image)}
379 ${RELOCATING+__data_section_start = .;}
380 ${RELOCATING+PROVIDE (__data_section_start = .);}
382 ${RELOCATING+${DATA_START_SYMBOLS}}
383 ${RELOCATING+*(.sdata)}
385 ${RELOCATING+*(.data.*)}
386 ${RELOCATING+*(.data1)}
387 ${RELOCATING+*(.gnu.linkonce.d.*)}
388 ${CONSTRUCTING+CONSTRUCTORS}
390 ${RELOCATING+_edata = .;}
391 ${RELOCATING+PROVIDE (edata = .);}
392 ${RELOCATING+. = ALIGN(2);}
393 } ${RELOCATING+ > ${DATA_MEMORY} =0xffffffff}
395 ${RELOCATING+__data_section_size = SIZEOF(.data);}
396 ${RELOCATING+PROVIDE (__data_section_size = SIZEOF(.data));}
397 ${RELOCATING+__data_image_end = __data_image + __data_section_size;}
399 ${RELOCATING+${PRE_COMPUTE_DATA_SIZE}}
401 /* .install ${RELOCATING-0}:
404 } ${RELOCATING+ > ${TEXT_MEMORY}} */
406 /* Relocation for some bss and data sections. */
407 ${RELOCATING-${BSS_DATA_RELOC}}
408 ${RELOCATING-${SOFT_REGS_RELOC}}
410 .bss ${RELOCATING-0} :
412 ${RELOCATING+__bss_start = .;}
413 ${RELOCATING+*(.softregs)}
414 ${RELOCATING+*(.sbss)}
415 ${RELOCATING+*(.scommon)}
419 ${RELOCATING+*(.bss.*)}
420 ${RELOCATING+*(.gnu.linkonce.b.*)}
422 ${RELOCATING+PROVIDE (_end = .);}
423 } ${RELOCATING+ > ${DATA_MEMORY}}
424 ${RELOCATING+__bss_size = SIZEOF(.bss);}
425 ${RELOCATING+PROVIDE (__bss_size = SIZEOF(.bss));}
427 .eeprom ${RELOCATING-0} :
431 } ${RELOCATING+ > ${EEPROM_MEMORY}}
433 ${RELOCATING+${VECTORS}}
435 /* Stabs debugging sections. */
436 .stab 0 : { *(.stab) }
437 .stabstr 0 : { *(.stabstr) }
438 .stab.excl 0 : { *(.stab.excl) }
439 .stab.exclstr 0 : { *(.stab.exclstr) }
440 .stab.index 0 : { *(.stab.index) }
441 .stab.indexstr 0 : { *(.stab.indexstr) }
443 .comment 0 : { *(.comment) }
445 /* Treatment of DWARF debug section must be at end of the linker
446 script to avoid problems when there are undefined symbols. It's necessary
447 to avoid that the DWARF section is relocated before such undefined
448 symbols are found. */
451 . $srcdir/scripttempl/DWARF.sc