* ld-srec/srec.exp: For m6811/m6812 use --defsym to define _.z soft
[deliverable/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
27CTOR=".ctors ${CONSTRUCTING-0} :
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
NC
36
37DTOR=" .dtors ${CONSTRUCTING-0} :
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}
90}
91
92/* Setup the stack on the top of the data memory bank. */
93PROVIDE (_stack = ${RAM_START_ADDR} + ${RAM_SIZE} - 1);
94"
95 ;;
96esac
97
98STARTUP_CODE="
99 /* Startup code. */
e1026ffb
SC
100 KEEP (*(.install0)) /* Section should setup the stack pointer. */
101 KEEP (*(.install1)) /* Place holder for applications. */
102 KEEP (*(.install2)) /* Optional installation of data sections in RAM. */
103 KEEP (*(.install3)) /* Place holder for applications. */
104 KEEP (*(.install4)) /* Section that calls the main. */
60bcf0fa
NC
105"
106
de0b1853
SC
107FINISH_CODE="
108 /* Finish code. */
e1026ffb
SC
109 KEEP (*(.fini0)) /* Beginning of finish code (_exit symbol). */
110 KEEP (*(.fini1)) /* Place holder for applications. */
111 KEEP (*(.fini2)) /* C++ destructors. */
112 KEEP (*(.fini3)) /* Place holder for applications. */
113 KEEP (*(.fini4)) /* Runtime exit. */
de0b1853
SC
114"
115
60bcf0fa
NC
116PRE_COMPUTE_DATA_SIZE="
117/* SCz: this does not work yet... This is supposed to force the loading
118 of _map_data.o (from libgcc.a) when the .data section is not empty.
119 By doing so, this should bring the code that copies the .data section
120 from ROM to RAM at init time.
121
122 ___pre_comp_data_size = SIZEOF(.data);
123 __install_data_sections = ___pre_comp_data_size > 0 ?
124 __map_data_sections : 0;
125*/
126"
127
128INSTALL_RELOC="
129 .install0 0 : { *(.install0) }
130 .install1 0 : { *(.install1) }
131 .install2 0 : { *(.install2) }
132 .install3 0 : { *(.install3) }
133 .install4 0 : { *(.install4) }
134"
135
de0b1853
SC
136FINISH_RELOC="
137 .fini0 0 : { *(.fini0) }
138 .fini1 0 : { *(.fini1) }
139 .fini2 0 : { *(.fini2) }
140 .fini3 0 : { *(.fini3) }
141 .fini4 0 : { *(.fini4) }
142"
143
60bcf0fa
NC
144BSS_DATA_RELOC="
145 .data1 0 : { *(.data1) }
146
147 /* We want the small data sections together, so single-instruction offsets
148 can access them all, and initialized data all before uninitialized, so
149 we can shorten the on-disk segment size. */
150 .sdata 0 : { *(.sdata) }
151 .sbss 0 : { *(.sbss) }
152 .scommon 0 : { *(.scommon) }
153"
154
a66c0f2c
SC
155SOFT_REGS_RELOC="
156 .softregs 0 : { *(.softregs) }
157"
158
60bcf0fa
NC
159cat <<EOF
160${RELOCATING+/* Linker script for 68HC12 executable (PROM). */}
161${RELOCATING-/* Linker script for 68HC12 object file (ld -r). */}
162
163OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}",
164 "${LITTLE_OUTPUT_FORMAT}")
165OUTPUT_ARCH(${OUTPUT_ARCH})
166ENTRY(${ENTRY})
167
168${RELOCATING+${LIB_SEARCH_DIRS}}
169${RELOCATING+${EXECUTABLE_SYMBOLS}}
170${RELOCATING+${MEMORY_DEF}}
171
172SECTIONS
173{
174 .hash ${RELOCATING-0} : { *(.hash) }
175 .dynsym ${RELOCATING-0} : { *(.dynsym) }
176 .dynstr ${RELOCATING-0} : { *(.dynstr) }
177 .gnu.version ${RELOCATING-0} : { *(.gnu.version) }
178 .gnu.version_d ${RELOCATING-0} : { *(.gnu.version_d) }
179 .gnu.version_r ${RELOCATING-0} : { *(.gnu.version_r) }
180
de0b1853
SC
181 .rel.text ${RELOCATING-0} :
182 {
183 *(.rel.text)
184 ${RELOCATING+*(.rel.text.*)}
185 ${RELOCATING+*(.rel.gnu.linkonce.t.*)}
186 }
187 .rela.text ${RELOCATING-0} :
188 {
189 *(.rela.text)
190 ${RELOCATING+*(.rela.text.*)}
191 ${RELOCATING+*(.rela.gnu.linkonce.t.*)}
192 }
193 .rel.data ${RELOCATING-0} :
194 {
195 *(.rel.data)
196 ${RELOCATING+*(.rel.data.*)}
197 ${RELOCATING+*(.rel.gnu.linkonce.d.*)}
198 }
199 .rela.data ${RELOCATING-0} :
200 {
201 *(.rela.data)
202 ${RELOCATING+*(.rela.data.*)}
203 ${RELOCATING+*(.rela.gnu.linkonce.d.*)}
204 }
205 .rel.rodata ${RELOCATING-0} :
206 {
207 *(.rel.rodata)
208 ${RELOCATING+*(.rel.rodata.*)}
209 ${RELOCATING+*(.rel.gnu.linkonce.r.*)}
210 }
211 .rela.rodata ${RELOCATING-0} :
212 {
213 *(.rela.rodata)
214 ${RELOCATING+*(.rela.rodata.*)}
215 ${RELOCATING+*(.rela.gnu.linkonce.r.*)}
216 }
217 .rel.sdata ${RELOCATING-0} :
218 {
219 *(.rel.sdata)
220 ${RELOCATING+*(.rel.sdata.*)}
221 ${RELOCATING+*(.rel.gnu.linkonce.s.*)}
222 }
223 .rela.sdata ${RELOCATING-0} :
224 {
225 *(.rela.sdata)
226 ${RELOCATING+*(.rela.sdata.*)}
227 ${RELOCATING+*(.rela.gnu.linkonce.s.*)}
228 }
229 .rel.sbss ${RELOCATING-0} :
230 {
231 *(.rel.sbss)
232 ${RELOCATING+*(.rel.sbss.*)}
233 ${RELOCATING+*(.rel.gnu.linkonce.sb.*)}
234 }
235 .rela.sbss ${RELOCATING-0} :
236 {
237 *(.rela.sbss)
238 ${RELOCATING+*(.rela.sbss.*)}
239 ${RELOCATING+*(.rel.gnu.linkonce.sb.*)}
240 }
241 .rel.bss ${RELOCATING-0} :
242 {
243 *(.rel.bss)
244 ${RELOCATING+*(.rel.bss.*)}
245 ${RELOCATING+*(.rel.gnu.linkonce.b.*)}
246 }
247 .rela.bss ${RELOCATING-0} :
248 {
249 *(.rela.bss)
250 ${RELOCATING+*(.rela.bss.*)}
251 ${RELOCATING+*(.rela.gnu.linkonce.b.*)}
252 }
1bf0a4d9 253 .rel.stext ${RELOCATING-0} : { *(.rel.stest) }
60bcf0fa 254 .rela.stext ${RELOCATING-0} : { *(.rela.stest) }
1bf0a4d9 255 .rel.etext ${RELOCATING-0} : { *(.rel.etest) }
60bcf0fa 256 .rela.etext ${RELOCATING-0} : { *(.rela.etest) }
1bf0a4d9 257 .rel.sdata ${RELOCATING-0} : { *(.rel.sdata) }
60bcf0fa 258 .rela.sdata ${RELOCATING-0} : { *(.rela.sdata) }
1bf0a4d9 259 .rel.edata ${RELOCATING-0} : { *(.rel.edata) }
60bcf0fa 260 .rela.edata ${RELOCATING-0} : { *(.rela.edata) }
1bf0a4d9 261 .rel.eit_v ${RELOCATING-0} : { *(.rel.eit_v) }
60bcf0fa 262 .rela.eit_v ${RELOCATING-0} : { *(.rela.eit_v) }
60bcf0fa 263 .rel.ebss ${RELOCATING-0} : { *(.rel.ebss) }
1bf0a4d9 264 .rela.ebss ${RELOCATING-0} : { *(.rela.ebss) }
60bcf0fa 265 .rel.srodata ${RELOCATING-0} : { *(.rel.srodata) }
1bf0a4d9 266 .rela.srodata ${RELOCATING-0} : { *(.rela.srodata) }
60bcf0fa 267 .rel.erodata ${RELOCATING-0} : { *(.rel.erodata) }
1bf0a4d9 268 .rela.erodata ${RELOCATING-0} : { *(.rela.erodata) }
60bcf0fa 269 .rel.got ${RELOCATING-0} : { *(.rel.got) }
1bf0a4d9 270 .rela.got ${RELOCATING-0} : { *(.rela.got) }
60bcf0fa 271 .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) }
1bf0a4d9 272 .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) }
60bcf0fa 273 .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) }
1bf0a4d9 274 .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) }
60bcf0fa 275 .rel.init ${RELOCATING-0} : { *(.rel.init) }
1bf0a4d9 276 .rela.init ${RELOCATING-0} : { *(.rela.init) }
60bcf0fa 277 .rel.fini ${RELOCATING-0} : { *(.rel.fini) }
1bf0a4d9 278 .rela.fini ${RELOCATING-0} : { *(.rela.fini) }
60bcf0fa 279 .rel.plt ${RELOCATING-0} : { *(.rel.plt) }
1bf0a4d9 280 .rela.plt ${RELOCATING-0} : { *(.rela.plt) }
60bcf0fa
NC
281
282 /* Concatenate .page0 sections. Put them in the page0 memory bank
283 unless we are creating a relocatable file. */
284 .page0 :
285 {
286 *(.page0)
287 } ${RELOCATING+ > page0}
288
289 /* Start of text section. */
290 .stext ${RELOCATING-0} :
291 {
292 *(.stext)
293 } ${RELOCATING+ > ${TEXT_MEMORY}}
294
295 .init ${RELOCATING-0} :
296 {
297 *(.init)
298 } ${RELOCATING+=${NOP-0}}
299
300 ${RELOCATING-${INSTALL_RELOC}}
de0b1853 301 ${RELOCATING-${FINISH_RELOC}}
60bcf0fa
NC
302
303 .text ${RELOCATING-0}:
304 {
305 /* Put startup code at beginning so that _start keeps same address. */
306 ${RELOCATING+${STARTUP_CODE}}
307
308 ${RELOCATING+*(.init)}
309 *(.text)
de0b1853 310 ${RELOCATING+*(.text.*)}
60bcf0fa
NC
311 /* .gnu.warning sections are handled specially by elf32.em. */
312 *(.gnu.warning)
de0b1853 313 ${RELOCATING+*(.gnu.linkonce.t.*)}
494fee87
SC
314 ${RELOCATING+*(.tramp)}
315 ${RELOCATING+*(.tramp.*)}
de0b1853
SC
316
317 ${RELOCATING+${FINISH_CODE}}
60bcf0fa
NC
318
319 ${RELOCATING+_etext = .;}
320 ${RELOCATING+PROVIDE (etext = .);}
321
322 } ${RELOCATING+ > ${TEXT_MEMORY}}
323
324 .eh_frame ${RELOCATING-0} :
325 {
24098abb 326 KEEP (*(.eh_frame))
60bcf0fa
NC
327 } ${RELOCATING+ > ${TEXT_MEMORY}}
328
329 .rodata ${RELOCATING-0} :
330 {
331 *(.rodata)
de0b1853
SC
332 ${RELOCATING+*(.rodata.*)}
333 ${RELOCATING+*(.gnu.linkonce.r*)}
60bcf0fa
NC
334 } ${RELOCATING+ > ${TEXT_MEMORY}}
335
336 .rodata1 ${RELOCATING-0} :
337 {
338 *(.rodata1)
339 } ${RELOCATING+ > ${TEXT_MEMORY}}
340
de0b1853
SC
341 /* Constructor and destructor tables are in ROM. */
342 ${RELOCATING+${CTOR}}
343 ${RELOCATING+${DTOR}}
344
24098abb
RH
345 .jcr ${RELOCATING-0} :
346 {
347 KEEP (*(.jcr))
348 } ${RELOCATING+ > ${TEXT_MEMORY}}
349
60bcf0fa
NC
350 /* Start of the data section image in ROM. */
351 ${RELOCATING+__data_image = .;}
352 ${RELOCATING+PROVIDE (__data_image = .);}
353
354 /* All read-only sections that normally go in PROM must be above.
355 We construct the DATA image section in PROM at end of all these
356 read-only sections. The data image must be copied at init time.
357 Refer to GNU ld, Section 3.6.8.2 Output Section LMA. */
358 .data ${RELOCATING-0} : ${RELOCATING+AT (__data_image)}
359 {
360 ${RELOCATING+__data_section_start = .;}
361 ${RELOCATING+PROVIDE (__data_section_start = .);}
362
363 ${RELOCATING+${DATA_START_SYMBOLS}}
364 ${RELOCATING+*(.sdata)}
365 *(.data)
de0b1853 366 ${RELOCATING+*(.data.*)}
60bcf0fa 367 ${RELOCATING+*(.data1)}
de0b1853 368 ${RELOCATING+*(.gnu.linkonce.d.*)}
60bcf0fa
NC
369 ${CONSTRUCTING+CONSTRUCTORS}
370
371 ${RELOCATING+_edata = .;}
372 ${RELOCATING+PROVIDE (edata = .);}
373 } ${RELOCATING+ > ${DATA_MEMORY}}
374
375 ${RELOCATING+__data_section_size = SIZEOF(.data);}
376 ${RELOCATING+PROVIDE (__data_section_size = SIZEOF(.data));}
377 ${RELOCATING+__data_image_end = __data_image + __data_section_size;}
378
379 ${RELOCATING+${PRE_COMPUTE_DATA_SIZE}}
380
381 /* .install ${RELOCATING-0}:
382 {
383 . = _data_image_end;
384 } ${RELOCATING+ > ${TEXT_MEMORY}} */
385
386 /* Relocation for some bss and data sections. */
387 ${RELOCATING-${BSS_DATA_RELOC}}
a66c0f2c 388 ${RELOCATING-${SOFT_REGS_RELOC}}
60bcf0fa
NC
389
390 .bss ${RELOCATING-0} :
391 {
392 ${RELOCATING+__bss_start = .;}
a66c0f2c 393 ${RELOCATING+*(.softregs)}
60bcf0fa
NC
394 ${RELOCATING+*(.sbss)}
395 ${RELOCATING+*(.scommon)}
396
397 *(.dynbss)
398 *(.bss)
de0b1853
SC
399 ${RELOCATING+*(.bss.*)}
400 ${RELOCATING+*(.gnu.linkonce.b.*)}
60bcf0fa
NC
401 *(COMMON)
402 ${RELOCATING+PROVIDE (_end = .);}
403 } ${RELOCATING+ > ${DATA_MEMORY}}
236d5abf
NC
404 ${RELOCATING+__bss_size = SIZEOF(.bss);}
405 ${RELOCATING+PROVIDE (__bss_size = SIZEOF(.bss));}
60bcf0fa 406
a66c0f2c
SC
407 .eeprom ${RELOCATING-0} :
408 {
409 *(.eeprom)
410 *(.eeprom.*)
411 } ${RELOCATING+ > ${EEPROM_MEMORY}}
412
60bcf0fa
NC
413 ${RELOCATING+${VECTORS}}
414
415 /* Stabs debugging sections. */
416 .stab 0 : { *(.stab) }
417 .stabstr 0 : { *(.stabstr) }
418 .stab.excl 0 : { *(.stab.excl) }
419 .stab.exclstr 0 : { *(.stab.exclstr) }
420 .stab.index 0 : { *(.stab.index) }
421 .stab.indexstr 0 : { *(.stab.indexstr) }
422
423 .comment 0 : { *(.comment) }
424
425 /* DWARF debug sections.
426 Symbols in the DWARF debugging sections are relative to the beginning
427 of the section so we begin them at 0.
428 Treatment of DWARF debug section must be at end of the linker
429 script to avoid problems when there are undefined symbols. It's necessary
430 to avoid that the DWARF section is relocated before such undefined
431 symbols are found. */
432
433 /* DWARF 1 */
434 .debug 0 : { *(.debug) }
435 .line 0 : { *(.line) }
436
437 /* GNU DWARF 1 extensions */
438 .debug_srcinfo 0 : { *(.debug_srcinfo) }
439 .debug_sfnames 0 : { *(.debug_sfnames) }
440
441 /* DWARF 1.1 and DWARF 2 */
442 .debug_aranges 0 : { *(.debug_aranges) }
443 .debug_pubnames 0 : { *(.debug_pubnames) }
444
445 /* DWARF 2 */
3a9d486c 446 .debug_info 0 : { *(.debug_info) *(.gnu.linkonce.wi.*) }
60bcf0fa
NC
447 .debug_abbrev 0 : { *(.debug_abbrev) }
448 .debug_line 0 : { *(.debug_line) }
449 .debug_frame 0 : { *(.debug_frame) }
450 .debug_str 0 : { *(.debug_str) }
451 .debug_loc 0 : { *(.debug_loc) }
452 .debug_macinfo 0 : { *(.debug_macinfo) }
453}
454EOF
This page took 0.165846 seconds and 4 git commands to generate.