CMSIS2000  0.0.7
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
gcc_arm.ld
Go to the documentation of this file.
1 /* Linker script to configure memory regions. */
2 MEMORY
3 {
4  FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x40000 /* 256k */
5  RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x08000 /* 32k */
6 }
7 
8 /* Library configurations */
9 GROUP(libgcc.a libc.a libm.a libnosys.a)
10 
11 /* Linker script to place sections and symbol values. Should be used together
12  * with other linker script that defines memory regions FLASH and RAM.
13  * It references following symbols, which must be defined in code:
14  * Reset_Handler : Entry of reset handler
15  *
16  * It defines following symbols, which code can use without definition:
17  * __exidx_start
18  * __exidx_end
19  * __etext
20  * __data_start__
21  * __preinit_array_start
22  * __preinit_array_end
23  * __init_array_start
24  * __init_array_end
25  * __fini_array_start
26  * __fini_array_end
27  * __data_end__
28  * __bss_start__
29  * __bss_end__
30  * __end__
31  * end
32  * __HeapLimit
33  * __StackLimit
34  * __StackTop
35  * __stack
36  */
38 
39 SECTIONS
40 {
41  .text :
42  {
43  KEEP(*(.isr_vector))
44  *(.text*)
45 
46  KEEP(*(.init))
47  KEEP(*(.fini))
48 
49  /* .ctors */
50  *crtbegin.o(.ctors)
51  *crtbegin?.o(.ctors)
52  *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
53  *(SORT(.ctors.*))
54  *(.ctors)
55 
56  /* .dtors */
57  *crtbegin.o(.dtors)
58  *crtbegin?.o(.dtors)
59  *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
60  *(SORT(.dtors.*))
61  *(.dtors)
62 
63  *(.rodata*)
64 
65  KEEP(*(.eh_frame*))
66  } > FLASH
67 
68  .ARM.extab :
69  {
70  *(.ARM.extab* .gnu.linkonce.armextab.*)
71  } > FLASH
72 
73  __exidx_start = .;
74  .ARM.exidx :
75  {
76  *(.ARM.exidx* .gnu.linkonce.armexidx.*)
77  } > FLASH
78  __exidx_end = .;
79 
80  __etext = .;
81 
82  .data : AT (__etext)
83  {
84  __data_start__ = .;
85  *(vtable)
86  *(.data*)
87 
88  . = ALIGN(4);
89  /* preinit data */
90  PROVIDE_HIDDEN (__preinit_array_start = .);
91  KEEP(*(.preinit_array))
92  PROVIDE_HIDDEN (__preinit_array_end = .);
93 
94  . = ALIGN(4);
95  /* init data */
96  PROVIDE_HIDDEN (__init_array_start = .);
97  KEEP(*(SORT(.init_array.*)))
98  KEEP(*(.init_array))
99  PROVIDE_HIDDEN (__init_array_end = .);
100 
101 
102  . = ALIGN(4);
103  /* finit data */
104  PROVIDE_HIDDEN (__fini_array_start = .);
105  KEEP(*(SORT(.fini_array.*)))
106  KEEP(*(.fini_array))
107  PROVIDE_HIDDEN (__fini_array_end = .);
108 
109  . = ALIGN(4);
110  /* All data end */
111  __data_end__ = .;
112 
113  } > RAM
114 
115  .bss :
116  {
117  __bss_start__ = .;
118  *(.bss*)
119  *(COMMON)
120  __bss_end__ = .;
121  } > RAM
122 
123  .heap :
124  {
125  __end__ = .;
126  end = __end__;
127  *(.heap*)
128  __HeapLimit = .;
129  } > RAM
130 
131  /* .stack_dummy section doesn't contains any symbols. It is only
132  * used for linker to calculate size of stack sections, and assign
133  * values to stack symbols later */
134  .stack_dummy :
135  {
136  *(.stack)
137  } > RAM
138 
139  /* Set stack top to end of RAM, and stack limit move down by
140  * size of stack_dummy section */
141  __StackTop = ORIGIN(RAM) + LENGTH(RAM);
142  __StackLimit = __StackTop - SIZEOF(.stack_dummy);
143  PROVIDE(__stack = __StackTop);
144 
145  /* Check if data + heap + stack exceeds RAM limit */
146  ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
147 }