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