Merge branch 'edge' into debugbreak
[clinton/Smoothieware.git] / gcc4mbed / build / mbed.ld
1 /* Linker script for mbed LPC1768 */
2 MEMORY
3 {
4 /* FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 512K */
5 FLASH (rx) : ORIGIN = 16K, LENGTH = (512K - 16K)
6 RAM (rwx) : ORIGIN = 0x100000C8, LENGTH = (32K - 0xC8)
7
8 USB_RAM(rwx) : ORIGIN = 0x2007C000, LENGTH = 16K
9 ETH_RAM(rwx) : ORIGIN = 0x20080000, LENGTH = 16K
10 }
11
12 /* Linker script to place sections and symbol values. Should be used together
13 * with other linker script that defines memory regions FLASH and RAM.
14 * It references following symbols, which must be defined in code:
15 * Reset_Handler : Entry of reset handler
16 *
17 * It defines following symbols, which code can use without definition:
18 * __exidx_start
19 * __exidx_end
20 * __etext
21 * __data_start__
22 * __preinit_array_start
23 * __preinit_array_end
24 * __init_array_start
25 * __init_array_end
26 * __fini_array_start
27 * __fini_array_end
28 * __data_end__
29 * __bss_start__
30 * __bss_end__
31 * __end__
32 * end
33 * __HeapLimit
34 * __StackLimit
35 * __StackTop
36 * __stack
37 */
38 ENTRY(Reset_Handler)
39
40 SECTIONS
41 {
42 .text :
43 {
44 __cs3_region_start_rom = .;
45 KEEP(*(.isr_vector))
46 *(.text*)
47
48 KEEP(*(.init))
49 KEEP(*(.fini))
50
51 /* .ctors */
52 *crtbegin.o(.ctors)
53 *crtbegin?.o(.ctors)
54 *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
55 *(SORT(.ctors.*))
56 *(.ctors)
57
58 /* .dtors */
59 *crtbegin.o(.dtors)
60 *crtbegin?.o(.dtors)
61 *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
62 *(SORT(.dtors.*))
63 *(.dtors)
64
65 *(.rodata*)
66
67 KEEP(*(.eh_frame*))
68 } > FLASH
69
70 .ARM.extab :
71 {
72 *(.ARM.extab* .gnu.linkonce.armextab.*)
73 } > FLASH
74
75 __exidx_start = .;
76 .ARM.exidx :
77 {
78 *(.ARM.exidx* .gnu.linkonce.armexidx.*)
79 } > FLASH
80 __exidx_end = .;
81
82 __etext = .;
83
84 .data : AT (__etext)
85 {
86 __cs3_region_start_ram = .;
87 __data_start__ = .;
88 Image$$RW_IRAM1$$Base = .;
89 *(vtable)
90 *(.data*)
91
92 . = ALIGN(4);
93 /* preinit data */
94 PROVIDE (__preinit_array_start = .);
95 KEEP(*(.preinit_array))
96 PROVIDE (__preinit_array_end = .);
97
98 . = ALIGN(4);
99 /* init data */
100 PROVIDE (__init_array_start = .);
101 KEEP(*(SORT(.init_array.*)))
102 KEEP(*(.init_array))
103 PROVIDE (__init_array_end = .);
104
105
106 . = ALIGN(4);
107 /* finit data */
108 PROVIDE (__fini_array_start = .);
109 KEEP(*(SORT(.fini_array.*)))
110 KEEP(*(.fini_array))
111 PROVIDE (__fini_array_end = .);
112
113 . = ALIGN(4);
114 /* All data end */
115 __data_end__ = .;
116
117 } > RAM
118
119 .bss :
120 {
121 __bss_start__ = .;
122 *(.bss*)
123 *(COMMON)
124 __bss_end__ = .;
125 Image$$RW_IRAM1$$ZI$$Limit = . ;
126 } > RAM
127
128 .heap :
129 {
130 __end__ = .;
131 end = __end__;
132 *(.heap*)
133 __HeapLimit = .;
134 } > RAM
135
136 /* .stack_dummy section doesn't contains any symbols. It is only
137 * used for linker to calculate size of stack sections, and assign
138 * values to stack symbols later */
139 .stack_dummy :
140 {
141 *(.stack)
142 } > RAM
143
144 /* Set stack top to end of RAM, and stack limit move down by
145 * size of stack_dummy section */
146 __StackTop = ORIGIN(RAM) + LENGTH(RAM);
147 __StackLimit = __StackTop - SIZEOF(.stack_dummy);
148 PROVIDE(__stack = __StackTop);
149
150 /* Check if data + heap + stack exceeds RAM limit */
151 ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
152
153
154 /* Code can explicitly ask for data to be
155 placed in these higher RAM banks where
156 they will be left uninitialized.
157 */
158 .AHBSRAM0 (NOLOAD):
159 {
160 Image$$RW_IRAM2$$Base = . ;
161 *(AHBSRAM0)
162 Image$$RW_IRAM2$$ZI$$Limit = .;
163 } > USB_RAM
164
165 .AHBSRAM1 (NOLOAD):
166 {
167 Image$$RW_IRAM3$$Base = . ;
168 *(AHBSRAM1)
169 Image$$RW_IRAM3$$ZI$$Limit = .;
170 } > ETH_RAM
171 }