Merge pull request #66 from arthurwolf/stepper
[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 KEEP(*(.isr_vector))
45 *(.text*)
46
47 KEEP(*(.init))
48 KEEP(*(.fini))
49
50 /* .ctors */
51 *crtbegin.o(.ctors)
52 *crtbegin?.o(.ctors)
53 *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
54 *(SORT(.ctors.*))
55 *(.ctors)
56
57 /* .dtors */
58 *crtbegin.o(.dtors)
59 *crtbegin?.o(.dtors)
60 *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
61 *(SORT(.dtors.*))
62 *(.dtors)
63
64 *(.rodata*)
65
66 KEEP(*(.eh_frame*))
67 } > FLASH
68
69 .ARM.extab :
70 {
71 *(.ARM.extab* .gnu.linkonce.armextab.*)
72 } > FLASH
73
74 __exidx_start = .;
75 .ARM.exidx :
76 {
77 *(.ARM.exidx* .gnu.linkonce.armexidx.*)
78 } > FLASH
79 __exidx_end = .;
80
81 __etext = .;
82
83 .data : AT (__etext)
84 {
85 __data_start__ = .;
86 Image$$RW_IRAM1$$Base = .;
87 *(vtable)
88 *(.data*)
89
90 . = ALIGN(4);
91 /* preinit data */
92 PROVIDE (__preinit_array_start = .);
93 KEEP(*(.preinit_array))
94 PROVIDE (__preinit_array_end = .);
95
96 . = ALIGN(4);
97 /* init data */
98 PROVIDE (__init_array_start = .);
99 KEEP(*(SORT(.init_array.*)))
100 KEEP(*(.init_array))
101 PROVIDE (__init_array_end = .);
102
103
104 . = ALIGN(4);
105 /* finit data */
106 PROVIDE (__fini_array_start = .);
107 KEEP(*(SORT(.fini_array.*)))
108 KEEP(*(.fini_array))
109 PROVIDE (__fini_array_end = .);
110
111 . = ALIGN(4);
112 /* All data end */
113 __data_end__ = .;
114
115 } > RAM
116
117 .bss :
118 {
119 __bss_start__ = .;
120 *(.bss*)
121 *(COMMON)
122 __bss_end__ = .;
123 Image$$RW_IRAM1$$ZI$$Limit = . ;
124 } > RAM
125
126 .heap :
127 {
128 __end__ = .;
129 end = __end__;
130 *(.heap*)
131 __HeapLimit = .;
132 } > RAM
133
134 /* .stack_dummy section doesn't contains any symbols. It is only
135 * used for linker to calculate size of stack sections, and assign
136 * values to stack symbols later */
137 .stack_dummy :
138 {
139 *(.stack)
140 } > RAM
141
142 /* Set stack top to end of RAM, and stack limit move down by
143 * size of stack_dummy section */
144 __StackTop = ORIGIN(RAM) + LENGTH(RAM);
145 __StackLimit = __StackTop - SIZEOF(.stack_dummy);
146 PROVIDE(__stack = __StackTop);
147
148 /* Check if data + heap + stack exceeds RAM limit */
149 ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
150
151
152 /* Code can explicitly ask for data to be
153 placed in these higher RAM banks where
154 they will be left uninitialized.
155 */
156 .AHBSRAM0 (NOLOAD):
157 {
158 Image$$RW_IRAM2$$Base = . ;
159 *(AHBSRAM0)
160 Image$$RW_IRAM2$$ZI$$Limit = .;
161 } > USB_RAM
162
163 .AHBSRAM1 (NOLOAD):
164 {
165 Image$$RW_IRAM3$$Base = . ;
166 *(AHBSRAM1)
167 Image$$RW_IRAM3$$ZI$$Limit = .;
168 } > ETH_RAM
169 }