Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / examples / platform / efr32 / ldscripts / efr32-MG12P.ld
1 /*
2  *
3  *    Copyright (c) 2020 Project CHIP Authors
4  *    All rights reserved.
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  * Linker script for Silicon Labs EFR32MG12P devices
20  * @version 5.7.2
21  *******************************************************************************
22  * # License
23  * <b>Copyright 2018 Silicon Laboratories Inc. www.silabs.com</b>
24  *******************************************************************************
25  *
26  * SPDX-License-Identifier: Zlib
27  *
28  * The licensor of this software is Silicon Laboratories Inc.
29  *
30  * This software is provided 'as-is', without any express or implied
31  * warranty. In no event will the authors be held liable for any damages
32  * arising from the use of this software.
33  *
34  * Permission is granted to anyone to use this software for any purpose,
35  * including commercial applications, and to alter it and redistribute it
36  * freely, subject to the following restrictions:
37  *
38  * 1. The origin of this software must not be misrepresented; you must not
39  *    claim that you wrote the original software. If you use this software
40  *    in a product, an acknowledgment in the product documentation would be
41  *    appreciated but is not required.
42  * 2. Altered source versions must be plainly marked as such, and must not be
43  *    misrepresented as being the original software.
44  * 3. This notice may not be removed or altered from any source distribution.
45  *
46  ******************************************************************************/
47
48 MEMORY
49 {
50   FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 1048576
51   RAM (rwx)  : ORIGIN = 0x20000000, LENGTH = 262144
52 }
53
54 /* Linker script to place sections and symbol values. Should be used together
55  * with other linker script that defines memory regions FLASH and RAM.
56  * It references following symbols, which must be defined in code:
57  *   Reset_Handler : Entry of reset handler
58  *
59  * It defines following symbols, which code can use without definition:
60  *   __exidx_start
61  *   __exidx_end
62  *   __copy_table_start__
63  *   __copy_table_end__
64  *   __zero_table_start__
65  *   __zero_table_end__
66  *   __etext
67  *   __data_start__
68  *   __preinit_array_start
69  *   __preinit_array_end
70  *   __init_array_start
71  *   __init_array_end
72  *   __fini_array_start
73  *   __fini_array_end
74  *   __data_end__
75  *   __bss_start__
76  *   __bss_end__
77  *   __end__
78  *   end
79  *   __HeapBase
80  *   __HeapLimit
81  *   __StackLimit
82  *   __StackTop
83  *   __stack
84  *   __Vectors_End
85  *   __Vectors_Size
86  */
87 ENTRY(Reset_Handler)
88
89 SECTIONS
90 {
91   .text :
92   {
93     KEEP(*(.vectors))
94     __Vectors_End = .;
95     __Vectors_Size = __Vectors_End - __Vectors;
96     __end__ = .;
97
98     *(.text*)
99
100     KEEP(*(.init))
101     KEEP(*(.fini))
102
103     KEEP(*(.application_properties))
104           KEEP(*(.gecko_configuration))
105           KEEP(*(.xo_configuration))
106     KEEP(*(.gatt_header))
107     KEEP(*(.gatt_data))
108
109     /* .ctors */
110     *crtbegin.o(.ctors)
111     *crtbegin?.o(.ctors)
112     *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
113     *(SORT(.ctors.*))
114     *(.ctors)
115
116     /* .dtors */
117     *crtbegin.o(.dtors)
118     *crtbegin?.o(.dtors)
119     *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
120     *(SORT(.dtors.*))
121     *(.dtors)
122
123     *(.rodata*)
124
125
126     KEEP(*(.eh_frame*))
127   } > FLASH
128
129
130   .ARM.extab :
131   {
132     *(.ARM.extab* .gnu.linkonce.armextab.*)
133   } > FLASH
134
135   __exidx_start = .;
136   .ARM.exidx :
137   {
138     *(.ARM.exidx* .gnu.linkonce.armexidx.*)
139   } > FLASH
140   __exidx_end = .;
141
142
143
144   /* To copy multiple ROM to RAM sections,
145    * uncomment .copy.table section and,
146    * define __STARTUP_COPY_MULTIPLE in startup_ARMCMx.S */
147   /*
148   .copy.table :
149   {
150     . = ALIGN(4);
151     __copy_table_start__ = .;
152     LONG (__etext)
153     LONG (__data_start__)
154     LONG (__data_end__ - __data_start__)
155     LONG (__etext2)
156     LONG (__data2_start__)
157     LONG (__data2_end__ - __data2_start__)
158     __copy_table_end__ = .;
159   } > FLASH
160   */
161
162   /* To clear multiple BSS sections,
163    * uncomment .zero.table section and,
164    * define __STARTUP_CLEAR_BSS_MULTIPLE in startup_ARMCMx.S */
165   /*
166   .zero.table :
167   {
168     . = ALIGN(4);
169     __zero_table_start__ = .;
170     LONG (__bss_start__)
171     LONG (__bss_end__ - __bss_start__)
172     LONG (__bss2_start__)
173     LONG (__bss2_end__ - __bss2_start__)
174     __zero_table_end__ = .;
175   } > FLASH
176   */
177
178   __etext = .;
179
180   /*******************************************************************/
181   /* Define flash block for BLE-simee & chip-nvm3                    */
182   /* simee: 9000H (36k) bytes for BLE nvm3                           */
183   /* chipNvm3_section: 4000H (16k) bytes for chip nvm3.              */
184   /* 8K is reserved for OpenThread's NVM which is mapped directly at */
185   /* the top of flash                                                */
186   /*******************************************************************/
187
188   OPENTHREAD_NVM_SIZE = 8192;
189
190   .nvm_dummy (DSECT):
191   {
192     __nvm3_dummy_begin = .;
193     . = ALIGN (8192);
194     __nvm3_dummy_simee = .;
195     KEEP(*(.simee));
196     . = ALIGN (8192);
197     __nvm3_dummy_chip = .;
198     KEEP(*(chipNvm3_section));
199     . = ALIGN (8192);
200     . += OPENTHREAD_NVM_SIZE;
201     . = ALIGN (8192);
202   } > FLASH
203
204   /* Set NVM to end of FLASH */
205   __nvm3Base = LENGTH(FLASH) - SIZEOF(.nvm_dummy) + (__nvm3_dummy_simee - __nvm3_dummy_begin);
206   __chipNvm3Base = LENGTH(FLASH) - SIZEOF(.nvm_dummy) + (__nvm3_dummy_chip - __nvm3_dummy_begin);
207
208
209   /*******************************************************************/
210
211   .data : AT (__etext)
212   {
213     __data_start__ = .;
214     *(vtable)
215     *(.data*)
216     . = ALIGN (4);
217     PROVIDE (__ram_func_section_start = .);
218     *(.ram)
219     PROVIDE (__ram_func_section_end = .);
220
221     . = ALIGN(4);
222     /* preinit data */
223     PROVIDE_HIDDEN (__preinit_array_start = .);
224     KEEP(*(.preinit_array))
225     PROVIDE_HIDDEN (__preinit_array_end = .);
226
227     . = ALIGN(4);
228     /* init data */
229     PROVIDE_HIDDEN (__init_array_start = .);
230     KEEP(*(SORT(.init_array.*)))
231     KEEP(*(.init_array))
232     PROVIDE_HIDDEN (__init_array_end = .);
233
234     . = ALIGN(4);
235     /* finit data */
236     PROVIDE_HIDDEN (__fini_array_start = .);
237     KEEP(*(SORT(.fini_array.*)))
238     KEEP(*(.fini_array))
239     PROVIDE_HIDDEN (__fini_array_end = .);
240
241     KEEP(*(.jcr*))
242     . = ALIGN(4);
243     /* All data end */
244     __data_end__ = .;
245
246   } > RAM
247
248   .bss :
249   {
250     . = ALIGN(4);
251     __bss_start__ = .;
252     *(.bss*)
253     *(COMMON)
254     . = ALIGN(4);
255     __bss_end__ = .;
256   } > RAM
257
258   .heap (COPY):
259   {
260     __HeapBase = .;
261     __end__ = .;
262     end = __end__;
263     _end = __end__;
264     KEEP(*(.heap*))
265     __HeapLimit = .;
266   } > RAM
267
268   /* .stack_dummy section doesn't contains any symbols. It is only
269    * used for linker to calculate size of stack sections, and assign
270    * values to stack symbols later */
271   .stack_dummy (COPY):
272   {
273     KEEP(*(.stack*))
274   } > RAM
275
276   /* Set stack top to end of RAM, and stack limit move down by
277    * size of stack_dummy section */
278   __StackTop = ORIGIN(RAM) + LENGTH(RAM);
279   __StackLimit = __StackTop - SIZEOF(.stack_dummy);
280   PROVIDE(__stack = __StackTop);
281
282   /* Check if data + heap + stack exceeds RAM limit */
283   ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
284
285
286   /* Check if FLASH usage exceeds FLASH size */
287   ASSERT( LENGTH(FLASH) >= (__etext + SIZEOF(.data)), "FLASH memory overflowed !")
288   ASSERT((__etext + SIZEOF(.data)) <= __nvm3Base, "FLASH memory overlapped with NVM section.")
289 }