]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - ld/scripttempl/elfm68hc12.sc
Fix typo in f7f2534e
[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
ec2d9b29 27CTOR=".ctors ${CONSTRUCTING-0} :
60bcf0fa 28 {
de0b1853 29 ${CONSTRUCTING+ PROVIDE (__CTOR_LIST__ = .); }
60bcf0fa 30 ${CONSTRUCTING+${CTOR_START}}
494fee87 31 KEEP (*(.ctors))
60bcf0fa
NC
32
33 ${CONSTRUCTING+${CTOR_END}}
de0b1853 34 ${CONSTRUCTING+ PROVIDE(__CTOR_END__ = .); }
ecfdd20c 35 } ${RELOCATING+ > ${TEXT_MEMORY}}"
60bcf0fa 36
ec2d9b29 37DTOR=" .dtors ${CONSTRUCTING-0} :
60bcf0fa 38 {
de0b1853 39 ${CONSTRUCTING+ PROVIDE(__DTOR_LIST__ = .); }
494fee87 40 KEEP (*(.dtors))
de0b1853 41 ${CONSTRUCTING+ PROVIDE(__DTOR_END__ = .); }
ecfdd20c 42 } ${RELOCATING+ > ${TEXT_MEMORY}}"
60bcf0fa
NC
43
44
45VECTORS="
46 /* If the 'vectors_addr' symbol is defined, it indicates the start address
47 of interrupt vectors. This depends on the 68HC11 operating mode:
48
49 Addr
50 Single chip 0xffc0
51 Extended mode 0xffc0
52 Bootstrap 0x00c0
53 Test 0xbfc0
54
55 In general, the vectors address is 0xffc0. This can be overriden
56 with the '-defsym vectors_addr=0xbfc0' ld option.
57
58 Note: for the bootstrap mode, the interrupt vectors are at 0xbfc0 but
59 they are redirected to 0x00c0 by the internal PROM. Application's vectors
60 must also consist of jump instructions (see Motorola's manual). */
61
62 PROVIDE (_vectors_addr = DEFINED (vectors_addr) ? vectors_addr : 0xffc0);
63 .vectors DEFINED (vectors_addr) ? vectors_addr : 0xffc0 :
64 {
e1026ffb 65 KEEP (*(.vectors))
60bcf0fa
NC
66 }"
67
68#
69# We provide two emulations: a fixed on that defines some memory banks
70# and a configurable one that includes a user provided memory definition.
71#
72case $GENERIC_BOARD in
73 yes|1|YES)
74 MEMORY_DEF="
75/* Get memory banks definition from some user configuration file.
76 This file must be located in some linker directory (search path
77 with -L<dir>). See fixed memory banks emulation script. */
78INCLUDE memory.x;
79"
80 ;;
81 *)
82MEMORY_DEF="
83/* Fixed definition of the available memory banks.
84 See generic emulation script for a user defined configuration. */
85MEMORY
86{
87 page0 (rwx) : ORIGIN = 0x0, LENGTH = 256
88 text (rx) : ORIGIN = ${ROM_START_ADDR}, LENGTH = ${ROM_SIZE}
89 data : ORIGIN = ${RAM_START_ADDR}, LENGTH = ${RAM_SIZE}
d522f227 90 eeprom : ORIGIN = ${EEPROM_START_ADDR}, LENGTH = ${EEPROM_SIZE}
60bcf0fa
NC
91}
92
93/* Setup the stack on the top of the data memory bank. */
94PROVIDE (_stack = ${RAM_START_ADDR} + ${RAM_SIZE} - 1);
95"
96 ;;
97esac
98
99STARTUP_CODE="
100 /* Startup code. */
e1026ffb
SC
101 KEEP (*(.install0)) /* Section should setup the stack pointer. */
102 KEEP (*(.install1)) /* Place holder for applications. */
103 KEEP (*(.install2)) /* Optional installation of data sections in RAM. */
104 KEEP (*(.install3)) /* Place holder for applications. */
105 KEEP (*(.install4)) /* Section that calls the main. */
60bcf0fa
NC
106"
107
de0b1853
SC
108FINISH_CODE="
109 /* Finish code. */
e1026ffb
SC
110 KEEP (*(.fini0)) /* Beginning of finish code (_exit symbol). */
111 KEEP (*(.fini1)) /* Place holder for applications. */
112 KEEP (*(.fini2)) /* C++ destructors. */
113 KEEP (*(.fini3)) /* Place holder for applications. */
114 KEEP (*(.fini4)) /* Runtime exit. */
de0b1853
SC
115"
116
60bcf0fa
NC
117PRE_COMPUTE_DATA_SIZE="
118/* SCz: this does not work yet... This is supposed to force the loading
119 of _map_data.o (from libgcc.a) when the .data section is not empty.
120 By doing so, this should bring the code that copies the .data section
121 from ROM to RAM at init time.
122
123 ___pre_comp_data_size = SIZEOF(.data);
124 __install_data_sections = ___pre_comp_data_size > 0 ?
125 __map_data_sections : 0;
126*/
127"
128
129INSTALL_RELOC="
ec2d9b29
AM
130 .install0 0 : { *(.install0) }
131 .install1 0 : { *(.install1) }
132 .install2 0 : { *(.install2) }
133 .install3 0 : { *(.install3) }
134 .install4 0 : { *(.install4) }
60bcf0fa
NC
135"
136
de0b1853 137FINISH_RELOC="
ec2d9b29
AM
138 .fini0 0 : { *(.fini0) }
139 .fini1 0 : { *(.fini1) }
140 .fini2 0 : { *(.fini2) }
141 .fini3 0 : { *(.fini3) }
142 .fini4 0 : { *(.fini4) }
de0b1853
SC
143"
144
60bcf0fa 145BSS_DATA_RELOC="
ec2d9b29 146 .data1 0 : { *(.data1) }
60bcf0fa
NC
147
148 /* We want the small data sections together, so single-instruction offsets
149 can access them all, and initialized data all before uninitialized, so
150 we can shorten the on-disk segment size. */
ec2d9b29
AM
151 .sdata 0 : { *(.sdata) }
152 .sbss 0 : { *(.sbss) }
153 .scommon 0 : { *(.scommon) }
60bcf0fa
NC
154"
155
a66c0f2c 156SOFT_REGS_RELOC="
ec2d9b29 157 .softregs 0 : { *(.softregs) }
a66c0f2c
SC
158"
159
60bcf0fa
NC
160cat <<EOF
161${RELOCATING+/* Linker script for 68HC12 executable (PROM). */}
162${RELOCATING-/* Linker script for 68HC12 object file (ld -r). */}
163
164OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}",
165 "${LITTLE_OUTPUT_FORMAT}")
166OUTPUT_ARCH(${OUTPUT_ARCH})
b34c1498 167${RELOCATING+ENTRY(${ENTRY})}
60bcf0fa
NC
168
169${RELOCATING+${LIB_SEARCH_DIRS}}
170${RELOCATING+${EXECUTABLE_SYMBOLS}}
171${RELOCATING+${MEMORY_DEF}}
172
173SECTIONS
174{
ec2d9b29
AM
175 .hash ${RELOCATING-0} : { *(.hash) }
176 .dynsym ${RELOCATING-0} : { *(.dynsym) }
177 .dynstr ${RELOCATING-0} : { *(.dynstr) }
178 .gnu.version ${RELOCATING-0} : { *(.gnu.version) }
179 .gnu.version_d ${RELOCATING-0} : { *(.gnu.version_d) }
180 .gnu.version_r ${RELOCATING-0} : { *(.gnu.version_r) }
181
182 .rel.text ${RELOCATING-0} :
de0b1853
SC
183 {
184 *(.rel.text)
185 ${RELOCATING+*(.rel.text.*)}
186 ${RELOCATING+*(.rel.gnu.linkonce.t.*)}
187 }
ec2d9b29 188 .rela.text ${RELOCATING-0} :
de0b1853
SC
189 {
190 *(.rela.text)
191 ${RELOCATING+*(.rela.text.*)}
192 ${RELOCATING+*(.rela.gnu.linkonce.t.*)}
193 }
ec2d9b29 194 .rel.data ${RELOCATING-0} :
de0b1853
SC
195 {
196 *(.rel.data)
197 ${RELOCATING+*(.rel.data.*)}
198 ${RELOCATING+*(.rel.gnu.linkonce.d.*)}
199 }
ec2d9b29 200 .rela.data ${RELOCATING-0} :
de0b1853
SC
201 {
202 *(.rela.data)
203 ${RELOCATING+*(.rela.data.*)}
204 ${RELOCATING+*(.rela.gnu.linkonce.d.*)}
205 }
ec2d9b29 206 .rel.rodata ${RELOCATING-0} :
de0b1853
SC
207 {
208 *(.rel.rodata)
209 ${RELOCATING+*(.rel.rodata.*)}
210 ${RELOCATING+*(.rel.gnu.linkonce.r.*)}
211 }
ec2d9b29 212 .rela.rodata ${RELOCATING-0} :
de0b1853
SC
213 {
214 *(.rela.rodata)
215 ${RELOCATING+*(.rela.rodata.*)}
216 ${RELOCATING+*(.rela.gnu.linkonce.r.*)}
217 }
ec2d9b29 218 .rel.sdata ${RELOCATING-0} :
de0b1853
SC
219 {
220 *(.rel.sdata)
221 ${RELOCATING+*(.rel.sdata.*)}
222 ${RELOCATING+*(.rel.gnu.linkonce.s.*)}
223 }
ec2d9b29 224 .rela.sdata ${RELOCATING-0} :
de0b1853
SC
225 {
226 *(.rela.sdata)
227 ${RELOCATING+*(.rela.sdata.*)}
228 ${RELOCATING+*(.rela.gnu.linkonce.s.*)}
229 }
ec2d9b29 230 .rel.sbss ${RELOCATING-0} :
de0b1853
SC
231 {
232 *(.rel.sbss)
233 ${RELOCATING+*(.rel.sbss.*)}
234 ${RELOCATING+*(.rel.gnu.linkonce.sb.*)}
235 }
ec2d9b29 236 .rela.sbss ${RELOCATING-0} :
de0b1853
SC
237 {
238 *(.rela.sbss)
239 ${RELOCATING+*(.rela.sbss.*)}
240 ${RELOCATING+*(.rel.gnu.linkonce.sb.*)}
241 }
ec2d9b29 242 .rel.bss ${RELOCATING-0} :
de0b1853
SC
243 {
244 *(.rel.bss)
245 ${RELOCATING+*(.rel.bss.*)}
246 ${RELOCATING+*(.rel.gnu.linkonce.b.*)}
247 }
ec2d9b29 248 .rela.bss ${RELOCATING-0} :
de0b1853
SC
249 {
250 *(.rela.bss)
251 ${RELOCATING+*(.rela.bss.*)}
252 ${RELOCATING+*(.rela.gnu.linkonce.b.*)}
253 }
ec2d9b29
AM
254 .rel.stext ${RELOCATING-0} : { *(.rel.stest) }
255 .rela.stext ${RELOCATING-0} : { *(.rela.stest) }
256 .rel.etext ${RELOCATING-0} : { *(.rel.etest) }
257 .rela.etext ${RELOCATING-0} : { *(.rela.etest) }
258 .rel.sdata ${RELOCATING-0} : { *(.rel.sdata) }
259 .rela.sdata ${RELOCATING-0} : { *(.rela.sdata) }
260 .rel.edata ${RELOCATING-0} : { *(.rel.edata) }
261 .rela.edata ${RELOCATING-0} : { *(.rela.edata) }
262 .rel.eit_v ${RELOCATING-0} : { *(.rel.eit_v) }
263 .rela.eit_v ${RELOCATING-0} : { *(.rela.eit_v) }
264 .rel.ebss ${RELOCATING-0} : { *(.rel.ebss) }
265 .rela.ebss ${RELOCATING-0} : { *(.rela.ebss) }
266 .rel.srodata ${RELOCATING-0} : { *(.rel.srodata) }
267 .rela.srodata ${RELOCATING-0} : { *(.rela.srodata) }
268 .rel.erodata ${RELOCATING-0} : { *(.rel.erodata) }
269 .rela.erodata ${RELOCATING-0} : { *(.rela.erodata) }
270 .rel.got ${RELOCATING-0} : { *(.rel.got) }
271 .rela.got ${RELOCATING-0} : { *(.rela.got) }
272 .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) }
273 .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) }
274 .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) }
275 .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) }
276 .rel.init ${RELOCATING-0} : { *(.rel.init) }
277 .rela.init ${RELOCATING-0} : { *(.rela.init) }
278 .rel.fini ${RELOCATING-0} : { *(.rel.fini) }
279 .rela.fini ${RELOCATING-0} : { *(.rela.fini) }
280 .rel.plt ${RELOCATING-0} : { *(.rel.plt) }
281 .rela.plt ${RELOCATING-0} : { *(.rela.plt) }
60bcf0fa
NC
282
283 /* Concatenate .page0 sections. Put them in the page0 memory bank
284 unless we are creating a relocatable file. */
285 .page0 :
286 {
287 *(.page0)
288 } ${RELOCATING+ > page0}
289
290 /* Start of text section. */
ec2d9b29 291 .stext ${RELOCATING-0} :
60bcf0fa
NC
292 {
293 *(.stext)
294 } ${RELOCATING+ > ${TEXT_MEMORY}}
295
ec2d9b29 296 .init ${RELOCATING-0} :
60bcf0fa
NC
297 {
298 *(.init)
299 } ${RELOCATING+=${NOP-0}}
300
301 ${RELOCATING-${INSTALL_RELOC}}
de0b1853 302 ${RELOCATING-${FINISH_RELOC}}
60bcf0fa 303
ec2d9b29 304 .text ${RELOCATING-0}:
60bcf0fa
NC
305 {
306 /* Put startup code at beginning so that _start keeps same address. */
307 ${RELOCATING+${STARTUP_CODE}}
308
309 ${RELOCATING+*(.init)}
310 *(.text)
de0b1853 311 ${RELOCATING+*(.text.*)}
60bcf0fa
NC
312 /* .gnu.warning sections are handled specially by elf32.em. */
313 *(.gnu.warning)
de0b1853 314 ${RELOCATING+*(.gnu.linkonce.t.*)}
494fee87
SC
315 ${RELOCATING+*(.tramp)}
316 ${RELOCATING+*(.tramp.*)}
de0b1853
SC
317
318 ${RELOCATING+${FINISH_CODE}}
60bcf0fa
NC
319
320 ${RELOCATING+_etext = .;}
321 ${RELOCATING+PROVIDE (etext = .);}
f1b123db
SC
322 ${RELOCATING+. = ALIGN(2);}
323 } ${RELOCATING+ > ${TEXT_MEMORY} =0xa7a7a7a7}
60bcf0fa 324
ec2d9b29 325 .eh_frame ${RELOCATING-0} :
60bcf0fa 326 {
24098abb 327 KEEP (*(.eh_frame))
60bcf0fa
NC
328 } ${RELOCATING+ > ${TEXT_MEMORY}}
329
ec2d9b29 330 .gcc_except_table ${RELOCATING-0} :
83a27a96
SC
331 {
332 *(.gcc_except_table)
333 } ${RELOCATING+ > ${TEXT_MEMORY}}
334
ec2d9b29 335 .rodata ${RELOCATING-0} :
60bcf0fa
NC
336 {
337 *(.rodata)
de0b1853
SC
338 ${RELOCATING+*(.rodata.*)}
339 ${RELOCATING+*(.gnu.linkonce.r*)}
f1b123db
SC
340 ${RELOCATING+. = ALIGN(2);}
341 } ${RELOCATING+ > ${TEXT_MEMORY} =0xffffffff}
60bcf0fa 342
ec2d9b29 343 .rodata1 ${RELOCATING-0} :
60bcf0fa
NC
344 {
345 *(.rodata1)
f1b123db
SC
346 ${RELOCATING+. = ALIGN(2);}
347 } ${RELOCATING+ > ${TEXT_MEMORY} =0xffffffff}
60bcf0fa 348
de0b1853
SC
349 /* Constructor and destructor tables are in ROM. */
350 ${RELOCATING+${CTOR}}
351 ${RELOCATING+${DTOR}}
352
ec2d9b29 353 .jcr ${RELOCATING-0} :
24098abb
RH
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. */
ec2d9b29 366 .data ${RELOCATING-0} : ${RELOCATING+AT (__data_image)}
60bcf0fa
NC
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 = .);}
f1b123db
SC
381 ${RELOCATING+. = ALIGN(2);}
382 } ${RELOCATING+ > ${DATA_MEMORY} =0xffffffff}
60bcf0fa
NC
383
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;}
387
388 ${RELOCATING+${PRE_COMPUTE_DATA_SIZE}}
389
ec2d9b29 390 /* .install ${RELOCATING-0}:
60bcf0fa
NC
391 {
392 . = _data_image_end;
393 } ${RELOCATING+ > ${TEXT_MEMORY}} */
394
395 /* Relocation for some bss and data sections. */
396 ${RELOCATING-${BSS_DATA_RELOC}}
a66c0f2c 397 ${RELOCATING-${SOFT_REGS_RELOC}}
60bcf0fa 398
ec2d9b29 399 .bss ${RELOCATING-0} :
60bcf0fa
NC
400 {
401 ${RELOCATING+__bss_start = .;}
a66c0f2c 402 ${RELOCATING+*(.softregs)}
60bcf0fa
NC
403 ${RELOCATING+*(.sbss)}
404 ${RELOCATING+*(.scommon)}
405
406 *(.dynbss)
407 *(.bss)
de0b1853
SC
408 ${RELOCATING+*(.bss.*)}
409 ${RELOCATING+*(.gnu.linkonce.b.*)}
60bcf0fa
NC
410 *(COMMON)
411 ${RELOCATING+PROVIDE (_end = .);}
412 } ${RELOCATING+ > ${DATA_MEMORY}}
236d5abf
NC
413 ${RELOCATING+__bss_size = SIZEOF(.bss);}
414 ${RELOCATING+PROVIDE (__bss_size = SIZEOF(.bss));}
60bcf0fa 415
ec2d9b29 416 .eeprom ${RELOCATING-0} :
a66c0f2c
SC
417 {
418 *(.eeprom)
419 *(.eeprom.*)
420 } ${RELOCATING+ > ${EEPROM_MEMORY}}
421
60bcf0fa
NC
422 ${RELOCATING+${VECTORS}}
423
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) }
431
432 .comment 0 : { *(.comment) }
433
ceb0a680 434 /* Treatment of DWARF debug section must be at end of the linker
60bcf0fa
NC
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. */
ceb0a680
NC
438EOF
439
d061dfac 440. $srcdir/scripttempl/DWARF.sc
60bcf0fa 441
ceb0a680 442cat <<EOF
60bcf0fa
NC
443}
444EOF