-
Notifications
You must be signed in to change notification settings - Fork 1
/
linkerscript.ld
201 lines (163 loc) · 4.43 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
192
193
194
195
196
197
198
199
200
201
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 = 0x1000;
/*
Memories definitions
*/
MEMORY
{
rom (rx) : org = 0x00000000 + 8k, len = 256k - 8k - 32k
/* Note: The profiles need to be sector aligned. The
storage erases the whole sector and writes the entries
back if we changed something. All other data in this
sector will be lost on changing the entries */
profiles (r) : org = 0x00000000 + 256k - 32k, len = 32k
ram (rwx) : org = 0x10000000, len = 16k
ram1 (rwx) : org = 0x2007C000, len = 16k
}
/*
Entry point
*/
ENTRY( __reset_handler );
/*
Sections
*/
SECTIONS
{
/* Vector table. Has the initial stack pointer and the initial
structure for the arm interrupts */
.vectors :
{
. = ALIGN(4);
/* vector table */
KEEP(*(.vectors .vectors.*));
. = ALIGN(4);
} > rom
/* 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);
} > rom
/* Read only data */
.rodata :
{
. = ALIGN(4);
/* Constands, strings, etc */
*(.rodata .rodata.* .gnu.linkonce.r.*);
. = ALIGN(4);
} > rom
/* 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 = .);
} > rom
.init_array :
{
. = ALIGN(4);
PROVIDE(__init_array_start = .);
KEEP(*(SORT(.init_array.*)))
KEEP(*(.init_array))
PROVIDE(__init_array_end = .);
} > rom
.fini_array :
{
. = ALIGN(4);
PROVIDE(__fini_array_start = .);
KEEP(*(SORT(.fini_array.*)))
KEEP(*(.fini_array))
PROVIDE(__fini_array_end = .);
} > rom
.profile (NOLOAD) :
{
/* provide the start and the end of the profile section */
PROVIDE(__profiles_start = .);
/* mark the whole section as filled with data */
. = . + LENGTH(profiles);
PROVIDE(__profiles_end = .);
} > profiles
/* Stack segment */
.stack (NOLOAD) :
{
. = ALIGN(4);
PROVIDE(__stack_start = .);
. = . + STACK_SIZE;
. = ALIGN(4);
PROVIDE(__stack_end = .);
} > ram
/* memory used for the framebuffer */
.framebuffer (NOLOAD) :
{
. = ALIGN(4);
/* vector table */
KEEP(*(.framebuffer .framebuffer.*));
. = ALIGN(4);
} > ram1
/* 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);
*(SORT_BY_ALIGNMENT(.data))
*(SORT_BY_ALIGNMENT(.data.*))
*(SORT_BY_ALIGNMENT(.gnu.linkonce.d.*))
. = ALIGN(4);
PROVIDE(__data_end = .);
PROVIDE(__data_init_end = LOADADDR(.data));
} > ram AT > rom
/* Data that needs to be initialized to 0 */
.bss (NOLOAD) :
{
. = ALIGN(4);
PROVIDE(__bss_start = .);
*(SORT_BY_ALIGNMENT(.bss))
*(SORT_BY_ALIGNMENT(.bss.*))
*(SORT_BY_ALIGNMENT(.gnu.linkonce.b.*))
*(COMMON);
. = ALIGN(4);
PROVIDE(__bss_end = .);
} > ram
/* Heap segment */
.heap (NOLOAD) :
{
. = ALIGN(4);
PROVIDE(__heap_start = .);
PROVIDE(__heap_end = (ORIGIN(ram1) + LENGTH(ram1)));
} > ram1
/* Remove information from the standard libraries */
/DISCARD/ :
{
libc.a ( * )
libm.a ( * )
libgcc.a ( * )
*(.note.GNU-stack)
}
.ARM.attributes 0 : { KEEP(*(.ARM.attributes)) }
}