-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathlink-script.ld
132 lines (107 loc) · 3.19 KB
/
link-script.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
/*
SPDX-FileCopyrightText: © 2020 Foundation Devices, Inc. <[email protected]>
SPDX-License-Identifier: GPL-3.0-or-later
SPDX-FileCopyrightText: 2018 Coinkite, Inc. <coldcardwallet.com>
SPDX-License-Identifier: GPL-3.0-only
*/
/* Memory layout for bootloader internal flash storage configuration:
FLASH_ISR .isr_vector
FLASH_TEXT .text
FLASH_TEXT .data
RAM .text
RAM .data
RAM .bss
RAM .stack
*/
OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
OUTPUT_ARCH(arm)
SEARCH_DIR(.)
/* Memory Spaces Definitions */
MEMORY
{
FLASH (rx) : ORIGIN = BL_FLASH_BASE, LENGTH = BL_FLASH_SIZE
DTCM (rwx) : ORIGIN = 0x20000000, LENGTH = 128K
ITCM (rwx) : ORIGIN = 0x00000000, LENGTH = 64K
}
/* The stack size used by the bootloader. */
STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : DEFINED(__stack_size__) ? __stack_size__ : 0x8000;
/* Firmware start address */
_bl_fw_base = BL_FW_BASE;
/* Section Definitions */
SECTIONS
{
.isr_vector :
{
. = ALIGN(4);
KEEP(*(.isr_vector)) /* Startup code */
. = ALIGN(4);
} > FLASH
.text :
{
. = ALIGN(4);
_sfixed = .;
KEEP(*(.entry_code))
. = ALIGN(256);
/* important: this pulls in library (libgcc) stuff here */
KEEP(*(.text .text.* .gnu.linkonce.t.*))
*(.rodata .rodata* .gnu.linkonce.r.*)
. = ALIGN(4);
_efixed = .; /* End of text section */
} > FLASH
/* .ARM.exidx is sorted, so has to go in its own output section. */
PROVIDE_HIDDEN (__exidx_start = .);
.ARM.exidx :
{
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
} > FLASH
PROVIDE_HIDDEN (__exidx_end = .);
. = ALIGN(4);
_etext = .;
_siram = LOADADDR(.ramfunc);
.ramfunc :
{
. = ALIGN(4);
_sram = .;
*(.ramfunc .ramfunc.*);
. = ALIGN(4);
_eram = .;
} >ITCM AT> FLASH
/* used by the startup to initialize data */
_sidata = LOADADDR(.data);
/* This is the initialized data section
The program executes knowing that the data is in the RAM
but the loader puts the initial values in the FLASH (inidata).
It is one task of the startup to copy the initial values from FLASH to RAM. */
.data :
{
. = ALIGN(4);
_sdata = .; /* create a global symbol at data start; used by startup code in order to initialise the .data section in RAM */
*(.data*) /* .data* sections */
. = ALIGN(4);
_edata = .; /* define a global symbol at data end; used by startup code in order to initialise the .data section in RAM */
} >DTCM AT> FLASH
/* .bss section which is used for uninitialized data */
.bss (NOLOAD) :
{
. = ALIGN(4);
_sbss = . ;
_szero = .;
*(.bss .bss.*)
*(COMMON)
. = ALIGN(4);
_ebss = . ;
_ezero = .;
} > DTCM
/* stack section */
.stack (NOLOAD):
{
. = ALIGN(8);
_sstack = .;
. = . + STACK_SIZE;
. = ALIGN(8);
_estack = .;
} > DTCM
. = ALIGN(4);
_end = . ;
end = _end;
}