1 /* FreeEMS - the open source engine management system
3 Copyright 2008-2009 Fred Cooke
5 This file is part of the FreeEMS project.
7 FreeEMS software is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 FreeEMS software is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with any FreeEMS software. If not, see http://www.gnu.org/licenses/
20 We ask that if you make any changes to this file you email them upstream to
21 us at admin(at)diyefi(dot)org or, even better, fork the code on github.com!
23 Thank you for choosing FreeEMS to run your engine! */
28 * @brief The main linker script
30 * This is the linker script for hc9s12xdp512 executables. It takes the
31 * object files generated by the compiler and assembles (links) them
32 * together into one output file according to a set of rules within and
33 * provided by the other included files memory.x and regions.x
35 * A description of what some of this means can be found at the following URLs:
36 * - http://www.gnu.org/software/m68hc11/m68hc11_binutils.html
37 * - http://m68hc11.serveftp.org/wiki/index.php/FAQ:Link
43 OUTPUT_FORMAT("elf32-m68hc12", "elf32-m68hc12",
47 SEARCH_DIR("/usr/m68hc11/lib");
48 /* Get memory banks definition from some user configuration file.
49 This file must be located in some linker directory (search path
50 with -L<dir>). See fixed memory banks emulation script. */
58 .dynsym : { *(.dynsym) }
59 .dynstr : { *(.dynstr) }
60 .gnu.version : { *(.gnu.version) }
61 .gnu.version_d : { *(.gnu.version_d) }
62 .gnu.version_r : { *(.gnu.version_r) }
67 *(.rel.gnu.linkonce.t.*)
73 *(.rela.gnu.linkonce.t.*)
79 *(.rel.gnu.linkonce.d.*)
85 *(.rela.gnu.linkonce.d.*)
91 *(.rel.gnu.linkonce.r.*)
97 *(.rela.gnu.linkonce.r.*)
103 *(.rel.gnu.linkonce.s.*)
109 *(.rela.gnu.linkonce.s.*)
115 *(.rel.gnu.linkonce.sb.*)
121 *(.rel.gnu.linkonce.sb.*)
127 *(.rel.gnu.linkonce.b.*)
133 *(.rela.gnu.linkonce.b.*)
135 .rel.stext : { *(.rel.stest) }
136 .rela.stext : { *(.rela.stest) }
137 .rel.etext : { *(.rel.etest) }
138 .rela.etext : { *(.rela.etest) }
139 .rel.sdata : { *(.rel.sdata) }
140 .rela.sdata : { *(.rela.sdata) }
141 .rel.edata : { *(.rel.edata) }
142 .rela.edata : { *(.rela.edata) }
143 .rel.eit_v : { *(.rel.eit_v) }
144 .rela.eit_v : { *(.rela.eit_v) }
145 .rel.ebss : { *(.rel.ebss) }
146 .rela.ebss : { *(.rela.ebss) }
147 .rel.srodata : { *(.rel.srodata) }
148 .rela.srodata : { *(.rela.srodata) }
149 .rel.erodata : { *(.rel.erodata) }
150 .rela.erodata : { *(.rela.erodata) }
151 .rel.got : { *(.rel.got) }
152 .rela.got : { *(.rela.got) }
153 .rel.ctors : { *(.rel.ctors) }
154 .rela.ctors : { *(.rela.ctors) }
155 .rel.dtors : { *(.rel.dtors) }
156 .rela.dtors : { *(.rela.dtors) }
157 .rel.init : { *(.rel.init) }
158 .rela.init : { *(.rela.init) }
159 .rel.fini : { *(.rel.fini) }
160 .rela.fini : { *(.rela.fini) }
161 .rel.plt : { *(.rel.plt) }
162 .rela.plt : { *(.rela.plt) }
163 /* Concatenate .page0 sections. Put them in the page0 memory bank
164 unless we are creating a relocatable file. */
165 /* 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.
170 /* Start of text section. */
182 /* Put startup code at beginning so that _start keeps same address. */
184 KEEP (*(.install0)) /* Section should setup the stack pointer. */
185 KEEP (*(.install1)) /* Place holder for applications. */
186 KEEP (*(.install2)) /* Optional installation of data sections in RAM. */
187 KEEP (*(.install3)) /* Place holder for applications. */
188 KEEP (*(.install4)) /* Section that calls the main. */
193 /* .gnu.warning sections are handled specially by elf32.em. */
200 KEEP (*(.fini0)) /* Beginning of finish code (_exit symbol). */
201 KEEP (*(.fini1)) /* Place holder for applications. */
202 KEEP (*(.fini2)) /* C++ destructors. */
203 KEEP (*(.fini3)) /* Place holder for applications. */
204 KEEP (*(.fini4)) /* Runtime exit. */
231 /* Constructor and destructor tables are in ROM. */
235 PROVIDE (__CTOR_LIST__ = .);
237 PROVIDE(__CTOR_END__ = .);
241 PROVIDE(__DTOR_LIST__ = .);
243 PROVIDE(__DTOR_END__ = .);
249 /* Start of the data section image in ROM. */
251 PROVIDE (__data_image = .);
252 /* All read-only sections that normally go in PROM must be above.
253 We construct the DATA image section in PROM at end of all these
254 read-only sections. The data image must be copied at init time.
255 Refer to GNU ld, Section 3.6.8.2 Output Section LMA. */
256 .data : AT (__data_image)
258 __data_section_start = .;
259 PROVIDE (__data_section_start = .);
270 __data_section_size = SIZEOF(.data);
271 PROVIDE (__data_section_size = SIZEOF(.data));
272 __data_image_end = __data_image + __data_section_size;
274 /* SCz: this does not work yet... This is supposed to force the loading
275 of _map_data.o (from libgcc.a) when the .data section is not empty.
276 By doing so, this should bring the code that copies the .data section
277 from ROM to RAM at init time.
278 ___pre_comp_data_size = SIZEOF(.data);
279 __install_data_sections = ___pre_comp_data_size > 0 ?
280 __map_data_sections : 0;
286 /* Relocation for some bss and data sections. */
287 .bss : AT (ADDR(.bss))
300 __bss_size = SIZEOF(.bss);
301 PROVIDE (__bss_size = SIZEOF(.bss));
302 /* eeprom removed because hcs12mem doesnt seem to want to load it at the moment. maybe put it back later? */
308 /* 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. */
309 /* Diff this with /usr/m68hc11/lib/ldscripts/m68hc12elfb.x to compare. */
310 PROVIDE (_vectors_addr = DEFINED (vectors_addr) ? vectors_addr : 0xffc0);
311 .vectors DEFINED (vectors_addr) ? vectors_addr : 0xffc0 :
315 /* Stabs debugging sections. */
316 .stab 0 : { *(.stab) }
317 .stabstr 0 : { *(.stabstr) }
318 .stab.excl 0 : { *(.stab.excl) }
319 .stab.exclstr 0 : { *(.stab.exclstr) }
320 .stab.index 0 : { *(.stab.index) }
321 .stab.indexstr 0 : { *(.stab.indexstr) }
322 .comment 0 : { *(.comment) }
323 /* DWARF debug sections.
324 Symbols in the DWARF debugging sections are relative to the beginning
325 of the section so we begin them at 0.
326 Treatment of DWARF debug section must be at end of the linker
327 script to avoid problems when there are undefined symbols. It's necessary
328 to avoid that the DWARF section is relocated before such undefined
329 symbols are found. */
331 .debug 0 : { *(.debug) }
332 .line 0 : { *(.line) }
333 /* GNU DWARF 1 extensions */
334 .debug_srcinfo 0 : { *(.debug_srcinfo) }
335 .debug_sfnames 0 : { *(.debug_sfnames) }
336 /* DWARF 1.1 and DWARF 2 */
337 .debug_aranges 0 : { *(.debug_aranges) }
338 .debug_pubnames 0 : { *(.debug_pubnames) }
340 .debug_info 0 : { *(.debug_info) *(.gnu.linkonce.wi.*) }
341 .debug_abbrev 0 : { *(.debug_abbrev) }
342 .debug_line 0 : { *(.debug_line) }
343 .debug_frame 0 : { *(.debug_frame) }
344 .debug_str 0 : { *(.debug_str) }
345 .debug_loc 0 : { *(.debug_loc) }
346 .debug_macinfo 0 : { *(.debug_macinfo) }