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