-
Notifications
You must be signed in to change notification settings - Fork 5
/
linkerscript.ld
191 lines (155 loc) · 3.77 KB
/
linkerscript.ld
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
SEARCH_DIR(.);
/*
Format configurations
*/
OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm");
OUTPUT_ARCH(arm);
/*
The stack size used by the application. NOTE: you need to adjust according to your application.
*/
STACK_SIZE = 0x100;
/*
Memories definitions
*/
MEMORY
{
ram (rwx) : org = 0x20000000, len = 32k
}
/*
Entry point
*/
ENTRY( __reset_handler );
/*
Sections
*/
SECTIONS
{
/* Flash os information */
PrgCode :
{
. = ALIGN(4);
KEEP(*(PrgCode PrgCode.*));
. = ALIGN(4);
} > ram
/* Vector table. Has the initial stack pointer and the initial
structure for the arm interrupts */
.vectors :
{
. = ALIGN(128);
/* vector table */
KEEP(*(.vectors .vectors.*));
. = ALIGN(4);
} > ram
/* Text segment, stores all user code */
.text :
{
. = ALIGN(4);
/* text segment */
*(.text .text.* .gnu.linkonce.t.*);
/* glue arm to thumb code, glue thumb to arm code*/
*(.glue_7t .glue_7);
/* c++ exceptions */
*(.eh_frame .eh_frame_hdr)
/* exception unwinding information */
. = ALIGN(4);
*(.ARM.extab* .gnu.linkonce.armextab.*);
*(.ARM.exidx*)
. = ALIGN(4);
KEEP(*(.init));
. = ALIGN(4);
KEEP(*(.fini));
. = ALIGN(4);
} > ram
/* Read only data */
.rodata :
{
. = ALIGN(4);
/* Constands, strings, etc */
*(.rodata .rodata.* .gnu.linkonce.r.*);
. = ALIGN(4);
} > ram
/* Support C constructors, and C destructors in both user code
and the C library. This also provides support for C++ code. */
.preinit_array :
{
. = ALIGN(4);
PROVIDE(__preinit_array_start = .);
KEEP(*(.preinit_array))
PROVIDE(__preinit_array_end = .);
} > ram
.init_array :
{
. = ALIGN(4);
PROVIDE(__init_array_start = .);
KEEP(*(SORT(.init_array.*)))
KEEP(*(.init_array))
PROVIDE(__init_array_end = .);
} > ram
.fini_array :
{
. = ALIGN(4);
PROVIDE(__fini_array_start = .);
KEEP(*(SORT(.fini_array.*)))
KEEP(*(.fini_array))
PROVIDE(__fini_array_end = .);
} > ram
PrgData :
{
. = ALIGN(4);
KEEP(*(PrgData PrgData.*))
. = ALIGN(4);
} > ram
/* Data that needs to be initialized to a value different than 0 */
.data :
{
. = ALIGN(4);
PROVIDE(__data_init_start = LOADADDR(.data));
PROVIDE(__data_start = .);
. = ALIGN(4);
*(.data .data.* .gnu.linkonce.d.*)
. = ALIGN(4);
PROVIDE(__data_end = .);
PROVIDE(__data_init_end = LOADADDR(.data));
} > ram
/* Data that needs to be initialized to 0 */
.bss (NOLOAD) :
{
. = ALIGN(4);
PROVIDE(__bss_start = .);
*(.bss .bss.* .gnu.linkonce.b.*)
*(COMMON);
. = ALIGN(4);
PROVIDE(__bss_end = .);
} > ram
/* Stack segment */
.stack (NOLOAD) :
{
. = ALIGN(8);
PROVIDE(__stack_start = .);
. = . + STACK_SIZE;
PROVIDE(__stack_end = .);
} > ram
/* Heap segment */
.heap (NOLOAD) :
{
. = ALIGN(4);
PROVIDE(__heap_start = .);
PROVIDE(__heap_end = (ORIGIN(ram) + LENGTH(ram)));
} > ram
/* Flash device information */
DevDscr :
{
. = ALIGN(4);
KEEP(*(DevDscr DevDscr.*));
. = ALIGN(4);
} > ram
/* Remove information from the standard libraries */
/DISCARD/ :
{
libc.a ( * )
libm.a ( * )
libgcc.a ( * )
*(.note.GNU-stack)
}
.ARM.attributes 0 : { KEEP(*(.ARM.attributes)) }
}