]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - ld/scripttempl/elfm68hc12.sc
Update year range in copyright notice of binutils files
[thirdparty/binutils-gdb.git] / ld / scripttempl / elfm68hc12.sc
CommitLineData
250d07de 1# Copyright (C) 2014-2021 Free Software Foundation, Inc.
6c19b93b 2#
985743c7
NC
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.
60bcf0fa
NC
6#
7# Unusual variables checked by this code:
563e308f 8# NOP - four byte opcode for no-op (defaults to 0)
60bcf0fa
NC
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
16# .text section.
17# DATA_START_SYMBOLS - symbols that appear at the start of the
18# .data section.
19# OTHER_BSS_SYMBOLS - symbols that appear at the start of the
20# .bss section besides __bss_start.
6c19b93b 21# EMBEDDED - whether this is for an embedded system.
60bcf0fa
NC
22#
23# When adding sections, do note that the names of some sections are used
24# when specifying the start address of the next.
25#
26test -z "$ENTRY" && ENTRY=_start
27test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT}
28test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT}
29if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi
30test "$LD_FLAG" = "N" && DATA_ADDR=.
31
6c19b93b 32CTOR=".ctors ${CONSTRUCTING-0} :
60bcf0fa 33 {
de0b1853 34 ${CONSTRUCTING+ PROVIDE (__CTOR_LIST__ = .); }
60bcf0fa 35 ${CONSTRUCTING+${CTOR_START}}
494fee87 36 KEEP (*(.ctors))
60bcf0fa
NC
37
38 ${CONSTRUCTING+${CTOR_END}}
de0b1853 39 ${CONSTRUCTING+ PROVIDE(__CTOR_END__ = .); }
ecfdd20c 40 } ${RELOCATING+ > ${TEXT_MEMORY}}"
60bcf0fa 41
ec2d9b29 42DTOR=" .dtors ${CONSTRUCTING-0} :
60bcf0fa 43 {
de0b1853 44 ${CONSTRUCTING+ PROVIDE(__DTOR_LIST__ = .); }
494fee87 45 KEEP (*(.dtors))
de0b1853 46 ${CONSTRUCTING+ PROVIDE(__DTOR_END__ = .); }
ecfdd20c 47 } ${RELOCATING+ > ${TEXT_MEMORY}}"
60bcf0fa
NC
48
49
50VECTORS="
51 /* If the 'vectors_addr' symbol is defined, it indicates the start address
52 of interrupt vectors. This depends on the 68HC11 operating mode:
53
54 Addr
55 Single chip 0xffc0
56 Extended mode 0xffc0
57 Bootstrap 0x00c0
58 Test 0xbfc0
59
6c19b93b 60 In general, the vectors address is 0xffc0. This can be overriden
60bcf0fa
NC
61 with the '-defsym vectors_addr=0xbfc0' ld option.
62
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). */
66
67 PROVIDE (_vectors_addr = DEFINED (vectors_addr) ? vectors_addr : 0xffc0);
68 .vectors DEFINED (vectors_addr) ? vectors_addr : 0xffc0 :
69 {
e1026ffb 70 KEEP (*(.vectors))
60bcf0fa
NC
71 }"
72
73#
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.
76#
77case $GENERIC_BOARD in
78 yes|1|YES)
79 MEMORY_DEF="
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. */
83INCLUDE memory.x;
84"
85 ;;
86 *)
87MEMORY_DEF="
88/* Fixed definition of the available memory banks.
89 See generic emulation script for a user defined configuration. */
90MEMORY
91{
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}
d522f227 95 eeprom : ORIGIN = ${EEPROM_START_ADDR}, LENGTH = ${EEPROM_SIZE}
60bcf0fa
NC
96}
97
98/* Setup the stack on the top of the data memory bank. */
99PROVIDE (_stack = ${RAM_START_ADDR} + ${RAM_SIZE} - 1);
100"
101 ;;
102esac
103
104STARTUP_CODE="
105 /* Startup code. */
e1026ffb
SC
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. */
60bcf0fa
NC
111"
112
de0b1853
SC
113FINISH_CODE="
114 /* Finish code. */
e1026ffb
SC
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. */
de0b1853
SC
120"
121
60bcf0fa
NC
122PRE_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.
127
128 ___pre_comp_data_size = SIZEOF(.data);
129 __install_data_sections = ___pre_comp_data_size > 0 ?
130 __map_data_sections : 0;
131*/
132"
133
134INSTALL_RELOC="
ec2d9b29
AM
135 .install0 0 : { *(.install0) }
136 .install1 0 : { *(.install1) }
137 .install2 0 : { *(.install2) }
138 .install3 0 : { *(.install3) }
139 .install4 0 : { *(.install4) }
60bcf0fa
NC
140"
141
de0b1853 142FINISH_RELOC="
ec2d9b29
AM
143 .fini0 0 : { *(.fini0) }
144 .fini1 0 : { *(.fini1) }
145 .fini2 0 : { *(.fini2) }
146 .fini3 0 : { *(.fini3) }
147 .fini4 0 : { *(.fini4) }
de0b1853
SC
148"
149
60bcf0fa 150BSS_DATA_RELOC="
ec2d9b29 151 .data1 0 : { *(.data1) }
60bcf0fa
NC
152
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. */
ec2d9b29
AM
156 .sdata 0 : { *(.sdata) }
157 .sbss 0 : { *(.sbss) }
158 .scommon 0 : { *(.scommon) }
60bcf0fa
NC
159"
160
a66c0f2c 161SOFT_REGS_RELOC="
ec2d9b29 162 .softregs 0 : { *(.softregs) }
a66c0f2c
SC
163"
164
60bcf0fa 165cat <<EOF
250d07de 166/* Copyright (C) 2014-2021 Free Software Foundation, Inc.
985743c7
NC
167
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. */
171
60bcf0fa
NC
172${RELOCATING+/* Linker script for 68HC12 executable (PROM). */}
173${RELOCATING-/* Linker script for 68HC12 object file (ld -r). */}
174
175OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}",
176 "${LITTLE_OUTPUT_FORMAT}")
177OUTPUT_ARCH(${OUTPUT_ARCH})
b34c1498 178${RELOCATING+ENTRY(${ENTRY})}
60bcf0fa
NC
179
180${RELOCATING+${LIB_SEARCH_DIRS}}
181${RELOCATING+${EXECUTABLE_SYMBOLS}}
182${RELOCATING+${MEMORY_DEF}}
183
184SECTIONS
185{
ec2d9b29
AM
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) }
192
193 .rel.text ${RELOCATING-0} :
de0b1853
SC
194 {
195 *(.rel.text)
196 ${RELOCATING+*(.rel.text.*)}
197 ${RELOCATING+*(.rel.gnu.linkonce.t.*)}
198 }
ec2d9b29 199 .rela.text ${RELOCATING-0} :
de0b1853
SC
200 {
201 *(.rela.text)
202 ${RELOCATING+*(.rela.text.*)}
203 ${RELOCATING+*(.rela.gnu.linkonce.t.*)}
204 }
ec2d9b29 205 .rel.data ${RELOCATING-0} :
de0b1853
SC
206 {
207 *(.rel.data)
208 ${RELOCATING+*(.rel.data.*)}
209 ${RELOCATING+*(.rel.gnu.linkonce.d.*)}
210 }
ec2d9b29 211 .rela.data ${RELOCATING-0} :
de0b1853
SC
212 {
213 *(.rela.data)
214 ${RELOCATING+*(.rela.data.*)}
215 ${RELOCATING+*(.rela.gnu.linkonce.d.*)}
216 }
ec2d9b29 217 .rel.rodata ${RELOCATING-0} :
de0b1853
SC
218 {
219 *(.rel.rodata)
220 ${RELOCATING+*(.rel.rodata.*)}
221 ${RELOCATING+*(.rel.gnu.linkonce.r.*)}
222 }
ec2d9b29 223 .rela.rodata ${RELOCATING-0} :
de0b1853
SC
224 {
225 *(.rela.rodata)
226 ${RELOCATING+*(.rela.rodata.*)}
227 ${RELOCATING+*(.rela.gnu.linkonce.r.*)}
228 }
ec2d9b29 229 .rel.sdata ${RELOCATING-0} :
de0b1853
SC
230 {
231 *(.rel.sdata)
232 ${RELOCATING+*(.rel.sdata.*)}
233 ${RELOCATING+*(.rel.gnu.linkonce.s.*)}
234 }
ec2d9b29 235 .rela.sdata ${RELOCATING-0} :
de0b1853
SC
236 {
237 *(.rela.sdata)
238 ${RELOCATING+*(.rela.sdata.*)}
239 ${RELOCATING+*(.rela.gnu.linkonce.s.*)}
240 }
ec2d9b29 241 .rel.sbss ${RELOCATING-0} :
6c19b93b 242 {
de0b1853
SC
243 *(.rel.sbss)
244 ${RELOCATING+*(.rel.sbss.*)}
245 ${RELOCATING+*(.rel.gnu.linkonce.sb.*)}
246 }
ec2d9b29 247 .rela.sbss ${RELOCATING-0} :
de0b1853
SC
248 {
249 *(.rela.sbss)
250 ${RELOCATING+*(.rela.sbss.*)}
251 ${RELOCATING+*(.rel.gnu.linkonce.sb.*)}
252 }
6c19b93b
AM
253 .rel.bss ${RELOCATING-0} :
254 {
de0b1853
SC
255 *(.rel.bss)
256 ${RELOCATING+*(.rel.bss.*)}
257 ${RELOCATING+*(.rel.gnu.linkonce.b.*)}
258 }
6c19b93b
AM
259 .rela.bss ${RELOCATING-0} :
260 {
de0b1853
SC
261 *(.rela.bss)
262 ${RELOCATING+*(.rela.bss.*)}
263 ${RELOCATING+*(.rela.gnu.linkonce.b.*)}
264 }
ec2d9b29
AM
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) }
60bcf0fa
NC
293
294 /* Concatenate .page0 sections. Put them in the page0 memory bank
295 unless we are creating a relocatable file. */
296 .page0 :
297 {
298 *(.page0)
299 } ${RELOCATING+ > page0}
300
301 /* Start of text section. */
6c19b93b 302 .stext ${RELOCATING-0} :
60bcf0fa
NC
303 {
304 *(.stext)
305 } ${RELOCATING+ > ${TEXT_MEMORY}}
306
ec2d9b29 307 .init ${RELOCATING-0} :
60bcf0fa 308 {
2d3181c7 309 KEEP (*(SORT_NONE(.init)))
60bcf0fa
NC
310 } ${RELOCATING+=${NOP-0}}
311
312 ${RELOCATING-${INSTALL_RELOC}}
de0b1853 313 ${RELOCATING-${FINISH_RELOC}}
60bcf0fa 314
ec2d9b29 315 .text ${RELOCATING-0}:
60bcf0fa
NC
316 {
317 /* Put startup code at beginning so that _start keeps same address. */
318 ${RELOCATING+${STARTUP_CODE}}
319
60bcf0fa 320 *(.text)
de0b1853 321 ${RELOCATING+*(.text.*)}
075a2b89 322 /* .gnu.warning sections are handled specially by elf.em. */
60bcf0fa 323 *(.gnu.warning)
de0b1853 324 ${RELOCATING+*(.gnu.linkonce.t.*)}
494fee87
SC
325 ${RELOCATING+*(.tramp)}
326 ${RELOCATING+*(.tramp.*)}
de0b1853 327
2d3181c7 328 ${RELOCATING+KEEP (*(SORT_NONE(.fini)))}
de0b1853 329 ${RELOCATING+${FINISH_CODE}}
60bcf0fa
NC
330
331 ${RELOCATING+_etext = .;}
332 ${RELOCATING+PROVIDE (etext = .);}
f1b123db
SC
333 ${RELOCATING+. = ALIGN(2);}
334 } ${RELOCATING+ > ${TEXT_MEMORY} =0xa7a7a7a7}
60bcf0fa 335
ec2d9b29 336 .eh_frame ${RELOCATING-0} :
60bcf0fa 337 {
24098abb 338 KEEP (*(.eh_frame))
60bcf0fa
NC
339 } ${RELOCATING+ > ${TEXT_MEMORY}}
340
ec2d9b29 341 .gcc_except_table ${RELOCATING-0} :
83a27a96
SC
342 {
343 *(.gcc_except_table)
344 } ${RELOCATING+ > ${TEXT_MEMORY}}
345
ec2d9b29 346 .rodata ${RELOCATING-0} :
60bcf0fa
NC
347 {
348 *(.rodata)
de0b1853
SC
349 ${RELOCATING+*(.rodata.*)}
350 ${RELOCATING+*(.gnu.linkonce.r*)}
f1b123db
SC
351 ${RELOCATING+. = ALIGN(2);}
352 } ${RELOCATING+ > ${TEXT_MEMORY} =0xffffffff}
60bcf0fa 353
ec2d9b29 354 .rodata1 ${RELOCATING-0} :
60bcf0fa
NC
355 {
356 *(.rodata1)
f1b123db
SC
357 ${RELOCATING+. = ALIGN(2);}
358 } ${RELOCATING+ > ${TEXT_MEMORY} =0xffffffff}
60bcf0fa 359
de0b1853
SC
360 /* Constructor and destructor tables are in ROM. */
361 ${RELOCATING+${CTOR}}
362 ${RELOCATING+${DTOR}}
363
ec2d9b29 364 .jcr ${RELOCATING-0} :
24098abb
RH
365 {
366 KEEP (*(.jcr))
367 } ${RELOCATING+ > ${TEXT_MEMORY}}
368
60bcf0fa
NC
369 /* Start of the data section image in ROM. */
370 ${RELOCATING+__data_image = .;}
371 ${RELOCATING+PROVIDE (__data_image = .);}
372
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. */
ec2d9b29 377 .data ${RELOCATING-0} : ${RELOCATING+AT (__data_image)}
60bcf0fa
NC
378 {
379 ${RELOCATING+__data_section_start = .;}
380 ${RELOCATING+PROVIDE (__data_section_start = .);}
381
382 ${RELOCATING+${DATA_START_SYMBOLS}}
383 ${RELOCATING+*(.sdata)}
384 *(.data)
de0b1853 385 ${RELOCATING+*(.data.*)}
60bcf0fa 386 ${RELOCATING+*(.data1)}
de0b1853 387 ${RELOCATING+*(.gnu.linkonce.d.*)}
60bcf0fa
NC
388 ${CONSTRUCTING+CONSTRUCTORS}
389
390 ${RELOCATING+_edata = .;}
391 ${RELOCATING+PROVIDE (edata = .);}
f1b123db
SC
392 ${RELOCATING+. = ALIGN(2);}
393 } ${RELOCATING+ > ${DATA_MEMORY} =0xffffffff}
60bcf0fa
NC
394
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;}
398
399 ${RELOCATING+${PRE_COMPUTE_DATA_SIZE}}
400
ec2d9b29 401 /* .install ${RELOCATING-0}:
60bcf0fa
NC
402 {
403 . = _data_image_end;
404 } ${RELOCATING+ > ${TEXT_MEMORY}} */
405
406 /* Relocation for some bss and data sections. */
407 ${RELOCATING-${BSS_DATA_RELOC}}
a66c0f2c 408 ${RELOCATING-${SOFT_REGS_RELOC}}
60bcf0fa 409
ec2d9b29 410 .bss ${RELOCATING-0} :
60bcf0fa
NC
411 {
412 ${RELOCATING+__bss_start = .;}
a66c0f2c 413 ${RELOCATING+*(.softregs)}
60bcf0fa
NC
414 ${RELOCATING+*(.sbss)}
415 ${RELOCATING+*(.scommon)}
2bf2bf23 416 ${RELOCATING+*(.dynbss)}
60bcf0fa 417 *(.bss)
de0b1853
SC
418 ${RELOCATING+*(.bss.*)}
419 ${RELOCATING+*(.gnu.linkonce.b.*)}
2bf2bf23 420 ${RELOCATING+*(COMMON)}
60bcf0fa
NC
421 ${RELOCATING+PROVIDE (_end = .);}
422 } ${RELOCATING+ > ${DATA_MEMORY}}
236d5abf
NC
423 ${RELOCATING+__bss_size = SIZEOF(.bss);}
424 ${RELOCATING+PROVIDE (__bss_size = SIZEOF(.bss));}
60bcf0fa 425
ec2d9b29 426 .eeprom ${RELOCATING-0} :
a66c0f2c
SC
427 {
428 *(.eeprom)
2bf2bf23 429 ${RELOCATING+*(.eeprom.*)}
a66c0f2c
SC
430 } ${RELOCATING+ > ${EEPROM_MEMORY}}
431
60bcf0fa
NC
432 ${RELOCATING+${VECTORS}}
433
434 /* Stabs debugging sections. */
435 .stab 0 : { *(.stab) }
436 .stabstr 0 : { *(.stabstr) }
437 .stab.excl 0 : { *(.stab.excl) }
438 .stab.exclstr 0 : { *(.stab.exclstr) }
439 .stab.index 0 : { *(.stab.index) }
440 .stab.indexstr 0 : { *(.stab.indexstr) }
441
442 .comment 0 : { *(.comment) }
443
ceb0a680 444 /* Treatment of DWARF debug section must be at end of the linker
60bcf0fa
NC
445 script to avoid problems when there are undefined symbols. It's necessary
446 to avoid that the DWARF section is relocated before such undefined
447 symbols are found. */
ceb0a680
NC
448EOF
449
d061dfac 450. $srcdir/scripttempl/DWARF.sc
60bcf0fa 451
ceb0a680 452cat <<EOF
60bcf0fa
NC
453}
454EOF