3d877e8219bf4b7054f33369d52eac4eea0ee5be
[platform/upstream/connectedhomeip.git] / third_party / openthread / repo / examples / platforms / efr32mg21 / efr32mg21.ld
1 /*
2  *  Copyright (c) 2020, The OpenThread Authors.
3  *  All rights reserved.
4  *
5  *  Redistribution and use in source and binary forms, with or without
6  *  modification, are permitted provided that the following conditions are met:
7  *  1. Redistributions of source code must retain the above copyright
8  *     notice, this list of conditions and the following disclaimer.
9  *  2. Redistributions in binary form must reproduce the above copyright
10  *     notice, this list of conditions and the following disclaimer in the
11  *     documentation and/or other materials provided with the distribution.
12  *  3. Neither the name of the copyright holder nor the
13  *     names of its contributors may be used to endorse or promote products
14  *     derived from this software without specific prior written permission.
15  *
16  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17  *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  *  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20  *  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21  *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22  *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23  *  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24  *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25  *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26  *  POSSIBILITY OF SUCH DAMAGE.
27  */
28
29  /**
30  * @file
31  *   This file implements the OpenThread linker script for the
32  *   Silicon Labs efr32mg21 platform.
33  *
34  */
35
36 MEMORY
37 {
38   FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 1024K
39   RAM (rwx)  : ORIGIN = 0x20000000, LENGTH = 96K
40 }
41
42 /* Linker script to place sections and symbol values. Should be used together
43  * with other linker script that defines memory regions FLASH and RAM.
44  * It references following symbols, which must be defined in code:
45  *   Reset_Handler : Entry of reset handler
46  *
47  * It defines following symbols, which code can use without definition:
48  *   __exidx_start
49  *   __exidx_end
50  *   __copy_table_start__
51  *   __copy_table_end__
52  *   __zero_table_start__
53  *   __zero_table_end__
54  *   __etext
55  *   __data_start__
56  *   __preinit_array_start
57  *   __preinit_array_end
58  *   __init_array_start
59  *   __init_array_end
60  *   __fini_array_start
61  *   __fini_array_end
62  *   __data_end__
63  *   __bss_start__
64  *   __bss_end__
65  *   __end__
66  *   end
67  *   __HeapBase
68  *   __HeapLimit
69  *   __StackLimit
70  *   __StackTop
71  *   __stack
72  *   __Vectors_End
73  *   __Vectors_Size
74  */
75 ENTRY(Reset_Handler)
76
77 SECTIONS
78 {
79   .text :
80   {
81     KEEP(*(.vectors))
82     __Vectors_End = .;
83     __Vectors_Size = __Vectors_End - __Vectors;
84     __end__ = .;
85
86     *(.text*)
87
88     KEEP(*(.init))
89     KEEP(*(.fini))
90
91     /* .ctors */
92     *crtbegin.o(.ctors)
93     *crtbegin?.o(.ctors)
94     *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
95     *(SORT(.ctors.*))
96     *(.ctors)
97
98     /* .dtors */
99     *crtbegin.o(.dtors)
100     *crtbegin?.o(.dtors)
101     *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
102     *(SORT(.dtors.*))
103     *(.dtors)
104
105     *(.rodata*)
106
107     KEEP(*(.eh_frame*))
108   } > FLASH
109
110   .ARM.extab :
111   {
112     *(.ARM.extab* .gnu.linkonce.armextab.*)
113   } > FLASH
114
115   __exidx_start = .;
116   .ARM.exidx :
117   {
118     *(.ARM.exidx* .gnu.linkonce.armexidx.*)
119   } > FLASH
120   __exidx_end = .;
121
122   /* To copy multiple ROM to RAM sections,
123    * uncomment .copy.table section and,
124    * define __STARTUP_COPY_MULTIPLE in startup_ARMCMx.S */
125   /*
126   .copy.table :
127   {
128     . = ALIGN(4);
129     __copy_table_start__ = .;
130     LONG (__etext)
131     LONG (__data_start__)
132     LONG (__data_end__ - __data_start__)
133     LONG (__etext2)
134     LONG (__data2_start__)
135     LONG (__data2_end__ - __data2_start__)
136     __copy_table_end__ = .;
137   } > FLASH
138   */
139
140   /* To clear multiple BSS sections,
141    * uncomment .zero.table section and,
142    * define __STARTUP_CLEAR_BSS_MULTIPLE in startup_ARMCMx.S */
143   /*
144   .zero.table :
145   {
146     . = ALIGN(4);
147     __zero_table_start__ = .;
148     LONG (__bss_start__)
149     LONG (__bss_end__ - __bss_start__)
150     LONG (__bss2_start__)
151     LONG (__bss2_end__ - __bss2_start__)
152     __zero_table_end__ = .;
153   } > FLASH
154   */
155
156   __etext = .;
157
158   .data : AT (__etext)
159   {
160     __data_start__ = .;
161     *(vtable)
162     *(.data*)
163     . = ALIGN (4);
164     PROVIDE (__ram_func_section_start = .);
165     *(.ram)
166     PROVIDE (__ram_func_section_end = .);
167
168     . = ALIGN(4);
169     /* preinit data */
170     PROVIDE_HIDDEN (__preinit_array_start = .);
171     KEEP(*(.preinit_array))
172     PROVIDE_HIDDEN (__preinit_array_end = .);
173
174     . = ALIGN(4);
175     /* init data */
176     PROVIDE_HIDDEN (__init_array_start = .);
177     KEEP(*(SORT(.init_array.*)))
178     KEEP(*(.init_array))
179     PROVIDE_HIDDEN (__init_array_end = .);
180
181     . = ALIGN(4);
182     /* finit data */
183     PROVIDE_HIDDEN (__fini_array_start = .);
184     KEEP(*(SORT(.fini_array.*)))
185     KEEP(*(.fini_array))
186     PROVIDE_HIDDEN (__fini_array_end = .);
187
188     KEEP(*(.jcr*))
189     . = ALIGN(4);
190     /* All data end */
191     __data_end__ = .;
192
193   } > RAM
194
195   .bss :
196   {
197     . = ALIGN(4);
198     __bss_start__ = .;
199     *(.bss*)
200     *(COMMON)
201     . = ALIGN(4);
202     __bss_end__ = .;
203   } > RAM
204
205   .heap (COPY):
206   {
207     __HeapBase = .;
208     __end__ = .;
209     end = __end__;
210     _end = __end__;
211     KEEP(*(.heap*))
212     __HeapLimit = .;
213   } > RAM
214
215   /* .stack_dummy section doesn't contains any symbols. It is only
216    * used for linker to calculate size of stack sections, and assign
217    * values to stack symbols later */
218   .stack_dummy (COPY):
219   {
220     KEEP(*(.stack*))
221   } > RAM
222
223   /* Set stack top to end of RAM, and stack limit move down by
224    * size of stack_dummy section */
225   __StackTop = ORIGIN(RAM) + LENGTH(RAM);
226   __StackLimit = __StackTop - SIZEOF(.stack_dummy);
227   PROVIDE(__stack = __StackTop);
228
229   /*******************************************************************/
230   /* Define flash block for nvm3                                     */
231   .nvm (DSECT) : {
232     KEEP(*(.simee*))
233   } > FLASH
234
235   linker_nvm_end = ORIGIN(FLASH) + LENGTH(FLASH);
236   linker_nvm_begin = linker_nvm_end - SIZEOF(.nvm);
237   linker_nvm_size = SIZEOF(.nvm);
238   __nvm3Base = linker_nvm_begin;
239   /*******************************************************************/
240
241   /* Check if data + heap + stack exceeds RAM limit */
242   ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
243
244   /* Check if FLASH usage exceeds FLASH size */
245   /*ASSERT( LENGTH(FLASH) >= (__etext + SIZEOF(.data)), "FLASH memory overflowed !")*/
246 }