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