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 = 0x1FFC0000, LENGTH = 0x00000400
34  m_text                (RX)  : ORIGIN = 0x1FFC0400, LENGTH = 0x0003FC00
35  m_data                (RW)  : ORIGIN = 0x20000000, LENGTH = 0x00040000
36  m_data_2              (RW)  : ORIGIN = 0x34000000, LENGTH = 0x00080000
37}
38
39/* Define output sections */
40SECTIONS
41{
42  /* The startup code goes first into internal RAM */
43  .interrupts :
44  {
45    . = ALIGN(4);
46    KEEP(*(.isr_vector))     /* Startup code */
47    . = ALIGN(4);
48  } > m_interrupts
49
50  /* The program code and other data goes into internal RAM */
51  .text :
52  {
53    . = ALIGN(4);
54    *(.text)                 /* .text sections (code) */
55    *(.text*)                /* .text* sections (code) */
56    *(.rodata)               /* .rodata sections (constants, strings, etc.) */
57    *(.rodata*)              /* .rodata* sections (constants, strings, etc.) */
58    *(.glue_7)               /* glue arm to thumb code */
59    *(.glue_7t)              /* glue thumb to arm code */
60    *(.eh_frame)
61    KEEP (*(.init))
62    KEEP (*(.fini))
63    . = ALIGN(4);
64  } > m_text
65
66  .ARM.extab :
67  {
68    *(.ARM.extab* .gnu.linkonce.armextab.*)
69  } > m_text
70
71  .ARM :
72  {
73    __exidx_start = .;
74    *(.ARM.exidx*)
75    __exidx_end = .;
76  } > m_text
77
78 .ctors :
79  {
80    __CTOR_LIST__ = .;
81    /* gcc uses crtbegin.o to find the start of
82       the constructors, so we make sure it is
83       first.  Because this is a wildcard, it
84       doesn't matter if the user does not
85       actually link against crtbegin.o; the
86       linker won't look for a file to match a
87       wildcard.  The wildcard also means that it
88       doesn't matter which directory crtbegin.o
89       is in.  */
90    KEEP (*crtbegin.o(.ctors))
91    KEEP (*crtbegin?.o(.ctors))
92    /* We don't want to include the .ctor section from
93       from the crtend.o file until after the sorted ctors.
94       The .ctor section from the crtend file contains the
95       end of ctors marker and it must be last */
96    KEEP (*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors))
97    KEEP (*(SORT(.ctors.*)))
98    KEEP (*(.ctors))
99    __CTOR_END__ = .;
100  } > m_text
101
102  .dtors :
103  {
104    __DTOR_LIST__ = .;
105    KEEP (*crtbegin.o(.dtors))
106    KEEP (*crtbegin?.o(.dtors))
107    KEEP (*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors))
108    KEEP (*(SORT(.dtors.*)))
109    KEEP (*(.dtors))
110    __DTOR_END__ = .;
111  } > m_text
112
113  .preinit_array :
114  {
115    PROVIDE_HIDDEN (__preinit_array_start = .);
116    KEEP (*(.preinit_array*))
117    PROVIDE_HIDDEN (__preinit_array_end = .);
118  } > m_text
119
120  .init_array :
121  {
122    PROVIDE_HIDDEN (__init_array_start = .);
123    KEEP (*(SORT(.init_array.*)))
124    KEEP (*(.init_array*))
125    PROVIDE_HIDDEN (__init_array_end = .);
126  } > m_text
127
128  .fini_array :
129  {
130    PROVIDE_HIDDEN (__fini_array_start = .);
131    KEEP (*(SORT(.fini_array.*)))
132    KEEP (*(.fini_array*))
133    PROVIDE_HIDDEN (__fini_array_end = .);
134  } > m_text
135
136  __etext = .;    /* define a global symbol at end of code */
137  __DATA_ROM = .; /* Symbol is used by startup for data initialization */
138
139  .data : AT(__DATA_ROM)
140  {
141    . = ALIGN(4);
142    __DATA_RAM = .;
143    __data_start__ = .;      /* create a global symbol at data start */
144    *(.data)                 /* .data sections */
145    *(.data*)                /* .data* sections */
146    KEEP(*(.jcr*))
147    . = ALIGN(4);
148    __data_end__ = .;        /* define a global symbol at data end */
149  } > m_data
150
151  __NDATA_ROM = __DATA_ROM + (__data_end__ - __data_start__);
152  .ncache.init : AT(__NDATA_ROM)
153  {
154    __noncachedata_start__ = .;   /* create a global symbol at ncache data start */
155    *(NonCacheable.init)
156    . = ALIGN(4);
157    __noncachedata_init_end__ = .;   /* create a global symbol at initialized ncache data end */
158  } > m_data
159
160  . = __noncachedata_init_end__;
161  .ncache :
162  {
163    *(NonCacheable)
164    . = ALIGN(4);
165    __noncachedata_end__ = .;     /* define a global symbol at ncache data end */
166  } > m_data
167
168  __DATA_END = __NDATA_ROM + (__noncachedata_init_end__ - __noncachedata_start__);
169  text_end = ORIGIN(m_text) + LENGTH(m_text);
170  ASSERT(__DATA_END <= text_end, "region m_text overflowed with text and data")
171
172  /* Uninitialized data section */
173  .bss :
174  {
175    /* This is used by the startup in order to initialize the .bss section */
176    . = ALIGN(4);
177    __START_BSS = .;
178    __bss_start__ = .;
179    *(.bss)
180    *(.bss*)
181    *(COMMON)
182    . = ALIGN(4);
183    __bss_end__ = .;
184    __END_BSS = .;
185  } > m_data
186
187  .heap :
188  {
189    . = ALIGN(8);
190    __end__ = .;
191    PROVIDE(end = .);
192    __HeapBase = .;
193    . += HEAP_SIZE;
194    __HeapLimit = .;
195    __heap_limit = .; /* Add for _sbrk */
196  } > m_data
197
198  .stack :
199  {
200    . = ALIGN(8);
201    . += STACK_SIZE;
202  } > m_data
203
204  /* Initializes stack on the end of block */
205  __StackTop   = ORIGIN(m_data) + LENGTH(m_data);
206  __StackLimit = __StackTop - STACK_SIZE;
207  PROVIDE(__stack = __StackTop);
208
209  .ARM.attributes 0 : { *(.ARM.attributes) }
210
211  ASSERT(__StackLimit >= __HeapLimit, "region m_data overflowed with stack and heap")
212}
213
214