]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - ld/scripttempl/elfm68hc11.sc
Update year range in copyright notice of binutils files
[thirdparty/binutils-gdb.git] / ld / scripttempl / elfm68hc11.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.
985743c7 25
60bcf0fa
NC
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}
a66c0f2c 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 68HC11 executable (PROM). */}
173${RELOCATING-/* Linker script for 68HC11 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)
a66c0f2c 299 ${RELOCATING+*(.softregs)}
60bcf0fa
NC
300 } ${RELOCATING+ > page0}
301
302 /* Start of text section. */
6c19b93b 303 .stext ${RELOCATING-0} :
60bcf0fa
NC
304 {
305 *(.stext)
306 } ${RELOCATING+ > ${TEXT_MEMORY}}
307
ec2d9b29 308 .init ${RELOCATING-0} :
60bcf0fa 309 {
2d3181c7 310 KEEP (*(SORT_NONE(.init)))
60bcf0fa
NC
311 } ${RELOCATING+=${NOP-0}}
312
313 ${RELOCATING-${INSTALL_RELOC}}
de0b1853 314 ${RELOCATING-${FINISH_RELOC}}
60bcf0fa 315
ec2d9b29 316 .text ${RELOCATING-0}:
60bcf0fa
NC
317 {
318 /* Put startup code at beginning so that _start keeps same address. */
319 ${RELOCATING+${STARTUP_CODE}}
320
60bcf0fa 321 *(.text)
de0b1853 322 ${RELOCATING+*(.text.*)}
075a2b89 323 /* .gnu.warning sections are handled specially by elf.em. */
60bcf0fa 324 *(.gnu.warning)
de0b1853 325 ${RELOCATING+*(.gnu.linkonce.t.*)}
494fee87
SC
326 ${RELOCATING+*(.tramp)}
327 ${RELOCATING+*(.tramp.*)}
de0b1853 328
2d3181c7 329 ${RELOCATING+KEEP (*(SORT_NONE(.fini)))}
de0b1853 330 ${RELOCATING+${FINISH_CODE}}
60bcf0fa
NC
331
332 ${RELOCATING+_etext = .;}
333 ${RELOCATING+PROVIDE (etext = .);}
334
335 } ${RELOCATING+ > ${TEXT_MEMORY}}
336
ec2d9b29 337 .eh_frame ${RELOCATING-0} :
60bcf0fa 338 {
24098abb 339 KEEP (*(.eh_frame))
60bcf0fa
NC
340 } ${RELOCATING+ > ${TEXT_MEMORY}}
341
ec2d9b29 342 .gcc_except_table ${RELOCATING-0} :
83a27a96
SC
343 {
344 *(.gcc_except_table)
345 } ${RELOCATING+ > ${TEXT_MEMORY}}
346
ec2d9b29 347 .rodata ${RELOCATING-0} :
60bcf0fa
NC
348 {
349 *(.rodata)
de0b1853
SC
350 ${RELOCATING+*(.rodata.*)}
351 ${RELOCATING+*(.gnu.linkonce.r*)}
60bcf0fa
NC
352 } ${RELOCATING+ > ${TEXT_MEMORY}}
353
ec2d9b29 354 .rodata1 ${RELOCATING-0} :
60bcf0fa
NC
355 {
356 *(.rodata1)
357 } ${RELOCATING+ > ${TEXT_MEMORY}}
358
de0b1853
SC
359 /* Constructor and destructor tables are in ROM. */
360 ${RELOCATING+${CTOR}}
361 ${RELOCATING+${DTOR}}
362
ec2d9b29 363 .jcr ${RELOCATING-0} :
24098abb
RH
364 {
365 KEEP (*(.jcr))
366 } ${RELOCATING+ > ${TEXT_MEMORY}}
367
60bcf0fa
NC
368 /* Start of the data section image in ROM. */
369 ${RELOCATING+__data_image = .;}
370 ${RELOCATING+PROVIDE (__data_image = .);}
371
372 /* All read-only sections that normally go in PROM must be above.
373 We construct the DATA image section in PROM at end of all these
374 read-only sections. The data image must be copied at init time.
375 Refer to GNU ld, Section 3.6.8.2 Output Section LMA. */
ec2d9b29 376 .data ${RELOCATING-0} : ${RELOCATING+AT (__data_image)}
60bcf0fa
NC
377 {
378 ${RELOCATING+__data_section_start = .;}
379 ${RELOCATING+PROVIDE (__data_section_start = .);}
380
381 ${RELOCATING+${DATA_START_SYMBOLS}}
382 ${RELOCATING+*(.sdata)}
383 *(.data)
de0b1853 384 ${RELOCATING+*(.data.*)}
60bcf0fa 385 ${RELOCATING+*(.data1)}
de0b1853 386 ${RELOCATING+*(.gnu.linkonce.d.*)}
60bcf0fa
NC
387 ${CONSTRUCTING+CONSTRUCTORS}
388
389 ${RELOCATING+_edata = .;}
390 ${RELOCATING+PROVIDE (edata = .);}
391 } ${RELOCATING+ > ${DATA_MEMORY}}
392
393 ${RELOCATING+__data_section_size = SIZEOF(.data);}
394 ${RELOCATING+PROVIDE (__data_section_size = SIZEOF(.data));}
395 ${RELOCATING+__data_image_end = __data_image + __data_section_size;}
396
397 ${RELOCATING+${PRE_COMPUTE_DATA_SIZE}}
398
ec2d9b29 399 /* .install ${RELOCATING-0}:
60bcf0fa
NC
400 {
401 . = _data_image_end;
402 } ${RELOCATING+ > ${TEXT_MEMORY}} */
403
404 /* Relocation for some bss and data sections. */
405 ${RELOCATING-${BSS_DATA_RELOC}}
a66c0f2c 406 ${RELOCATING-${SOFT_REGS_RELOC}}
60bcf0fa 407
ec2d9b29 408 .bss ${RELOCATING-0} :
60bcf0fa
NC
409 {
410 ${RELOCATING+__bss_start = .;}
411 ${RELOCATING+*(.sbss)}
412 ${RELOCATING+*(.scommon)}
2bf2bf23 413 ${RELOCATING+*(.dynbss)}
60bcf0fa 414 *(.bss)
de0b1853
SC
415 ${RELOCATING+*(.bss.*)}
416 ${RELOCATING+*(.gnu.linkonce.b.*)}
2bf2bf23 417 ${RELOCATING+*(COMMON)}
60bcf0fa
NC
418 ${RELOCATING+PROVIDE (_end = .);}
419 } ${RELOCATING+ > ${DATA_MEMORY}}
236d5abf
NC
420 ${RELOCATING+__bss_size = SIZEOF(.bss);}
421 ${RELOCATING+PROVIDE (__bss_size = SIZEOF(.bss));}
60bcf0fa 422
ec2d9b29 423 .eeprom ${RELOCATING-0} :
a66c0f2c
SC
424 {
425 *(.eeprom)
2bf2bf23 426 ${RELOCATING+*(.eeprom.*)}
a66c0f2c
SC
427 } ${RELOCATING+ > ${EEPROM_MEMORY}}
428
60bcf0fa
NC
429 ${RELOCATING+${VECTORS}}
430
431 /* Stabs debugging sections. */
432 .stab 0 : { *(.stab) }
433 .stabstr 0 : { *(.stabstr) }
434 .stab.excl 0 : { *(.stab.excl) }
435 .stab.exclstr 0 : { *(.stab.exclstr) }
436 .stab.index 0 : { *(.stab.index) }
437 .stab.indexstr 0 : { *(.stab.indexstr) }
438
439 .comment 0 : { *(.comment) }
440
ceb0a680
NC
441EOF
442
d061dfac 443. $srcdir/scripttempl/DWARF.sc
ceb0a680
NC
444
445cat <<EOF
60bcf0fa
NC
446}
447EOF