]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - ld/scripttempl/elfm68hc12.sc
* scripttempl/elfm68hc11.sc: Keep ctor/dtor sections; Take into
[thirdparty/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 KEEP (*(.ctors))
32
33 ${CONSTRUCTING+${CTOR_END}}
34 ${CONSTRUCTING+ PROVIDE(__CTOR_END__ = .); }
35 } ${RELOCATING+ > ${TEXT_MEMORY}}"
36
37 DTOR=" .dtors ${CONSTRUCTING-0} :
38 {
39 ${CONSTRUCTING+ PROVIDE(__DTOR_LIST__ = .); }
40 KEEP (*(.dtors))
41 ${CONSTRUCTING+ PROVIDE(__DTOR_END__ = .); }
42 } ${RELOCATING+ > ${TEXT_MEMORY}}"
43
44
45 VECTORS="
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 {
65 KEEP (*(.vectors))
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 #
72 case $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. */
78 INCLUDE memory.x;
79 "
80 ;;
81 *)
82 MEMORY_DEF="
83 /* Fixed definition of the available memory banks.
84 See generic emulation script for a user defined configuration. */
85 MEMORY
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. */
93 PROVIDE (_stack = ${RAM_START_ADDR} + ${RAM_SIZE} - 1);
94 "
95 ;;
96 esac
97
98 STARTUP_CODE="
99 /* Startup code. */
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. */
105 "
106
107 FINISH_CODE="
108 /* Finish code. */
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. */
114 "
115
116 PRE_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
128 INSTALL_RELOC="
129 .install0 0 : { *(.install0) }
130 .install1 0 : { *(.install1) }
131 .install2 0 : { *(.install2) }
132 .install3 0 : { *(.install3) }
133 .install4 0 : { *(.install4) }
134 "
135
136 FINISH_RELOC="
137 .fini0 0 : { *(.fini0) }
138 .fini1 0 : { *(.fini1) }
139 .fini2 0 : { *(.fini2) }
140 .fini3 0 : { *(.fini3) }
141 .fini4 0 : { *(.fini4) }
142 "
143
144 BSS_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
155 SOFT_REGS_RELOC="
156 .softregs 0 : { *(.softregs) }
157 "
158
159 cat <<EOF
160 ${RELOCATING+/* Linker script for 68HC12 executable (PROM). */}
161 ${RELOCATING-/* Linker script for 68HC12 object file (ld -r). */}
162
163 OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}",
164 "${LITTLE_OUTPUT_FORMAT}")
165 OUTPUT_ARCH(${OUTPUT_ARCH})
166 ENTRY(${ENTRY})
167
168 ${RELOCATING+${LIB_SEARCH_DIRS}}
169 ${RELOCATING+${EXECUTABLE_SYMBOLS}}
170 ${RELOCATING+${MEMORY_DEF}}
171
172 SECTIONS
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
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 }
253 .rel.stext ${RELOCATING-0} : { *(.rel.stest) }
254 .rela.stext ${RELOCATING-0} : { *(.rela.stest) }
255 .rel.etext ${RELOCATING-0} : { *(.rel.etest) }
256 .rela.etext ${RELOCATING-0} : { *(.rela.etest) }
257 .rel.sdata ${RELOCATING-0} : { *(.rel.sdata) }
258 .rela.sdata ${RELOCATING-0} : { *(.rela.sdata) }
259 .rel.edata ${RELOCATING-0} : { *(.rel.edata) }
260 .rela.edata ${RELOCATING-0} : { *(.rela.edata) }
261 .rel.eit_v ${RELOCATING-0} : { *(.rel.eit_v) }
262 .rela.eit_v ${RELOCATING-0} : { *(.rela.eit_v) }
263 .rel.ebss ${RELOCATING-0} : { *(.rel.ebss) }
264 .rela.ebss ${RELOCATING-0} : { *(.rela.ebss) }
265 .rel.srodata ${RELOCATING-0} : { *(.rel.srodata) }
266 .rela.srodata ${RELOCATING-0} : { *(.rela.srodata) }
267 .rel.erodata ${RELOCATING-0} : { *(.rel.erodata) }
268 .rela.erodata ${RELOCATING-0} : { *(.rela.erodata) }
269 .rel.got ${RELOCATING-0} : { *(.rel.got) }
270 .rela.got ${RELOCATING-0} : { *(.rela.got) }
271 .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) }
272 .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) }
273 .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) }
274 .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) }
275 .rel.init ${RELOCATING-0} : { *(.rel.init) }
276 .rela.init ${RELOCATING-0} : { *(.rela.init) }
277 .rel.fini ${RELOCATING-0} : { *(.rel.fini) }
278 .rela.fini ${RELOCATING-0} : { *(.rela.fini) }
279 .rel.plt ${RELOCATING-0} : { *(.rel.plt) }
280 .rela.plt ${RELOCATING-0} : { *(.rela.plt) }
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}}
301 ${RELOCATING-${FINISH_RELOC}}
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)
310 ${RELOCATING+*(.text.*)}
311 /* .gnu.warning sections are handled specially by elf32.em. */
312 *(.gnu.warning)
313 ${RELOCATING+*(.gnu.linkonce.t.*)}
314 ${RELOCATING+*(.tramp)}
315 ${RELOCATING+*(.tramp.*)}
316
317 ${RELOCATING+${FINISH_CODE}}
318
319 ${RELOCATING+_etext = .;}
320 ${RELOCATING+PROVIDE (etext = .);}
321
322 } ${RELOCATING+ > ${TEXT_MEMORY}}
323
324 .eh_frame ${RELOCATING-0} :
325 {
326 KEEP (*(.eh_frame))
327 } ${RELOCATING+ > ${TEXT_MEMORY}}
328
329 .rodata ${RELOCATING-0} :
330 {
331 *(.rodata)
332 ${RELOCATING+*(.rodata.*)}
333 ${RELOCATING+*(.gnu.linkonce.r*)}
334 } ${RELOCATING+ > ${TEXT_MEMORY}}
335
336 .rodata1 ${RELOCATING-0} :
337 {
338 *(.rodata1)
339 } ${RELOCATING+ > ${TEXT_MEMORY}}
340
341 /* Constructor and destructor tables are in ROM. */
342 ${RELOCATING+${CTOR}}
343 ${RELOCATING+${DTOR}}
344
345 .jcr ${RELOCATING-0} :
346 {
347 KEEP (*(.jcr))
348 } ${RELOCATING+ > ${TEXT_MEMORY}}
349
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)
366 ${RELOCATING+*(.data.*)}
367 ${RELOCATING+*(.data1)}
368 ${RELOCATING+*(.gnu.linkonce.d.*)}
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}}
388 ${RELOCATING-${SOFT_REGS_RELOC}}
389
390 .bss ${RELOCATING-0} :
391 {
392 ${RELOCATING+__bss_start = .;}
393 ${RELOCATING+*(.softregs)}
394 ${RELOCATING+*(.sbss)}
395 ${RELOCATING+*(.scommon)}
396
397 *(.dynbss)
398 *(.bss)
399 ${RELOCATING+*(.bss.*)}
400 ${RELOCATING+*(.gnu.linkonce.b.*)}
401 *(COMMON)
402 ${RELOCATING+PROVIDE (_end = .);}
403 } ${RELOCATING+ > ${DATA_MEMORY}}
404 ${RELOCATING+__bss_size = SIZEOF(.bss);}
405 ${RELOCATING+PROVIDE (__bss_size = SIZEOF(.bss));}
406
407 .eeprom ${RELOCATING-0} :
408 {
409 *(.eeprom)
410 *(.eeprom.*)
411 } ${RELOCATING+ > ${EEPROM_MEMORY}}
412
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 */
446 .debug_info 0 : { *(.debug_info) *(.gnu.linkonce.wi.*) }
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 }
454 EOF