* scripttempl/elfm68hc11.sc: Use KEEP for .vectors, .installN,
[deliverable/binutils-gdb.git] / ld / scripttempl / elfm68hc12.sc
1 #
2 # Unusual variables checked by this code:
3 # NOP - four byte opcode for no-op (defaults to 0)
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 #
21 test -z "$ENTRY" && ENTRY=_start
22 test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT}
23 test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT}
24 if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi
25 test "$LD_FLAG" = "N" && DATA_ADDR=.
26
27 CTOR=".ctors ${CONSTRUCTING-0} :
28 {
29 ${CONSTRUCTING+ PROVIDE (__CTOR_LIST__ = .); }
30 ${CONSTRUCTING+${CTOR_START}}
31 *(.ctors)
32 /* We don't want to include the .ctor section from
33 from the crtend.o file until after the sorted ctors.
34 The .ctor section from the crtend file contains the
35 end of ctors marker and it must be last
36
37 KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
38 KEEP (*(SORT(.ctors.*)))
39 KEEP (*(.ctors)) */
40
41 ${CONSTRUCTING+${CTOR_END}}
42 ${CONSTRUCTING+ PROVIDE(__CTOR_END__ = .); }
43 } ${RELOCATING+ > ${TEXT_MEMORY}}"
44
45 DTOR=" .dtors ${CONSTRUCTING-0} :
46 {
47 ${CONSTRUCTING+ PROVIDE(__DTOR_LIST__ = .); }
48 *(.dtors)
49 /*
50 KEEP (*crtbegin.o(.dtors))
51 KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
52 KEEP (*(SORT(.dtors.*)))
53 KEEP (*(.dtors)) */
54 ${CONSTRUCTING+ PROVIDE(__DTOR_END__ = .); }
55 } ${RELOCATING+ > ${TEXT_MEMORY}}"
56
57
58 VECTORS="
59 /* If the 'vectors_addr' symbol is defined, it indicates the start address
60 of interrupt vectors. This depends on the 68HC11 operating mode:
61
62 Addr
63 Single chip 0xffc0
64 Extended mode 0xffc0
65 Bootstrap 0x00c0
66 Test 0xbfc0
67
68 In general, the vectors address is 0xffc0. This can be overriden
69 with the '-defsym vectors_addr=0xbfc0' ld option.
70
71 Note: for the bootstrap mode, the interrupt vectors are at 0xbfc0 but
72 they are redirected to 0x00c0 by the internal PROM. Application's vectors
73 must also consist of jump instructions (see Motorola's manual). */
74
75 PROVIDE (_vectors_addr = DEFINED (vectors_addr) ? vectors_addr : 0xffc0);
76 .vectors DEFINED (vectors_addr) ? vectors_addr : 0xffc0 :
77 {
78 KEEP (*(.vectors))
79 }"
80
81 #
82 # We provide two emulations: a fixed on that defines some memory banks
83 # and a configurable one that includes a user provided memory definition.
84 #
85 case $GENERIC_BOARD in
86 yes|1|YES)
87 MEMORY_DEF="
88 /* Get memory banks definition from some user configuration file.
89 This file must be located in some linker directory (search path
90 with -L<dir>). See fixed memory banks emulation script. */
91 INCLUDE memory.x;
92 "
93 ;;
94 *)
95 MEMORY_DEF="
96 /* Fixed definition of the available memory banks.
97 See generic emulation script for a user defined configuration. */
98 MEMORY
99 {
100 page0 (rwx) : ORIGIN = 0x0, LENGTH = 256
101 text (rx) : ORIGIN = ${ROM_START_ADDR}, LENGTH = ${ROM_SIZE}
102 data : ORIGIN = ${RAM_START_ADDR}, LENGTH = ${RAM_SIZE}
103 }
104
105 /* Setup the stack on the top of the data memory bank. */
106 PROVIDE (_stack = ${RAM_START_ADDR} + ${RAM_SIZE} - 1);
107 "
108 ;;
109 esac
110
111 STARTUP_CODE="
112 /* Startup code. */
113 KEEP (*(.install0)) /* Section should setup the stack pointer. */
114 KEEP (*(.install1)) /* Place holder for applications. */
115 KEEP (*(.install2)) /* Optional installation of data sections in RAM. */
116 KEEP (*(.install3)) /* Place holder for applications. */
117 KEEP (*(.install4)) /* Section that calls the main. */
118 "
119
120 FINISH_CODE="
121 /* Finish code. */
122 KEEP (*(.fini0)) /* Beginning of finish code (_exit symbol). */
123 KEEP (*(.fini1)) /* Place holder for applications. */
124 KEEP (*(.fini2)) /* C++ destructors. */
125 KEEP (*(.fini3)) /* Place holder for applications. */
126 KEEP (*(.fini4)) /* Runtime exit. */
127 "
128
129 PRE_COMPUTE_DATA_SIZE="
130 /* SCz: this does not work yet... This is supposed to force the loading
131 of _map_data.o (from libgcc.a) when the .data section is not empty.
132 By doing so, this should bring the code that copies the .data section
133 from ROM to RAM at init time.
134
135 ___pre_comp_data_size = SIZEOF(.data);
136 __install_data_sections = ___pre_comp_data_size > 0 ?
137 __map_data_sections : 0;
138 */
139 "
140
141 INSTALL_RELOC="
142 .install0 0 : { *(.install0) }
143 .install1 0 : { *(.install1) }
144 .install2 0 : { *(.install2) }
145 .install3 0 : { *(.install3) }
146 .install4 0 : { *(.install4) }
147 "
148
149 FINISH_RELOC="
150 .fini0 0 : { *(.fini0) }
151 .fini1 0 : { *(.fini1) }
152 .fini2 0 : { *(.fini2) }
153 .fini3 0 : { *(.fini3) }
154 .fini4 0 : { *(.fini4) }
155 "
156
157 BSS_DATA_RELOC="
158 .data1 0 : { *(.data1) }
159
160 /* We want the small data sections together, so single-instruction offsets
161 can access them all, and initialized data all before uninitialized, so
162 we can shorten the on-disk segment size. */
163 .sdata 0 : { *(.sdata) }
164 .sbss 0 : { *(.sbss) }
165 .scommon 0 : { *(.scommon) }
166 "
167
168 SOFT_REGS_RELOC="
169 .softregs 0 : { *(.softregs) }
170 "
171
172 cat <<EOF
173 ${RELOCATING+/* Linker script for 68HC12 executable (PROM). */}
174 ${RELOCATING-/* Linker script for 68HC12 object file (ld -r). */}
175
176 OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}",
177 "${LITTLE_OUTPUT_FORMAT}")
178 OUTPUT_ARCH(${OUTPUT_ARCH})
179 ENTRY(${ENTRY})
180
181 ${RELOCATING+${LIB_SEARCH_DIRS}}
182 ${RELOCATING+${EXECUTABLE_SYMBOLS}}
183 ${RELOCATING+${MEMORY_DEF}}
184
185 SECTIONS
186 {
187 .hash ${RELOCATING-0} : { *(.hash) }
188 .dynsym ${RELOCATING-0} : { *(.dynsym) }
189 .dynstr ${RELOCATING-0} : { *(.dynstr) }
190 .gnu.version ${RELOCATING-0} : { *(.gnu.version) }
191 .gnu.version_d ${RELOCATING-0} : { *(.gnu.version_d) }
192 .gnu.version_r ${RELOCATING-0} : { *(.gnu.version_r) }
193
194 .rel.text ${RELOCATING-0} :
195 {
196 *(.rel.text)
197 ${RELOCATING+*(.rel.text.*)}
198 ${RELOCATING+*(.rel.gnu.linkonce.t.*)}
199 }
200 .rela.text ${RELOCATING-0} :
201 {
202 *(.rela.text)
203 ${RELOCATING+*(.rela.text.*)}
204 ${RELOCATING+*(.rela.gnu.linkonce.t.*)}
205 }
206 .rel.data ${RELOCATING-0} :
207 {
208 *(.rel.data)
209 ${RELOCATING+*(.rel.data.*)}
210 ${RELOCATING+*(.rel.gnu.linkonce.d.*)}
211 }
212 .rela.data ${RELOCATING-0} :
213 {
214 *(.rela.data)
215 ${RELOCATING+*(.rela.data.*)}
216 ${RELOCATING+*(.rela.gnu.linkonce.d.*)}
217 }
218 .rel.rodata ${RELOCATING-0} :
219 {
220 *(.rel.rodata)
221 ${RELOCATING+*(.rel.rodata.*)}
222 ${RELOCATING+*(.rel.gnu.linkonce.r.*)}
223 }
224 .rela.rodata ${RELOCATING-0} :
225 {
226 *(.rela.rodata)
227 ${RELOCATING+*(.rela.rodata.*)}
228 ${RELOCATING+*(.rela.gnu.linkonce.r.*)}
229 }
230 .rel.sdata ${RELOCATING-0} :
231 {
232 *(.rel.sdata)
233 ${RELOCATING+*(.rel.sdata.*)}
234 ${RELOCATING+*(.rel.gnu.linkonce.s.*)}
235 }
236 .rela.sdata ${RELOCATING-0} :
237 {
238 *(.rela.sdata)
239 ${RELOCATING+*(.rela.sdata.*)}
240 ${RELOCATING+*(.rela.gnu.linkonce.s.*)}
241 }
242 .rel.sbss ${RELOCATING-0} :
243 {
244 *(.rel.sbss)
245 ${RELOCATING+*(.rel.sbss.*)}
246 ${RELOCATING+*(.rel.gnu.linkonce.sb.*)}
247 }
248 .rela.sbss ${RELOCATING-0} :
249 {
250 *(.rela.sbss)
251 ${RELOCATING+*(.rela.sbss.*)}
252 ${RELOCATING+*(.rel.gnu.linkonce.sb.*)}
253 }
254 .rel.bss ${RELOCATING-0} :
255 {
256 *(.rel.bss)
257 ${RELOCATING+*(.rel.bss.*)}
258 ${RELOCATING+*(.rel.gnu.linkonce.b.*)}
259 }
260 .rela.bss ${RELOCATING-0} :
261 {
262 *(.rela.bss)
263 ${RELOCATING+*(.rela.bss.*)}
264 ${RELOCATING+*(.rela.gnu.linkonce.b.*)}
265 }
266 .rel.stext ${RELOCATING-0} : { *(.rel.stest) }
267 .rela.stext ${RELOCATING-0} : { *(.rela.stest) }
268 .rel.etext ${RELOCATING-0} : { *(.rel.etest) }
269 .rela.etext ${RELOCATING-0} : { *(.rela.etest) }
270 .rel.sdata ${RELOCATING-0} : { *(.rel.sdata) }
271 .rela.sdata ${RELOCATING-0} : { *(.rela.sdata) }
272 .rel.edata ${RELOCATING-0} : { *(.rel.edata) }
273 .rela.edata ${RELOCATING-0} : { *(.rela.edata) }
274 .rel.eit_v ${RELOCATING-0} : { *(.rel.eit_v) }
275 .rela.eit_v ${RELOCATING-0} : { *(.rela.eit_v) }
276 .rel.ebss ${RELOCATING-0} : { *(.rel.ebss) }
277 .rela.ebss ${RELOCATING-0} : { *(.rela.ebss) }
278 .rel.srodata ${RELOCATING-0} : { *(.rel.srodata) }
279 .rela.srodata ${RELOCATING-0} : { *(.rela.srodata) }
280 .rel.erodata ${RELOCATING-0} : { *(.rel.erodata) }
281 .rela.erodata ${RELOCATING-0} : { *(.rela.erodata) }
282 .rel.got ${RELOCATING-0} : { *(.rel.got) }
283 .rela.got ${RELOCATING-0} : { *(.rela.got) }
284 .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) }
285 .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) }
286 .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) }
287 .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) }
288 .rel.init ${RELOCATING-0} : { *(.rel.init) }
289 .rela.init ${RELOCATING-0} : { *(.rela.init) }
290 .rel.fini ${RELOCATING-0} : { *(.rel.fini) }
291 .rela.fini ${RELOCATING-0} : { *(.rela.fini) }
292 .rel.plt ${RELOCATING-0} : { *(.rel.plt) }
293 .rela.plt ${RELOCATING-0} : { *(.rela.plt) }
294
295 /* Concatenate .page0 sections. Put them in the page0 memory bank
296 unless we are creating a relocatable file. */
297 .page0 :
298 {
299 *(.page0)
300 } ${RELOCATING+ > page0}
301
302 /* Start of text section. */
303 .stext ${RELOCATING-0} :
304 {
305 *(.stext)
306 } ${RELOCATING+ > ${TEXT_MEMORY}}
307
308 .init ${RELOCATING-0} :
309 {
310 *(.init)
311 } ${RELOCATING+=${NOP-0}}
312
313 ${RELOCATING-${INSTALL_RELOC}}
314 ${RELOCATING-${FINISH_RELOC}}
315
316 .text ${RELOCATING-0}:
317 {
318 /* Put startup code at beginning so that _start keeps same address. */
319 ${RELOCATING+${STARTUP_CODE}}
320
321 ${RELOCATING+*(.init)}
322 *(.text)
323 ${RELOCATING+*(.text.*)}
324 /* .gnu.warning sections are handled specially by elf32.em. */
325 *(.gnu.warning)
326 ${RELOCATING+*(.gnu.linkonce.t.*)}
327
328 ${RELOCATING+${FINISH_CODE}}
329
330 ${RELOCATING+_etext = .;}
331 ${RELOCATING+PROVIDE (etext = .);}
332
333 } ${RELOCATING+ > ${TEXT_MEMORY}}
334
335 .eh_frame ${RELOCATING-0} :
336 {
337 KEEP (*(.eh_frame))
338 } ${RELOCATING+ > ${TEXT_MEMORY}}
339
340 .rodata ${RELOCATING-0} :
341 {
342 *(.rodata)
343 ${RELOCATING+*(.rodata.*)}
344 ${RELOCATING+*(.gnu.linkonce.r*)}
345 } ${RELOCATING+ > ${TEXT_MEMORY}}
346
347 .rodata1 ${RELOCATING-0} :
348 {
349 *(.rodata1)
350 } ${RELOCATING+ > ${TEXT_MEMORY}}
351
352 /* Constructor and destructor tables are in ROM. */
353 ${RELOCATING+${CTOR}}
354 ${RELOCATING+${DTOR}}
355
356 .jcr ${RELOCATING-0} :
357 {
358 KEEP (*(.jcr))
359 } ${RELOCATING+ > ${TEXT_MEMORY}}
360
361 /* Start of the data section image in ROM. */
362 ${RELOCATING+__data_image = .;}
363 ${RELOCATING+PROVIDE (__data_image = .);}
364
365 /* All read-only sections that normally go in PROM must be above.
366 We construct the DATA image section in PROM at end of all these
367 read-only sections. The data image must be copied at init time.
368 Refer to GNU ld, Section 3.6.8.2 Output Section LMA. */
369 .data ${RELOCATING-0} : ${RELOCATING+AT (__data_image)}
370 {
371 ${RELOCATING+__data_section_start = .;}
372 ${RELOCATING+PROVIDE (__data_section_start = .);}
373
374 ${RELOCATING+${DATA_START_SYMBOLS}}
375 ${RELOCATING+*(.sdata)}
376 *(.data)
377 ${RELOCATING+*(.data.*)}
378 ${RELOCATING+*(.data1)}
379 ${RELOCATING+*(.gnu.linkonce.d.*)}
380 ${CONSTRUCTING+CONSTRUCTORS}
381
382 ${RELOCATING+_edata = .;}
383 ${RELOCATING+PROVIDE (edata = .);}
384 } ${RELOCATING+ > ${DATA_MEMORY}}
385
386 ${RELOCATING+__data_section_size = SIZEOF(.data);}
387 ${RELOCATING+PROVIDE (__data_section_size = SIZEOF(.data));}
388 ${RELOCATING+__data_image_end = __data_image + __data_section_size;}
389
390 ${RELOCATING+${PRE_COMPUTE_DATA_SIZE}}
391
392 /* .install ${RELOCATING-0}:
393 {
394 . = _data_image_end;
395 } ${RELOCATING+ > ${TEXT_MEMORY}} */
396
397 /* Relocation for some bss and data sections. */
398 ${RELOCATING-${BSS_DATA_RELOC}}
399 ${RELOCATING-${SOFT_REGS_RELOC}}
400
401 .bss ${RELOCATING-0} :
402 {
403 ${RELOCATING+__bss_start = .;}
404 ${RELOCATING+*(.softregs)}
405 ${RELOCATING+*(.sbss)}
406 ${RELOCATING+*(.scommon)}
407
408 *(.dynbss)
409 *(.bss)
410 ${RELOCATING+*(.bss.*)}
411 ${RELOCATING+*(.gnu.linkonce.b.*)}
412 *(COMMON)
413 ${RELOCATING+PROVIDE (_end = .);}
414 } ${RELOCATING+ > ${DATA_MEMORY}}
415 ${RELOCATING+__bss_size = SIZEOF(.bss);}
416 ${RELOCATING+PROVIDE (__bss_size = SIZEOF(.bss));}
417
418 .eeprom ${RELOCATING-0} :
419 {
420 *(.eeprom)
421 *(.eeprom.*)
422 } ${RELOCATING+ > ${EEPROM_MEMORY}}
423
424 ${RELOCATING+${VECTORS}}
425
426 /* Stabs debugging sections. */
427 .stab 0 : { *(.stab) }
428 .stabstr 0 : { *(.stabstr) }
429 .stab.excl 0 : { *(.stab.excl) }
430 .stab.exclstr 0 : { *(.stab.exclstr) }
431 .stab.index 0 : { *(.stab.index) }
432 .stab.indexstr 0 : { *(.stab.indexstr) }
433
434 .comment 0 : { *(.comment) }
435
436 /* DWARF debug sections.
437 Symbols in the DWARF debugging sections are relative to the beginning
438 of the section so we begin them at 0.
439 Treatment of DWARF debug section must be at end of the linker
440 script to avoid problems when there are undefined symbols. It's necessary
441 to avoid that the DWARF section is relocated before such undefined
442 symbols are found. */
443
444 /* DWARF 1 */
445 .debug 0 : { *(.debug) }
446 .line 0 : { *(.line) }
447
448 /* GNU DWARF 1 extensions */
449 .debug_srcinfo 0 : { *(.debug_srcinfo) }
450 .debug_sfnames 0 : { *(.debug_sfnames) }
451
452 /* DWARF 1.1 and DWARF 2 */
453 .debug_aranges 0 : { *(.debug_aranges) }
454 .debug_pubnames 0 : { *(.debug_pubnames) }
455
456 /* DWARF 2 */
457 .debug_info 0 : { *(.debug_info) *(.gnu.linkonce.wi.*) }
458 .debug_abbrev 0 : { *(.debug_abbrev) }
459 .debug_line 0 : { *(.debug_line) }
460 .debug_frame 0 : { *(.debug_frame) }
461 .debug_str 0 : { *(.debug_str) }
462 .debug_loc 0 : { *(.debug_loc) }
463 .debug_macinfo 0 : { *(.debug_macinfo) }
464 }
465 EOF
This page took 0.044638 seconds and 5 git commands to generate.