1/* Linker script to configure memory regions
2 *
3 * Version:CodeSourcery Sourcery G++ Lite 2007q3-53
4 * BugURL:https://support.codesourcery.com/GNUToolchain/
5 *
6 *  Copyright 2007 CodeSourcery.
7 *
8 * The authors hereby grant permission to use, copy, modify, distribute,
9 * and license this software and its documentation for any purpose, provided
10 * that existing copyright notices are retained in all copies and that this
11 * notice is included verbatim in any distributions. No written agreement,
12 * license, or royalty fee is required for any of the authorized uses.
13 * Modifications to this software may be copyrighted by their authors
14 * and need not follow the licensing terms described here, provided that
15 * the new terms are clearly indicated on the first page of each file where
16 * they apply. */
17
18OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
19ENTRY(_start)
20SEARCH_DIR(.)
21
22MEMORY
23{
24  rom (rx)  : ORIGIN = 0x00000000, LENGTH = 0x00100000   /* 1024k */
25  ram (rwx) : ORIGIN = 0x1FFF0000, LENGTH = 0x00010000   /*   64k */
26}
27
28/* These force the linker to search for particular symbols from
29 * the start of the link process and thus ensure the user's
30 * overrides are picked up
31 */
32EXTERN(__cs3_reset_cortex_m)
33EXTERN(__cs3_interrupt_vector_cortex_m)
34EXTERN(__cs3_start_c main __cs3_stack __cs3_stack_size __cs3_heap_end)
35
36PROVIDE(__cs3_stack = __cs3_region_start_ram + __cs3_region_size_ram);
37PROVIDE(__cs3_stack_size = __cs3_region_start_ram + __cs3_region_size_ram - _end);
38PROVIDE(__cs3_heap_start = _end);
39PROVIDE(__cs3_heap_end = __cs3_region_start_ram + __cs3_region_size_ram);
40
41SECTIONS
42{
43    .text :
44    {
45        CREATE_OBJECT_SYMBOLS
46        __cs3_region_start_rom = .;
47        *(.cs3.region-head.rom)
48        __cs3_interrupt_vector = __cs3_interrupt_vector_cortex_m;
49        *(.cs3.interrupt_vector)
50        /* Make sure we pulled in an interrupt vector.  */
51        ASSERT (. != __cs3_interrupt_vector_cortex_m, "No interrupt vector");
52        *(.rom)
53        *(.rom.b)
54
55        __cs3_reset = __cs3_reset_cortex_m;
56        *(.cs3.reset)
57        /* Make sure we pulled in some reset code.  */
58        ASSERT (. != __cs3_reset, "No reset code");
59
60        *(.text .text.* .gnu.linkonce.t.*)
61        *(.plt)
62        *(.gnu.warning)
63        *(.glue_7t) *(.glue_7) *(.vfp11_veneer)
64
65        *(.rodata .rodata.* .gnu.linkonce.r.*)
66
67        *(.ARM.extab* .gnu.linkonce.armextab.*)
68        *(.gcc_except_table)
69        *(.eh_frame_hdr)
70        *(.eh_frame)
71
72        . = ALIGN(4);
73        KEEP(*(.init))
74
75        . = ALIGN(4);
76        __preinit_array_start = .;
77        KEEP (*(.preinit_array))
78        __preinit_array_end = .;
79
80        . = ALIGN(4);
81        __init_array_start = .;
82        KEEP (*(SORT(.init_array.*)))
83        KEEP (*(.init_array))
84        __init_array_end = .;
85
86        . = ALIGN(0x4);
87        KEEP (*crtbegin.o(.ctors))
88        KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
89        KEEP (*(SORT(.ctors.*)))
90        KEEP (*crtend.o(.ctors))
91
92        . = ALIGN(4);
93        KEEP(*(.fini))
94
95        . = ALIGN(4);
96        __fini_array_start = .;
97        KEEP (*(.fini_array))
98        KEEP (*(SORT(.fini_array.*)))
99        __fini_array_end = .;
100
101        KEEP (*crtbegin.o(.dtors))
102        KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
103        KEEP (*(SORT(.dtors.*)))
104        KEEP (*crtend.o(.dtors))
105
106        . = ALIGN(4);
107        __cs3_regions = .;
108        LONG (0)
109        LONG (__cs3_region_init_ram)
110        LONG (__cs3_region_start_ram)
111        LONG (__cs3_region_init_size_ram)
112        LONG (__cs3_region_zero_size_ram)
113
114        /* section information for finsh shell */
115        . = ALIGN(4);
116        __fsymtab_start = .;
117        KEEP(*(FSymTab))
118        __fsymtab_end = .;
119        . = ALIGN(4);
120        __vsymtab_start = .;
121        KEEP(*(VSymTab))
122        __vsymtab_end = .;
123        . = ALIGN(4);
124
125        . = ALIGN(4);
126        __rt_init_start = .;
127        KEEP(*(SORT(.rti_fn*)))
128        __rt_init_end = .;
129        . = ALIGN(4);
130
131    }
132
133    /* .ARM.exidx is sorted, so has to go in its own output section.  */
134    __exidx_start = .;
135    .ARM.exidx :
136    {
137      *(.ARM.exidx* .gnu.linkonce.armexidx.*)
138    } >rom
139    __exidx_end = .;
140    .text.align :
141    {
142      . = ALIGN(8);
143      _etext = .;
144    } >rom
145    __cs3_region_size_rom = LENGTH(rom);
146    __cs3_region_num = 1;
147
148    .data :
149    {
150        __cs3_region_start_ram = .;
151        *(.cs3.region-head.ram)
152        KEEP(*(.jcr))
153        *(.got.plt) *(.got)
154        *(.shdata)
155        *(.data .data.* .gnu.linkonce.d.*)
156        *(.ram)
157        . = ALIGN (8);
158        _edata = .;
159    } >ram AT>rom
160
161  .bss :
162  {
163    *(.shbss)
164    *(.bss .bss.* .gnu.linkonce.b.*)
165    *(COMMON)
166    *(.ram.b)
167    . = ALIGN (8);
168    _end = .;
169    __end = .;
170  } >ram AT>rom
171
172  .heap :
173  {
174    *(.heap)
175  } >ram
176
177  __bss_end = .;
178
179  .stack (__cs3_stack - __cs3_stack_size) :
180  {
181    *(.stack)
182  } >ram
183
184  __cs3_region_init_ram = LOADADDR (.data);
185  __cs3_region_init_size_ram = _edata - __cs3_region_start_ram;
186  __cs3_region_zero_size_ram = _end - _edata;
187  __cs3_region_size_ram = LENGTH(ram);
188  __cs3_region_num = 1;
189
190  .stab 0 (NOLOAD) : { *(.stab) }
191  .stabstr 0 (NOLOAD) : { *(.stabstr) }
192  /* DWARF debug sections.
193   * Symbols in the DWARF debugging sections are relative to the beginning
194   * of the section so we begin them at 0.  */
195  /* DWARF 1 */
196  .debug          0 : { *(.debug) }
197  .line           0 : { *(.line) }
198  /* GNU DWARF 1 extensions */
199  .debug_srcinfo  0 : { *(.debug_srcinfo) }
200  .debug_sfnames  0 : { *(.debug_sfnames) }
201  /* DWARF 1.1 and DWARF 2 */
202  .debug_aranges  0 : { *(.debug_aranges) }
203  .debug_pubnames 0 : { *(.debug_pubnames) }
204  /* DWARF 2 */
205  .debug_info     0 : { *(.debug_info .gnu.linkonce.wi.*) }
206  .debug_abbrev   0 : { *(.debug_abbrev) }
207  .debug_line     0 : { *(.debug_line) }
208  .debug_frame    0 : { *(.debug_frame) }
209  .debug_str      0 : { *(.debug_str) }
210  .debug_loc      0 : { *(.debug_loc) }
211  .debug_macinfo  0 : { *(.debug_macinfo) }
212  /* SGI/MIPS DWARF 2 extensions */
213  .debug_weaknames 0 : { *(.debug_weaknames) }
214  .debug_funcnames 0 : { *(.debug_funcnames) }
215  .debug_typenames 0 : { *(.debug_typenames) }
216  .debug_varnames  0 : { *(.debug_varnames) }
217
218  .note.gnu.arm.ident 0 : { KEEP (*(.note.gnu.arm.ident)) }
219  .ARM.attributes 0 : { KEEP (*(.ARM.attributes)) }
220  /DISCARD/ : { *(.note.GNU-stack) }
221}
222