FreeEMS  0.2.0-SNAPSHOT-285-g028e24c
hc9s12xdp512elfb.x
Go to the documentation of this file.
1 /* FreeEMS - the open source engine management system
2 
3  Copyright 2008-2009 Fred Cooke
4 
5  This file is part of the FreeEMS project.
6 
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.
11 
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.
16 
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/
19 
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!
22 
23  Thank you for choosing FreeEMS to run your engine! */
24 
25 
26 /** @file
27  *
28  * @brief The main linker script
29  *
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
34  *
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
38  *
39  * @cond linkerscript
40  */
41 
42 
43 OUTPUT_FORMAT("elf32-m68hc12", "elf32-m68hc12",
44  "elf32-m68hc12")
45 OUTPUT_ARCH(m68hc12)
46 ENTRY(_start)
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. */
51 
52 INCLUDE memory.x;
53 INCLUDE regions.x;
54 
55 SECTIONS
56 {
57  .hash : { *(.hash) }
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) }
63  .rel.text :
64  {
65  *(.rel.text)
66  *(.rel.text.*)
67  *(.rel.gnu.linkonce.t.*)
68  }
69  .rela.text :
70  {
71  *(.rela.text)
72  *(.rela.text.*)
73  *(.rela.gnu.linkonce.t.*)
74  }
75  .rel.data :
76  {
77  *(.rel.data)
78  *(.rel.data.*)
79  *(.rel.gnu.linkonce.d.*)
80  }
81  .rela.data :
82  {
83  *(.rela.data)
84  *(.rela.data.*)
85  *(.rela.gnu.linkonce.d.*)
86  }
87  .rel.rodata :
88  {
89  *(.rel.rodata)
90  *(.rel.rodata.*)
91  *(.rel.gnu.linkonce.r.*)
92  }
93  .rela.rodata :
94  {
95  *(.rela.rodata)
96  *(.rela.rodata.*)
97  *(.rela.gnu.linkonce.r.*)
98  }
99  .rel.sdata :
100  {
101  *(.rel.sdata)
102  *(.rel.sdata.*)
103  *(.rel.gnu.linkonce.s.*)
104  }
105  .rela.sdata :
106  {
107  *(.rela.sdata)
108  *(.rela.sdata.*)
109  *(.rela.gnu.linkonce.s.*)
110  }
111  .rel.sbss :
112  {
113  *(.rel.sbss)
114  *(.rel.sbss.*)
115  *(.rel.gnu.linkonce.sb.*)
116  }
117  .rela.sbss :
118  {
119  *(.rela.sbss)
120  *(.rela.sbss.*)
121  *(.rel.gnu.linkonce.sb.*)
122  }
123  .rel.bss :
124  {
125  *(.rel.bss)
126  *(.rel.bss.*)
127  *(.rel.gnu.linkonce.b.*)
128  }
129  .rela.bss :
130  {
131  *(.rela.bss)
132  *(.rela.bss.*)
133  *(.rela.gnu.linkonce.b.*)
134  }
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.
166  .page0 :
167  {
168  *(.page0)
169  } > page0 */
170  /* Start of text section. */
171  .stext :
172  {
173  *(.stext)
174  } > text
175  .init :
176  {
177  *(.init)
178  } =0
179 
180  .text :
181  {
182  /* Put startup code at beginning so that _start keeps same address. */
183  /* Startup code. */
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. */
189  *(.init)
190  *(.text)
191  *(.text.*)
192 
193  /* .gnu.warning sections are handled specially by elf32.em. */
194  *(.gnu.warning)
195  *(.gnu.linkonce.t.*)
196  *(.tramp)
197  *(.tramp.*)
198 
199  /* Finish code. */
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. */
205  _etext = .;
206  PROVIDE (etext = .);
207  . = ALIGN(2);
208  } > text =0xa7a7a7a7
209  .eh_frame :
210  {
211  KEEP (*(.eh_frame))
212  } > text
213  .gcc_except_table :
214  {
215  *(.gcc_except_table)
216  } > text
217 
218  .rodata :
219  {
220  *(.rodata)
221  *(.rodata.*)
222  *(.gnu.linkonce.r*)
223  . = ALIGN(2);
224  } > text =0xffffffff
225 
226  .rodata1 :
227  {
228  *(.rodata1)
229  . = ALIGN(2);
230  } > text =0xffffffff
231  /* Constructor and destructor tables are in ROM. */
232 
233  .ctors :
234  {
235  PROVIDE (__CTOR_LIST__ = .);
236  KEEP (*(.ctors))
237  PROVIDE(__CTOR_END__ = .);
238  } > text
239  .dtors :
240  {
241  PROVIDE(__DTOR_LIST__ = .);
242  KEEP (*(.dtors))
243  PROVIDE(__DTOR_END__ = .);
244  } > text
245  .jcr :
246  {
247  KEEP (*(.jcr))
248  } > text
249  /* Start of the data section image in ROM. */
250  __data_image = .;
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)
257  {
258  __data_section_start = .;
259  PROVIDE (__data_section_start = .);
260  *(.sdata)
261  *(.data)
262  *(.data.*)
263  *(.data1)
264  *(.gnu.linkonce.d.*)
265  CONSTRUCTORS
266  _edata = .;
267  PROVIDE (edata = .);
268  . = ALIGN(2);
269  } > data =0xffffffff
270  __data_section_size = SIZEOF(.data);
271  PROVIDE (__data_section_size = SIZEOF(.data));
272  __data_image_end = __data_image + __data_section_size;
273 
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;
281 */
282  /* .install :
283  {
284  . = _data_image_end;
285  } > text */
286  /* Relocation for some bss and data sections. */
287  .bss : AT (ADDR(.bss))
288  {
289  __bss_start = .;
290  *(.softregs)
291  *(.sbss)
292  *(.scommon)
293  *(.dynbss)
294  *(.bss)
295  *(.bss.*)
296  *(.gnu.linkonce.b.*)
297  *(COMMON)
298  PROVIDE (_end = .);
299  } > data
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? */
303  /*.eeprom :
304  {
305  *(.eeprom)
306  *(.eeprom.*)
307  } > eeprom*/
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 :
312  {
313  KEEP (*(.vectors))
314  }
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. */
330  /* DWARF 1 */
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) }
339  /* DWARF 2 */
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) }
347 }
348 
349 
350 /** @endcond */