1/*
2** ###################################################################
3**     Processors:          MIMX8DX1AVLFZ
4**                          MIMX8DX1AVOFZ
5**
6**     Compiler:            GNU C Compiler
7**     Reference manual:    IMX8DQXPRM, Rev. E, 6/2019
8**     Version:             rev. 4.0, 2020-06-19
9**     Build:               b201113
10**
11**     Abstract:
12**         Linker file for the GNU C Compiler
13**
14**     Copyright 2016 Freescale Semiconductor, Inc.
15**     Copyright 2016-2020 NXP
16**     All rights reserved.
17**
18**     SPDX-License-Identifier: BSD-3-Clause
19**
20**     http:                 www.nxp.com
21**     mail:                 support@nxp.com
22**
23** ###################################################################
24*/
25
26/* Entry Point */
27ENTRY(Reset_Handler)
28
29HEAP_SIZE  = DEFINED(__heap_size__)  ? __heap_size__  : 0x0400;
30STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0x0400;
31
32/* Reserved for PFU fetches, which is six 16-bit Thumb instructions */
33SAFE_BOUNDARY_LEN = 12;
34
35/* Specify the memory areas */
36/* M4 always start up from TCM. The SCU will copy the first 32 bytes of the binary to TCM
37if the start address is not TCM. The TCM region [0x1FFE0000-0x1FFE001F] is reserved for this purpose. */
38MEMORY
39{
40  m_interrupts          (RX)  : ORIGIN = DEFINED(__STARTUP_CONFIG_DDR_ALIAS)?0x08000000:0x88000000, LENGTH = 0x00000A00
41  m_text                (RX)  : ORIGIN = DEFINED(__STARTUP_CONFIG_DDR_ALIAS)?0x08000A00:0x88000A00, LENGTH = 0x001FF600
42  m_data                (RW)  : ORIGIN = 0x88200000, LENGTH = 0x00200000
43  m_data2               (RW)  : ORIGIN = 0x88400000, LENGTH = 0x07C00000
44  m_tcml                (RW)  : ORIGIN = 0x1FFE0020, LENGTH = 0x0001FFE0
45  m_tcmu                (RW)  : ORIGIN = 0x20000000, LENGTH = 0x00020000
46}
47
48/* Define output sections */
49SECTIONS
50{
51  /* The startup code goes first into internal RAM */
52  .interrupts :
53  {
54    . = ALIGN(4);
55    KEEP(*(.isr_vector))     /* Startup code */
56    . = ALIGN(4);
57  } > m_interrupts
58
59  .resource_table :
60  {
61    . = ALIGN(8);
62    KEEP(*(.resource_table)) /* Resource table */
63    . = ALIGN(8);
64  } > m_text
65
66  /* The program code and other data goes into internal RAM */
67  .text :
68  {
69    . = ALIGN(4);
70    *(.text)                 /* .text sections (code) */
71    *(.text*)                /* .text* sections (code) */
72    *(.rodata)               /* .rodata sections (constants, strings, etc.) */
73    *(.rodata*)              /* .rodata* sections (constants, strings, etc.) */
74    *(.glue_7)               /* glue arm to thumb code */
75    *(.glue_7t)              /* glue thumb to arm code */
76    *(.eh_frame)
77    KEEP (*(.init))
78    KEEP (*(.fini))
79    . = ALIGN(4);
80  } > m_text
81
82  .ARM.extab :
83  {
84    *(.ARM.extab* .gnu.linkonce.armextab.*)
85  } > m_text
86
87  .ARM :
88  {
89    __exidx_start = .;
90    *(.ARM.exidx*)
91    __exidx_end = .;
92  } > m_text
93
94 .ctors :
95  {
96    __CTOR_LIST__ = .;
97    /* gcc uses crtbegin.o to find the start of
98       the constructors, so we make sure it is
99       first.  Because this is a wildcard, it
100       doesn't matter if the user does not
101       actually link against crtbegin.o; the
102       linker won't look for a file to match a
103       wildcard.  The wildcard also means that it
104       doesn't matter which directory crtbegin.o
105       is in.  */
106    KEEP (*crtbegin.o(.ctors))
107    KEEP (*crtbegin?.o(.ctors))
108    /* We don't want to include the .ctor section from
109       from the crtend.o file until after the sorted ctors.
110       The .ctor section from the crtend file contains the
111       end of ctors marker and it must be last */
112    KEEP (*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors))
113    KEEP (*(SORT(.ctors.*)))
114    KEEP (*(.ctors))
115    __CTOR_END__ = .;
116  } > m_text
117
118  .dtors :
119  {
120    __DTOR_LIST__ = .;
121    KEEP (*crtbegin.o(.dtors))
122    KEEP (*crtbegin?.o(.dtors))
123    KEEP (*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors))
124    KEEP (*(SORT(.dtors.*)))
125    KEEP (*(.dtors))
126    __DTOR_END__ = .;
127  } > m_text
128
129  .preinit_array :
130  {
131    PROVIDE_HIDDEN (__preinit_array_start = .);
132    KEEP (*(.preinit_array*))
133    PROVIDE_HIDDEN (__preinit_array_end = .);
134  } > m_text
135
136  .init_array :
137  {
138    PROVIDE_HIDDEN (__init_array_start = .);
139    KEEP (*(SORT(.init_array.*)))
140    KEEP (*(.init_array*))
141    PROVIDE_HIDDEN (__init_array_end = .);
142  } > m_text
143
144  .fini_array :
145  {
146    PROVIDE_HIDDEN (__fini_array_start = .);
147    KEEP (*(SORT(.fini_array.*)))
148    KEEP (*(.fini_array*))
149    PROVIDE_HIDDEN (__fini_array_end = .);
150  } > m_text
151
152  __etext = .;    /* define a global symbol at end of code */
153  __DATA_ROM = .; /* Symbol is used by startup for data initialization */
154
155  .data : AT(__DATA_ROM)
156  {
157    . = ALIGN(4);
158    __DATA_RAM = .;
159    __data_start__ = .;      /* create a global symbol at data start */
160    *(.data)                 /* .data sections */
161    *(.data*)                /* .data* sections */
162    KEEP(*(.jcr*))
163    . = ALIGN(4);
164    __data_end__ = .;        /* define a global symbol at data end */
165  } > m_data
166
167  __TDATA_ROM = __DATA_ROM + SIZEOF(.data); /* Symbol is used by startup for TCM data initialization */
168  .quickaccess : AT(__TDATA_ROM)
169  {
170    __quickaccess_start__ = .;
171    . = ALIGN(32);
172    *(CodeQuickAccess)
173    . += SAFE_BOUNDARY_LEN;
174    *(DataQuickAccess)
175    . = ALIGN(128);
176    __quickaccess_end__ = .;
177  } > m_tcml
178
179  __CACHE_REGION_START = DEFINED(__STARTUP_CONFIG_DDR_ALIAS) ? ORIGIN(m_data) : ORIGIN(m_interrupts);
180  __CACHE_REGION_SIZE = DEFINED(__STARTUP_CONFIG_DDR_ALIAS) ? LENGTH(m_data) : LENGTH(m_interrupts) + LENGTH(m_text) + LENGTH(m_data);
181
182
183  __NDATA_ROM = __TDATA_ROM + SIZEOF(.quickaccess); /* Symbol is used by startup for ncache data initialization */
184
185  .ncache.init : AT(__NDATA_ROM)
186  {
187    __noncachedata_start__ = .;   /* create a global symbol at ncache data start */
188    *(NonCacheable.init)
189    . = ALIGN(4);
190    __noncachedata_init_end__ = .;   /* create a global symbol at initialized ncache data end */
191  } > m_data2
192
193  . = __noncachedata_init_end__;
194  .ncache :
195  {
196    *(NonCacheable)
197    . = ALIGN(4);
198    __noncachedata_end__ = .;     /* define a global symbol at ncache data end */
199  } > m_data2
200
201  __DATA_END = __NDATA_ROM + SIZEOF(.ncache.init);
202  text_end = ORIGIN(m_text) + LENGTH(m_text);
203  ASSERT(__DATA_END <= text_end, "region m_text overflowed with text and data")
204
205  /* Uninitialized data section */
206  .bss :
207  {
208    /* This is used by the startup in order to initialize the .bss section */
209    . = ALIGN(4);
210    __START_BSS = .;
211    __bss_start__ = .;
212    *(.bss)
213    *(.bss*)
214    *(COMMON)
215    . = ALIGN(4);
216    __bss_end__ = .;
217    __END_BSS = .;
218  } > m_data
219
220  .heap :
221  {
222    . = ALIGN(8);
223    __end__ = .;
224    PROVIDE(end = .);
225    __HeapBase = .;
226    . += HEAP_SIZE;
227    __HeapLimit = .;
228    __heap_limit = .; /* Add for _sbrk */
229  } > m_data
230
231  .stack :
232  {
233    . = ALIGN(8);
234    . += STACK_SIZE;
235  } > m_data
236
237  /* Initializes stack on the end of block */
238  __StackTop   = ORIGIN(m_data) + LENGTH(m_data);
239  __StackLimit = __StackTop - STACK_SIZE;
240  PROVIDE(__stack = __StackTop);
241
242  .ARM.attributes 0 : { *(.ARM.attributes) }
243
244  ASSERT(__StackLimit >= __HeapLimit, "region m_data overflowed with stack and heap")
245}
246
247