1/*
2** ###################################################################
3**     Processor:           MK27FN2M0AVMI15
4**     Compiler:            GNU C Compiler
5**     Reference manual:    K27P169M150SF5RM, Rev. 2, Aug 2017
6**     Version:             rev. 1.3, 2018-01-09
7**     Build:               b190916
8**
9**     Abstract:
10**         Linker file for the GNU C Compiler
11**
12**     Copyright 2016 Freescale Semiconductor, Inc.
13**     Copyright 2016-2019 NXP
14**     All rights reserved.
15**
16**     SPDX-License-Identifier: BSD-3-Clause
17**
18**     http:                 www.nxp.com
19**     mail:                 support@nxp.com
20**
21** ###################################################################
22*/
23
24/* Entry Point */
25ENTRY(Reset_Handler)
26
27HEAP_SIZE  = DEFINED(__heap_size__)  ? __heap_size__  : 0x0400;
28STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0x0400;
29
30/* Specify the memory areas */
31MEMORY
32{
33  m_interrupts          (RX)  : ORIGIN = 0x00000000, LENGTH = 0x000003C0
34  m_bootloader_config   (RX)  : ORIGIN = 0x000003C0, LENGTH = 0x00000040
35  m_flash_config        (RX)  : ORIGIN = 0x00000400, LENGTH = 0x00000010
36  m_text                (RX)  : ORIGIN = 0x00000410, LENGTH = 0x001FFBF0
37  m_data                (RW)  : ORIGIN = 0x1FFC0000, LENGTH = 0x00040000
38  m_data_2              (RW)  : ORIGIN = 0x20000000, LENGTH = 0x00040000
39  m_data_3              (RW)  : ORIGIN = 0x34000000, LENGTH = 0x00080000
40}
41
42/* Define output sections */
43SECTIONS
44{
45  /* The startup code goes first into internal flash */
46  .interrupts :
47  {
48    . = ALIGN(4);
49    KEEP(*(.isr_vector))     /* Startup code */
50    . = ALIGN(4);
51  } > m_interrupts
52
53  .bootloader_config :
54  {
55    . = ALIGN(4);
56    KEEP(*(.BootloaderConfig)) /* Bootloader Configuration Area (BCA) */
57    . = ALIGN(4);
58  } > m_bootloader_config
59
60  .flash_config :
61  {
62    . = ALIGN(4);
63    KEEP(*(.FlashConfig))    /* Flash Configuration Field (FCF) */
64    . = ALIGN(4);
65  } > m_flash_config
66
67  /* The program code and other data goes into internal flash */
68  .text :
69  {
70    . = ALIGN(4);
71    *(.text)                 /* .text sections (code) */
72    *(.text*)                /* .text* sections (code) */
73    *(.rodata)               /* .rodata sections (constants, strings, etc.) */
74    *(.rodata*)              /* .rodata* sections (constants, strings, etc.) */
75    *(.glue_7)               /* glue arm to thumb code */
76    *(.glue_7t)              /* glue thumb to arm code */
77    *(.eh_frame)
78    KEEP (*(.init))
79    KEEP (*(.fini))
80    . = ALIGN(4);
81  } > m_text
82
83  .ARM.extab :
84  {
85    *(.ARM.extab* .gnu.linkonce.armextab.*)
86  } > m_text
87
88  .ARM :
89  {
90    __exidx_start = .;
91    *(.ARM.exidx*)
92    __exidx_end = .;
93  } > m_text
94
95 .ctors :
96  {
97    __CTOR_LIST__ = .;
98    /* gcc uses crtbegin.o to find the start of
99       the constructors, so we make sure it is
100       first.  Because this is a wildcard, it
101       doesn't matter if the user does not
102       actually link against crtbegin.o; the
103       linker won't look for a file to match a
104       wildcard.  The wildcard also means that it
105       doesn't matter which directory crtbegin.o
106       is in.  */
107    KEEP (*crtbegin.o(.ctors))
108    KEEP (*crtbegin?.o(.ctors))
109    /* We don't want to include the .ctor section from
110       from the crtend.o file until after the sorted ctors.
111       The .ctor section from the crtend file contains the
112       end of ctors marker and it must be last */
113    KEEP (*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors))
114    KEEP (*(SORT(.ctors.*)))
115    KEEP (*(.ctors))
116    __CTOR_END__ = .;
117  } > m_text
118
119  .dtors :
120  {
121    __DTOR_LIST__ = .;
122    KEEP (*crtbegin.o(.dtors))
123    KEEP (*crtbegin?.o(.dtors))
124    KEEP (*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors))
125    KEEP (*(SORT(.dtors.*)))
126    KEEP (*(.dtors))
127    __DTOR_END__ = .;
128  } > m_text
129
130  .preinit_array :
131  {
132    PROVIDE_HIDDEN (__preinit_array_start = .);
133    KEEP (*(.preinit_array*))
134    PROVIDE_HIDDEN (__preinit_array_end = .);
135  } > m_text
136
137  .init_array :
138  {
139    PROVIDE_HIDDEN (__init_array_start = .);
140    KEEP (*(SORT(.init_array.*)))
141    KEEP (*(.init_array*))
142    PROVIDE_HIDDEN (__init_array_end = .);
143  } > m_text
144
145  .fini_array :
146  {
147    PROVIDE_HIDDEN (__fini_array_start = .);
148    KEEP (*(SORT(.fini_array.*)))
149    KEEP (*(.fini_array*))
150    PROVIDE_HIDDEN (__fini_array_end = .);
151  } > m_text
152
153  __etext = .;    /* define a global symbol at end of code */
154  __DATA_ROM = .; /* Symbol is used by startup for data initialization */
155
156  .data : AT(__DATA_ROM)
157  {
158    . = ALIGN(4);
159    __DATA_RAM = .;
160    __data_start__ = .;      /* create a global symbol at data start */
161    *(.data)                 /* .data sections */
162    *(.data*)                /* .data* sections */
163    KEEP(*(.jcr*))
164    . = ALIGN(4);
165    __data_end__ = .;        /* define a global symbol at data end */
166  } > m_data
167
168  __NDATA_ROM = __DATA_ROM + (__data_end__ - __data_start__);
169  .ncache.init : AT(__NDATA_ROM)
170  {
171    __noncachedata_start__ = .;   /* create a global symbol at ncache data start */
172    *(NonCacheable.init)
173    . = ALIGN(4);
174    __noncachedata_init_end__ = .;   /* create a global symbol at initialized ncache data end */
175  } > m_data
176
177  . = __noncachedata_init_end__;
178  .ncache :
179  {
180    *(NonCacheable)
181    . = ALIGN(4);
182    __noncachedata_end__ = .;     /* define a global symbol at ncache data end */
183  } > m_data
184
185  __DATA_END = __NDATA_ROM + (__noncachedata_init_end__ - __noncachedata_start__);
186  text_end = ORIGIN(m_text) + LENGTH(m_text);
187  ASSERT(__DATA_END <= text_end, "region m_text overflowed with text and data")
188
189  /* Uninitialized data section */
190  .bss :
191  {
192    /* This is used by the startup in order to initialize the .bss section */
193    . = ALIGN(4);
194    __START_BSS = .;
195    __bss_start__ = .;
196    *(.bss)
197    *(.bss*)
198    *(COMMON)
199    . = ALIGN(4);
200    __bss_end__ = .;
201    __END_BSS = .;
202  } > m_data
203
204  .heap :
205  {
206    . = ALIGN(8);
207    __end__ = .;
208    PROVIDE(end = .);
209    __HeapBase = .;
210    . += HEAP_SIZE;
211    __HeapLimit = .;
212    __heap_limit = .; /* Add for _sbrk */
213  } > m_data_2
214
215  .stack :
216  {
217    . = ALIGN(8);
218    . += STACK_SIZE;
219  } > m_data_2
220
221  /* Initializes stack on the end of block */
222  __StackTop   = ORIGIN(m_data_2) + LENGTH(m_data_2);
223  __StackLimit = __StackTop - STACK_SIZE;
224  PROVIDE(__stack = __StackTop);
225
226  .ARM.attributes 0 : { *(.ARM.attributes) }
227
228  ASSERT(__StackLimit >= __HeapLimit, "region m_data_2 overflowed with stack and heap")
229}
230
231