Skip to content

Commit 5ec9b79

Browse files
committed
M2351: Support GCC
1. Enable GCC support on non-secure targets 2. Disable GCC support on secure targets becasue of GCC bug (as of 9-2019-q4-major): In non-secure entry function, callee-saved registers must be restored, but they are incorrectly cleared at optimization level "Os".
1 parent 9058a95 commit 5ec9b79

File tree

3 files changed

+447
-1
lines changed

3 files changed

+447
-1
lines changed
Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
/*
2+
* Copyright (c) 2018-2019, Nuvoton Technology Corporation
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
/*
20+
* Nuvoton M2351 GCC linker script file
21+
*/
22+
23+
#include "../../../device/partition_M2351_mem.h"
24+
25+
#if !defined(MBED_BOOT_STACK_SIZE)
26+
#define MBED_BOOT_STACK_SIZE 0x400
27+
#endif
28+
29+
StackSize = MBED_BOOT_STACK_SIZE;
30+
31+
MEMORY
32+
{
33+
VECTORS (rx) : ORIGIN = MBED_APP_START, LENGTH = 0x00000400
34+
FLASH (rx) : ORIGIN = MBED_APP_START + 0x400, LENGTH = MBED_APP_SIZE - 0x400
35+
RAM_INTERN (rwx) : ORIGIN = MBED_RAM_APP_START, LENGTH = MBED_RAM_APP_SIZE
36+
}
37+
38+
/**
39+
* Must match cmsis_nvic.h
40+
*/
41+
__vector_size = 4 * (16 + 102);
42+
43+
44+
/* Linker script to place sections and symbol values. Should be used together
45+
* with other linker script that defines memory regions FLASH and RAM.
46+
* It references following symbols, which must be defined in code:
47+
* Reset_Handler : Entry of reset handler
48+
*
49+
* It defines following symbols, which code can use without definition:
50+
* __exidx_start
51+
* __exidx_end
52+
* __etext
53+
* __data_start__
54+
* __preinit_array_start
55+
* __preinit_array_end
56+
* __init_array_start
57+
* __init_array_end
58+
* __fini_array_start
59+
* __fini_array_end
60+
* __data_end__
61+
* __bss_start__
62+
* __bss_end__
63+
* __end__
64+
* end
65+
* __HeapLimit
66+
* __StackLimit
67+
* __StackTop
68+
* __stack
69+
*/
70+
ENTRY(Reset_Handler)
71+
72+
SECTIONS
73+
{
74+
.isr_vector :
75+
{
76+
__vector_table = .;
77+
KEEP(*(.vector_table))
78+
. = ALIGN(8);
79+
} > VECTORS
80+
81+
.copy.table : ALIGN(4)
82+
{
83+
__copy_table_start__ = .;
84+
LONG (LOADADDR(.data))
85+
LONG (ADDR(.data))
86+
LONG (SIZEOF(.data))
87+
__copy_table_end__ = .;
88+
} > FLASH
89+
90+
.zero.table : ALIGN(4)
91+
{
92+
__zero_table_start__ = .;
93+
LONG (ADDR(.bss))
94+
LONG (SIZEOF(.bss))
95+
__zero_table_end__ = .;
96+
} > FLASH
97+
98+
.text :
99+
{
100+
*(.text*)
101+
102+
KEEP(*(.init))
103+
KEEP(*(.fini))
104+
105+
/* .ctors */
106+
*crtbegin.o(.ctors)
107+
*crtbegin?.o(.ctors)
108+
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
109+
*(SORT(.ctors.*))
110+
*(.ctors)
111+
112+
/* .dtors */
113+
*crtbegin.o(.dtors)
114+
*crtbegin?.o(.dtors)
115+
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
116+
*(SORT(.dtors.*))
117+
*(.dtors)
118+
119+
*(.rodata*)
120+
121+
KEEP(*(.eh_frame*))
122+
} > FLASH
123+
124+
.stack (NOLOAD) :
125+
{
126+
. = ALIGN(8);
127+
__StackLimit = .;
128+
. += StackSize;
129+
__StackTop = .;
130+
} > RAM_INTERN
131+
132+
PROVIDE(__stack = __StackTop);
133+
134+
.ARM.extab :
135+
{
136+
*(.ARM.extab* .gnu.linkonce.armextab.*)
137+
} > FLASH
138+
139+
.ARM.exidx :
140+
{
141+
__exidx_start = .;
142+
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
143+
__exidx_end = .;
144+
} > FLASH
145+
146+
/* Relocate vector table in SRAM */
147+
.isr_vector.reloc (NOLOAD) :
148+
{
149+
. = ALIGN(1 << LOG2CEIL(__vector_size));
150+
PROVIDE(__start_vector_table__ = .);
151+
. += __vector_size;
152+
PROVIDE(__end_vector_table__ = .);
153+
} > RAM_INTERN
154+
155+
.data :
156+
{
157+
PROVIDE( __etext = LOADADDR(.data) );
158+
159+
__data_start__ = .;
160+
*(vtable)
161+
*(.data*)
162+
163+
. = ALIGN(8);
164+
/* preinit data */
165+
PROVIDE_HIDDEN (__preinit_array_start = .);
166+
KEEP(*(.preinit_array))
167+
PROVIDE_HIDDEN (__preinit_array_end = .);
168+
169+
. = ALIGN(8);
170+
/* init data */
171+
PROVIDE_HIDDEN (__init_array_start = .);
172+
KEEP(*(SORT(.init_array.*)))
173+
KEEP(*(.init_array))
174+
PROVIDE_HIDDEN (__init_array_end = .);
175+
176+
. = ALIGN(8);
177+
/* finit data */
178+
PROVIDE_HIDDEN (__fini_array_start = .);
179+
KEEP(*(SORT(.fini_array.*)))
180+
KEEP(*(.fini_array))
181+
PROVIDE_HIDDEN (__fini_array_end = .);
182+
183+
/* All data end */
184+
. = ALIGN(32);
185+
__data_end__ = .;
186+
187+
} >RAM_INTERN AT>FLASH
188+
189+
.bss (NOLOAD):
190+
{
191+
__bss_start__ = .;
192+
*(.bss*)
193+
*(COMMON)
194+
__bss_end__ = .;
195+
} > RAM_INTERN
196+
197+
.heap (NOLOAD) :
198+
{
199+
. = ALIGN(8);
200+
__end__ = .;
201+
end = __end__;
202+
*(.heap*);
203+
. += (ORIGIN(RAM_INTERN) + LENGTH(RAM_INTERN) - .);
204+
__HeapLimit = .;
205+
} > RAM_INTERN
206+
Image$$ARM_LIB_HEAP$$ZI$$Base = ADDR(.heap);
207+
Image$$ARM_LIB_HEAP$$ZI$$Limit = ADDR(.heap) + SIZEOF(.heap);
208+
209+
PROVIDE(__heap_size = SIZEOF(.heap));
210+
PROVIDE(__mbed_sbrk_start = ADDR(.heap));
211+
PROVIDE(__mbed_krbs_start = ADDR(.heap) + SIZEOF(.heap));
212+
}

0 commit comments

Comments
 (0)