source: trunk/libs/newlib/src/libgloss/msp430/msp430xl-sim.ld @ 546

Last change on this file since 546 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 14.4 KB
Line 
1/* Copyright (c) 2013-2015 Red Hat, Inc. All rights reserved.
2
3   This copyrighted material is made available to anyone wishing to use,
4   modify, copy, or redistribute it subject to the terms and conditions of
5   the BSD License.   This program is distributed in the hope that it will be
6   useful, but WITHOUT ANY WARRANTY expressed or implied, including the
7   implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
8   A copy of this license is available at http://www.opensource.org/licenses.
9
10   Any Red Hat trademarks that are incorporated in the source code or
11   documentation are not subject to the BSD License and may only be used or
12   replicated with the express permission of Red Hat, Inc.  */
13
14/* Example linker script, for large MSP430X executables.  */
15
16OUTPUT_ARCH(msp430)
17ENTRY(_start)
18
19INCLUDE intr_vectors.ld
20
21/* Note - These memory regions are just examples.  Real MSP430 MCUs will have
22   different varieties and sizes of RAM, ROM and FLASH.  Not all devices will
23   have all of these regions either.  Device specific linker scripts are
24   provided by TI, so this file is intended to be used as a guide and so that
25   toolchain tests can be run against the simulator.  */
26MEMORY
27{
28  RAM (rw)     : ORIGIN = 0x00500, LENGTH = 0x01b00
29  ROM (rx)     : ORIGIN = 0x02000, LENGTH = 0x0df00
30  /* The regions from intr_vectors.ld go here.  */
31  HIFRAM (rw)  : ORIGIN = 0x10000, LENGTH = 0x80000
32  HIROM (rx)   : ORIGIN = 0x90000, LENGTH = 0x70000
33}
34
35SECTIONS
36{
37  .resetvec :
38  {
39    *(.resetvec)
40  } > VECT31
41
42  .rodata :
43  {
44    . = ALIGN(2);
45    *(.plt)
46
47    . = ALIGN(2);
48    *(.lower.rodata.* .lower.rodata)
49
50    /* Note: By default we do not have this line:
51
52         *(.either.rodata.*) *(.either.rodata)
53
54       defined here, or anywhere else in this script.  This is deliberate.
55       The algorithm in the linker that automatically places rodata into
56       either the .rodata or the .upper.rodata sections relies upon the
57       fact that the .either.rodata section is not defined, and that the
58       .upper.rodata section is defined.  If the .upper.rodata is not
59       defined in this script then the line above should be restored so that
60       code compiled with -mdata-region=either enabled will still work.
61
62       The same reasoning applies to the absence of definitions for the
63       .either.text, .either.data and .either.bss sections as well.  */
64
65    . = ALIGN(2);
66    *(.rodata .rodata.* .gnu.linkonce.r.* .const .const:*)
67    *(.rodata1)
68
69    . = ALIGN(2);
70    KEEP (*(.gcc_except_table)) *(.gcc_except_table.*)
71    PROVIDE (__preinit_array_start = .);
72    KEEP (*(.preinit_array))
73    PROVIDE (__preinit_array_end = .);
74    PROVIDE (__init_array_start = .);
75    KEEP (*(SORT(.init_array.*)))
76    KEEP (*(.init_array))
77    PROVIDE (__init_array_end = .);
78    PROVIDE (__fini_array_start = .);
79    KEEP (*(.fini_array))
80    KEEP (*(SORT(.fini_array.*)))
81    PROVIDE (__fini_array_end = .);
82
83  } > ROM
84
85  /* Note: This is a separate .rodata section for sections which are
86     read only but which older linkers treat as read-write.
87     This prevents older linkers from marking the entire .rodata
88     section as read-write.  */
89  .rodata2 : {
90    . = ALIGN(2);
91    *(.eh_frame_hdr)
92    KEEP (*(.eh_frame))
93
94    /* gcc uses crtbegin.o to find the start of the constructors, so
95       we make sure it is first.  Because this is a wildcard, it
96       doesn't matter if the user does not actually link against
97       crtbegin.o; the linker won't look for a file to match a
98       wildcard.  The wildcard also means that it doesn't matter which
99       directory crtbegin.o is in.  */
100    KEEP (*crtbegin*.o(.ctors))
101
102    /* We don't want to include the .ctor section from from the
103       crtend.o file until after the sorted ctors.  The .ctor section
104       from the crtend file contains the end of ctors marker and it
105       must be last */
106    KEEP (*(EXCLUDE_FILE (*crtend*.o ) .ctors))
107    KEEP (*(SORT(.ctors.*)))
108    KEEP (*(.ctors))
109
110    KEEP (*crtbegin*.o(.dtors))
111    KEEP (*(EXCLUDE_FILE (*crtend*.o ) .dtors))
112    KEEP (*(SORT(.dtors.*)))
113    KEEP (*(.dtors))
114  } > ROM
115
116  .upper.rodata :
117  {
118    /* Note: If this section is not defined then please add:
119   
120         *(.either.rodata.*) *(.either.rodata)
121
122       to the definition of the .rodata section above.  This
123       will allow code compiled with -mdata-region=either to
124       work properly.  */
125
126    . = ALIGN(2);
127    *(.upper.rodata.* .upper.rodata)
128  } > HIROM
129
130  .data :
131  {
132    . = ALIGN(2);
133    PROVIDE (__datastart = .);
134    *(.lower.data.* .lower.data)
135
136    . = ALIGN(2);
137    KEEP (*(.jcr))
138    *(.data.rel.ro.local) *(.data.rel.ro*)
139    *(.dynamic)
140
141    . = ALIGN(2);
142    *(.data .data.* .gnu.linkonce.d.*)
143
144    /* See the note in .rodata section about why we do not have this line here:
145
146        *(.either.data.* .either.data)
147    */
148
149    KEEP (*(.gnu.linkonce.d.*personality*))
150    SORT(CONSTRUCTORS)
151    *(.data1)
152    *(.got.plt) *(.got)
153
154    /* We want the small data sections together, so single-instruction offsets
155       can access them all, and initialized data all before uninitialized, so
156       we can shorten the on-disk segment size.  */
157    . = ALIGN(2);
158    *(.sdata .sdata.* .gnu.linkonce.s.* D_2 D_1)
159
160    . = ALIGN(2);
161    _edata = .;
162    PROVIDE (edata = .);
163    PROVIDE (__dataend = .);
164
165    /* See the comment in the .upper.data section about the need
166       to copy data from ROM into RAM at program start up.  */
167  } > RAM AT> ROM
168
169  /* Note that crt0 assumes that __romdatacopysize is a multiple of two.
170     All the start/stop symbols are also assumed to be word-aligned.  */
171  __romdatastart = LOADADDR(.data);
172  __romdatacopysize = SIZEOF(.data);
173
174  /* ------------------- start of .upper.data sections.----------------  */
175  /* Note: If both HIROM and HIFRAM are available then the .upper.data
176     section should look like this:
177
178        . = ALIGN(2);
179        .upper.data :
180        {
181          __upper_data_init = LOADADDR (.upper.data);
182          /* Status word.  * /
183          SHORT(1);
184          __high_datastart = .;
185          *(.upper.data.* .upper.data)
186          __high_dataend = .;
187        } > HIFRAM AT> HIROM
188
189        __rom_highdatacopysize = SIZEOF(.upper.data) - 2;
190        __rom_highdatastart = LOADADDR(.upper.data) + 2;
191 
192      If only HIFRAM is available then the layout below must look like this:
193
194        .upper.data :
195        {
196          . = ALIGN(2);
197          __high_datastart = .;
198          *(.upper.data.* .upper.data)
199          __high_dataend = .;
200        } > HIFRAM
201
202        __rom_highdatacopysize = SIZEOF(.upper.data);
203
204        .shadow.upper.data :
205        {
206          . = ALIGN(2);
207          __upper_data_init = .;
208          /* Status word.  * /
209          SHORT(0);
210          /* Space for the copy of .upper.data.  * /
211          . = . + SIZEOF(.upper.data) - 2;
212         } > HIFRAM
213
214        __rom_highdatastart = LOADADDR(.shadow.upper.data) + 2;
215
216      Note - remove the space in this sequence: * / (twice) when you copy one
217      of the script fragments above into your script.
218
219      Note - the symbols defined here are *not* enclosed by the PROVIDE
220      keyword.  This is deliberate.  The crt0 library provides weak
221      definitions of these symbols and those weak definitions *must* be
222      overriden by the correct values.
223
224      The status word is used to control how the .upper.data section
225      is initialized at application start up.  If the word is non-zero
226      then data is copied from __rom_highdatastart to __high_datastart.
227      This corresponds with copying the contents of .upper.data from its
228      load address (HIROM) to its run-time address (HIFRAM) in the first
229      scenario, or from the .shadow.upper.section to the .upper.data in
230      the second scenario.
231
232      If the status word is zero then the data is copied the other way
233      and the word is set to one.  This only happens when the second
234      scenario is in play, and only the very first time the application
235      starts running.  This makes sure that the .shadow.upper.data section
236      contains a pristine copy of the .upper.data section that can be used
237      to reinitialize the .upper.data section upon device reset.
238
239      The status word is necessary as this allows us to have one routine
240      in crt0 that can handle either form of .upper.data layout.  IE crt0
241      is linker script agnostic.
242
243      Note - if the .upper.data section is not going to be defined at all
244      then please add this line back into the .data section above:
245
246        *(.either.data.* .either.data)
247    */
248
249  . = ALIGN(2);
250  .upper.data :
251  {
252    __upper_data_init = LOADADDR (.upper.data);
253    /* Status word.  */
254    SHORT(1);
255    __high_datastart = .;
256    *(.upper.data.* .upper.data)
257    __high_dataend = .;
258  } > HIFRAM AT> HIROM
259 
260  __rom_highdatacopysize = SIZEOF(.upper.data) - 2;
261  __rom_highdatastart = LOADADDR(.upper.data) + 2;
262
263  /* ------------------- end of .upper.data sections.----------------  */
264
265  .bss :
266  {
267    . = ALIGN(2);
268    PROVIDE (__bssstart = .);
269    *(.lower.bss.* .lower.bss)
270    *(.dynbss)
271    *(.sbss .sbss.*)
272    *(.bss .bss.* .gnu.linkonce.b.*)
273    /* See the note in .rodata section about why we do not have this line here:
274
275        *(.either.bss.* .either.bss)
276    */
277    . = ALIGN(2);
278    *(COMMON)
279    . = ALIGN(2);
280    PROVIDE (__bssend = .);
281  } > RAM
282  PROVIDE (__bsssize = SIZEOF(.bss));
283
284  /* This section contains data that is not initialised during load
285     *or* application reset.  */
286  .noinit (NOLOAD) :
287  {
288    . = ALIGN(2);
289    PROVIDE (__noinit_start = .);
290    *(.noinit)
291    . = ALIGN(2);
292    PROVIDE (__noinit_end = .);
293  } > RAM
294
295  /* This section contains data that *is* initialised during load
296     but *not* on application reset.  This section should be in FLASH.  */
297  .persistent :
298  {
299    . = ALIGN(2);
300    PROVIDE (__persistent_start = .);
301    *(.persistent)
302    . = ALIGN(2);
303    PROVIDE (__persistent_end = .);
304  } > HIFRAM
305 
306  .upper.bss :
307  {
308    /* Note - if this section is not going to be defined then please
309       add this line back into the definition of the .bss section above:
310       
311      *(.either.bss.* .either.bss)
312    */
313    . = ALIGN(2);
314    __high_bssstart = .;
315    *(.upper.bss.* .upper.bss)
316    . = ALIGN(2);
317    __high_bssend = .;
318  } > HIFRAM
319  __high_bsssize = SIZEOF(.upper.bss);
320
321  /* We create this section so that "end" will always be in the
322     HIFRAM region (matching .stack below), even if the .upper.bss
323     section is empty.  */
324  .heap_start :
325  {
326    . = ALIGN(2);
327    _end = .;
328    PROVIDE (end = .);
329    LONG(0);
330  } > HIFRAM
331
332  /* The __stack_size value of 0x100 is just a guess, but since it is
333     PROVIDEd the user can override it on the command line.  It has to be
334     set here, rather than inside the .stack section, as symbols defined
335     inside sections are only evaluated during the final phase of the link,
336     long after the ASSERT is checked.  An ASSERT referencing a PROVIDED but
337     not yet evaluated symbol will automatically fail.
338
339     FIXME: It would be nice if this value could be automatically set via
340     gcc's -fstack-usage command line option somehow.  */
341  PROVIDE (__stack_size = 0x100);
342
343  /* Note: We place the stack in HIFRAM because then there is less
344     chance that it will collide with allocated data in the RAM region.
345     In scripts targeted at real MCUs however it may be better to place
346     the stack and heap in RAM, as flash does have a limited number of
347     writes before failure.
348
349     Note - if the location of .stack is changed, then be sure to change
350     the definition of .heap_start above as well.  */
351  .stack (ORIGIN (HIFRAM) + LENGTH (HIFRAM)) :
352  {
353    PROVIDE (__stack = .);
354
355    /* Linker section checking ignores empty sections like
356       this one so we have to have our own test here.  */
357    ASSERT ((__stack > (_end + __stack_size)),
358            "Error: Too much data - no room left for the stack");
359  }
360
361  .text :
362  {
363    PROVIDE (_start = .);
364
365    . = ALIGN(2);
366    KEEP (*(SORT(.crt_*)))
367
368    . = ALIGN(2);
369    KEEP (*(.lowtext))
370
371    . = ALIGN(2);
372    *(.lower.text.* .lower.text)
373
374    . = ALIGN(2);
375    *(.text .stub .text.* .gnu.linkonce.t.* .text:*)
376
377    /* See the note in .rodata section about why we do not have this line here:
378
379        *(.either.text.* .either.text)
380    */
381   
382    KEEP (*(.text.*personality*))
383    /* .gnu.warning sections are handled specially by elf32.em.  */
384    *(.gnu.warning)
385    *(.interp .hash .dynsym .dynstr .gnu.version*)
386    PROVIDE (__etext = .);
387    PROVIDE (_etext = .);
388    PROVIDE (etext = .);
389    . = ALIGN(2);
390    KEEP (*(.init))
391    KEEP (*(.fini))
392    KEEP (*(.tm_clone_table))
393  } > ROM
394
395  .upper.text :
396  {
397    /* Note - if this section is not going to be included in the script
398       then please add this line back into the definition of the .text
399       section above:
400
401       *(.either.text.* .either.text)
402    */
403    . = ALIGN(2);
404    *(.upper.text.* .upper.text)
405  } > HIROM
406
407  /* The rest are all not normally part of the runtime image.  */
408
409  .MSP430.attributes 0 :
410  {
411    KEEP (*(.MSP430.attributes))
412    KEEP (*(.gnu.attributes))
413    KEEP (*(__TI_build_attributes))
414  }
415
416  /* Stabs debugging sections.  */
417  .stab          0 : { *(.stab) }
418  .stabstr       0 : { *(.stabstr) }
419  .stab.excl     0 : { *(.stab.excl) }
420  .stab.exclstr  0 : { *(.stab.exclstr) }
421  .stab.index    0 : { *(.stab.index) }
422  .stab.indexstr 0 : { *(.stab.indexstr) }
423  .comment       0 : { *(.comment) }
424  /* DWARF debug sections.
425     Symbols in the DWARF debugging sections are relative to the beginning
426     of the section so we begin them at 0.  */
427  /* DWARF 1.  */
428  .debug          0 : { *(.debug) }
429  .line           0 : { *(.line) }
430  /* GNU DWARF 1 extensions.  */
431  .debug_srcinfo  0 : { *(.debug_srcinfo) }
432  .debug_sfnames  0 : { *(.debug_sfnames) }
433  /* DWARF 1.1 and DWARF 2.  */
434  .debug_aranges  0 : { *(.debug_aranges) }
435  .debug_pubnames 0 : { *(.debug_pubnames) }
436  /* DWARF 2.  */
437  .debug_info     0 : { *(.debug_info .gnu.linkonce.wi.*) }
438  .debug_abbrev   0 : { *(.debug_abbrev) }
439  .debug_line     0 : { *(.debug_line .debug_line.* .debug_line_end ) }
440  .debug_frame    0 : { *(.debug_frame) }
441  .debug_str      0 : { *(.debug_str) }
442  .debug_loc      0 : { *(.debug_loc) }
443  .debug_macinfo  0 : { *(.debug_macinfo) }
444  /* SGI/MIPS DWARF 2 extensions.  */
445  .debug_weaknames 0 : { *(.debug_weaknames) }
446  .debug_funcnames 0 : { *(.debug_funcnames) }
447  .debug_typenames 0 : { *(.debug_typenames) }
448  .debug_varnames  0 : { *(.debug_varnames) }
449  /* DWARF 3 */
450  .debug_pubtypes 0 : { *(.debug_pubtypes) }
451  .debug_ranges   0 : { *(.debug_ranges) }
452  /* DWARF Extension.  */
453  .debug_macro    0 : { *(.debug_macro) }
454
455  /DISCARD/ : { *(.note.GNU-stack) }
456}
Note: See TracBrowser for help on using the repository browser.