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