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