-
Notifications
You must be signed in to change notification settings - Fork 27
/
arm.ld
224 lines (190 loc) · 6.21 KB
/
arm.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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
/* Entry Point */
ENTRY(Reset_Handler)
/* Specify the memory areas */
MEMORY
{
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 96K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 20K
}
FLASH_START = ORIGIN(FLASH);
FLASH_SIZE = LENGTH(FLASH);
RAM_START = ORIGIN(RAM);
RAM_SIZE = LENGTH(RAM);
/* Shared memory size */
_Shared_Memory_Size = 128;
/* Generate a link error if stack don't fit into RAM */
_Min_Stack_Size = 0x2000; /* required amount of stack */
/* Highest address of the user mode stack */
_estack = RAM_START + RAM_SIZE - _Shared_Memory_Size;
/* Define output sections */
SECTIONS
{
/* The startup code goes first into FLASH */
.isr_vector :
{
. = ALIGN(4);
/*KEEP(*(.isr_vector)) *//* Startup code *//*moved down to text segment for sake of disassembly */
. = ALIGN(4);
} >FLASH
/* The program code and other data goes into FLASH */
.text :
{
___SVECTOR = .;
KEEP(*(.isr_vector)) /* Startup code */
ASSERT (. != ___SVECTOR, "No isr_vector input-section!");
. = ALIGN(4);
*(.text) /* .text sections (code) */
*(.text.*) /* .text* sections (code) */
*(.gnu.linkonce.t.*)
/**(.plt)*/
/**(.gnu.warning)*/
/**(.vfp11_veneer)*/
/**(.eh_frame)*/
*(EXCLUDE_FILE (*bootloader*) .rodata) /* .rodata sections (constants, strings, etc.) */
*(EXCLUDE_FILE (*bootloader*) .rodata.*) /* .rodata* sections (constants, strings, etc.) */
*(.gnu.linkonce.r.*)
*(.ARM.extab* .gnu.linkonce.armextab.*)
/**(.gcc_except_table)*/
/**(.eh_frame_hdr)*/
/**(.eh_frame)*/
. = ALIGN(4);
KEEP (*(.init))
. = ALIGN(4);
__preinit_array_start = .;
KEEP (*(.preinit_array))
__preinit_array_end = .;
. = ALIGN(4);
__init_array_start = .;
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array))
__init_array_end = .;
. = ALIGN(4);
KEEP (*(.fini))
. = ALIGN(4);
__fini_array_start = .;
KEEP (*(.fini_array))
KEEP (*(SORT(.fini_array.*)))
__fini_array_end = .;
} >FLASH
.ARM : {
__exidx_start = .;
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
__exidx_end = .;
} >FLASH
.text.align_etext :
{
. = ALIGN(8);
_etext = .;
} >FLASH
/*
Define bootloader text and data segments placement.
This will overlap .data segment, must not coexist with app.
*/
_bootloader_text_laddr = .;
_bootloader_text_vaddr = RAM_START;
_bootloader_text_lma_start = _bootloader_text_laddr;
.bootloader_text _bootloader_text_vaddr : AT ( _bootloader_text_laddr )
{
_bootloader_text_vma_start = .;
*(.bootloader_text)
*(.bootloader_text.*)
_bootloader_text_vma_end = .;
. = ALIGN(8);
}
_bootloader_data_laddr = _bootloader_text_laddr + SIZEOF (.bootloader_text);
_bootloader_data_vaddr = _bootloader_text_vaddr + SIZEOF (.bootloader_text);
_bootloader_data_lma_start = _bootloader_data_laddr;
.bootloader_data _bootloader_data_vaddr : AT ( _bootloader_data_laddr )
{
_bootloader_data_vma_start = .;
*bootloader*(.rodata) /* .rodata sections (constants, strings, etc.) */
*bootloader*(.rodata.*) /* .rodata sections (constants, strings, etc.) */
*(.bootloader_data)
*(.bootloader_data.*)
_bootloader_data_vma_end = .;
. = ALIGN(4);
}
/* Reset pointer */
. = _bootloader_data_laddr + SIZEOF (.bootloader_data);
/* used by the startup to initialize data */
_sidata = .;
/* Initialized data sections goes into RAM, load LMA copy after code */
.data : AT ( _sidata )
{
. = ALIGN(4);
_sdata = .; /* create a global symbol at data start */
*(.got.plt) *(.got)
*(.shdata)
*(.data) /* .data sections */
*(.data.*) /* .data* sections */
*(.gnu.linkonce.d.*)
. = ALIGN(4);
*(.ram_functions)
. = ALIGN(8);
_edata = .; /* define a global symbol at data end */
} >RAM
/* Uninitialized data section */
. = ALIGN(4);
.bss :
{
/* This is used by the startup in order to initialize the .bss secion */
_sbss = .; /* define a global symbol at bss start */
__bss_start__ = _sbss;
*(.bss)
*(.bss.*)
*(.gnu.linkonce.b.*)
*(COMMON)
. = ALIGN(8);
_ebss = .; /* define a global symbol at bss end */
__bss_end__ = _ebss;
} >RAM
. = ALIGN(4);
__stack_start__ = .;
. = ALIGN(4);
__stack_end__ = _estack;
/* Shared memory area, not wiped at reset */
.shmem (RAM_START + RAM_SIZE - _Shared_Memory_Size): {
__shared_memory_address__ = .; /* define a global symbol at shared memory start */
*(.shmem)
*(.shmem.*)
__shared_memory_address_end__ = .;
. = ALIGN(4);
} >RAM
.stab 0 (NOLOAD) : { *(.stab) }
.stabstr 0 (NOLOAD) : { *(.stabstr) }
/* DWARF debug sections.
* Symbols in the DWARF debugging sections are relative to the beginning
* of the section so we begin them at 0. */
/* DWARF 1 */
.debug 0 : { *(.debug) }
.line 0 : { *(.line) }
/* GNU DWARF 1 extensions */
.debug_srcinfo 0 : { *(.debug_srcinfo) }
.debug_sfnames 0 : { *(.debug_sfnames) }
/* DWARF 1.1 and DWARF 2 */
.debug_aranges 0 : { *(.debug_aranges) }
.debug_pubnames 0 : { *(.debug_pubnames) }
/* DWARF 2 */
.debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_line 0 : { *(.debug_line) }
.debug_frame 0 : { *(.debug_frame) }
.debug_str 0 : { *(.debug_str) }
.debug_loc 0 : { *(.debug_loc) }
.debug_macinfo 0 : { *(.debug_macinfo) }
/* SGI/MIPS DWARF 2 extensions */
.debug_weaknames 0 : { *(.debug_weaknames) }
.debug_funcnames 0 : { *(.debug_funcnames) }
.debug_typenames 0 : { *(.debug_typenames) }
.debug_varnames 0 : { *(.debug_varnames) }
.note.gnu.arm.ident 0 : { KEEP (*(.note.gnu.arm.ident)) }
.ARM.attributes 0 : { KEEP (*(.ARM.attributes)) }
/* Remove information from the standard libraries */
/*/DISCARD/ :
{
libc.a ( * )
libm.a ( * )
libgcc.a ( * )
*(.note.GNU-stack)
}*/
}