1 /** @file hc9s12xdp512elfb.x
3 Copyright 2008 Fred Cooke
5 This is the linker script for hc9s12xdp512 executables. It takes the
6 object files generated by the compiler and assembles (links) them
7 together into one output file according to a set of rules within and
8 provided by the other included files memory.x and regions.x
10 This file is part of the FreeEMS project.
12 FreeEMS software is free software: you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation, either version 3 of the License, or
15 (at your option) any later version.
17 FreeEMS software is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with any FreeEMS software. If not, see http://www.gnu.org/licenses/
25 We ask that if you make any changes to this file you email them upstream to
26 us at admin(at)diyefi(dot)org or, even better, fork the code on github.com!
28 Thank you for choosing FreeEMS to run your engine!
33 /* A description of what some of this means can be found at the following URL */
34 /* http://www.gnu.org/software/m68hc11/m68hc11_binutils.html */
35 /* http://m68hc11.serveftp.org/wiki/index.php/FAQ:Link */
38 OUTPUT_FORMAT("elf32-m68hc12", "elf32-m68hc12",
42 SEARCH_DIR("/usr/m68hc11/lib");
43 /* Get memory banks definition from some user configuration file.
44 This file must be located in some linker directory (search path
45 with -L<dir>). See fixed memory banks emulation script. */
53 .dynsym : { *(.dynsym) }
54 .dynstr : { *(.dynstr) }
55 .gnu.version : { *(.gnu.version) }
56 .gnu.version_d : { *(.gnu.version_d) }
57 .gnu.version_r : { *(.gnu.version_r) }
62 *(.rel.gnu.linkonce.t.*)
68 *(.rela.gnu.linkonce.t.*)
74 *(.rel.gnu.linkonce.d.*)
80 *(.rela.gnu.linkonce.d.*)
86 *(.rel.gnu.linkonce.r.*)
92 *(.rela.gnu.linkonce.r.*)
98 *(.rel.gnu.linkonce.s.*)
104 *(.rela.gnu.linkonce.s.*)
110 *(.rel.gnu.linkonce.sb.*)
116 *(.rel.gnu.linkonce.sb.*)
122 *(.rel.gnu.linkonce.b.*)
128 *(.rela.gnu.linkonce.b.*)
130 .rel.stext : { *(.rel.stest) }
131 .rela.stext : { *(.rela.stest) }
132 .rel.etext : { *(.rel.etest) }
133 .rela.etext : { *(.rela.etest) }
134 .rel.sdata : { *(.rel.sdata) }
135 .rela.sdata : { *(.rela.sdata) }
136 .rel.edata : { *(.rel.edata) }
137 .rela.edata : { *(.rela.edata) }
138 .rel.eit_v : { *(.rel.eit_v) }
139 .rela.eit_v : { *(.rela.eit_v) }
140 .rel.ebss : { *(.rel.ebss) }
141 .rela.ebss : { *(.rela.ebss) }
142 .rel.srodata : { *(.rel.srodata) }
143 .rela.srodata : { *(.rela.srodata) }
144 .rel.erodata : { *(.rel.erodata) }
145 .rela.erodata : { *(.rela.erodata) }
146 .rel.got : { *(.rel.got) }
147 .rela.got : { *(.rela.got) }
148 .rel.ctors : { *(.rel.ctors) }
149 .rela.ctors : { *(.rela.ctors) }
150 .rel.dtors : { *(.rel.dtors) }
151 .rela.dtors : { *(.rela.dtors) }
152 .rel.init : { *(.rel.init) }
153 .rela.init : { *(.rela.init) }
154 .rel.fini : { *(.rel.fini) }
155 .rela.fini : { *(.rela.fini) }
156 .rel.plt : { *(.rel.plt) }
157 .rela.plt : { *(.rela.plt) }
158 /* Concatenate .page0 sections. Put them in the page0 memory bank
159 unless we are creating a relocatable file. */
160 /* Removed page0 from linker script and memory.x because A it shouldnt exceed 0xFF and B if it doesn't, it quickly fills up with virtually no code and complains.
165 /* Start of text section. */
177 /* Put startup code at beginning so that _start keeps same address. */
179 KEEP (*(.install0)) /* Section should setup the stack pointer. */
180 KEEP (*(.install1)) /* Place holder for applications. */
181 KEEP (*(.install2)) /* Optional installation of data sections in RAM. */
182 KEEP (*(.install3)) /* Place holder for applications. */
183 KEEP (*(.install4)) /* Section that calls the main. */
188 /* .gnu.warning sections are handled specially by elf32.em. */
195 KEEP (*(.fini0)) /* Beginning of finish code (_exit symbol). */
196 KEEP (*(.fini1)) /* Place holder for applications. */
197 KEEP (*(.fini2)) /* C++ destructors. */
198 KEEP (*(.fini3)) /* Place holder for applications. */
199 KEEP (*(.fini4)) /* Runtime exit. */
226 /* Constructor and destructor tables are in ROM. */
230 PROVIDE (__CTOR_LIST__ = .);
232 PROVIDE(__CTOR_END__ = .);
236 PROVIDE(__DTOR_LIST__ = .);
238 PROVIDE(__DTOR_END__ = .);
244 /* Start of the data section image in ROM. */
246 PROVIDE (__data_image = .);
247 /* All read-only sections that normally go in PROM must be above.
248 We construct the DATA image section in PROM at end of all these
249 read-only sections. The data image must be copied at init time.
250 Refer to GNU ld, Section 3.6.8.2 Output Section LMA. */
251 .data : AT (__data_image)
253 __data_section_start = .;
254 PROVIDE (__data_section_start = .);
265 __data_section_size = SIZEOF(.data);
266 PROVIDE (__data_section_size = SIZEOF(.data));
267 __data_image_end = __data_image + __data_section_size;
269 /* SCz: this does not work yet... This is supposed to force the loading
270 of _map_data.o (from libgcc.a) when the .data section is not empty.
271 By doing so, this should bring the code that copies the .data section
272 from ROM to RAM at init time.
273 ___pre_comp_data_size = SIZEOF(.data);
274 __install_data_sections = ___pre_comp_data_size > 0 ?
275 __map_data_sections : 0;
281 /* Relocation for some bss and data sections. */
282 .bss : AT (ADDR(.bss))
295 __bss_size = SIZEOF(.bss);
296 PROVIDE (__bss_size = SIZEOF(.bss));
297 /* eeprom removed because hcs12mem doesnt seem to want to load it at the moment. maybe put it back later? */
303 /* I had removed this due to placing it explicitly in the memory.x file. However that didn't work, so I've put it back. */
304 /* Diff this with /usr/m68hc11/lib/ldscripts/m68hc12elfb.x to compare. */
305 PROVIDE (_vectors_addr = DEFINED (vectors_addr) ? vectors_addr : 0xffc0);
306 .vectors DEFINED (vectors_addr) ? vectors_addr : 0xffc0 :
310 /* Stabs debugging sections. */
311 .stab 0 : { *(.stab) }
312 .stabstr 0 : { *(.stabstr) }
313 .stab.excl 0 : { *(.stab.excl) }
314 .stab.exclstr 0 : { *(.stab.exclstr) }
315 .stab.index 0 : { *(.stab.index) }
316 .stab.indexstr 0 : { *(.stab.indexstr) }
317 .comment 0 : { *(.comment) }
318 /* DWARF debug sections.
319 Symbols in the DWARF debugging sections are relative to the beginning
320 of the section so we begin them at 0.
321 Treatment of DWARF debug section must be at end of the linker
322 script to avoid problems when there are undefined symbols. It's necessary
323 to avoid that the DWARF section is relocated before such undefined
324 symbols are found. */
326 .debug 0 : { *(.debug) }
327 .line 0 : { *(.line) }
328 /* GNU DWARF 1 extensions */
329 .debug_srcinfo 0 : { *(.debug_srcinfo) }
330 .debug_sfnames 0 : { *(.debug_sfnames) }
331 /* DWARF 1.1 and DWARF 2 */
332 .debug_aranges 0 : { *(.debug_aranges) }
333 .debug_pubnames 0 : { *(.debug_pubnames) }
335 .debug_info 0 : { *(.debug_info) *(.gnu.linkonce.wi.*) }
336 .debug_abbrev 0 : { *(.debug_abbrev) }
337 .debug_line 0 : { *(.debug_line) }
338 .debug_frame 0 : { *(.debug_frame) }
339 .debug_str 0 : { *(.debug_str) }
340 .debug_loc 0 : { *(.debug_loc) }
341 .debug_macinfo 0 : { *(.debug_macinfo) }