1/*
2** ###################################################################
3**     Processors:          MIMX8US5CVP08_cm33
4**                          MIMX8US5DVK08_cm33
5**                          MIMX8US5DVP08_cm33
6**
7**     Compiler:            GNU C Compiler
8**     Reference manual:    IMX8ULPRM, Rev. D, December. 2022
9**     Version:             rev. 5.0, 2023-04-27
10**     Build:               b230927
11**
12**     Abstract:
13**         Linker file for the GNU C Compiler
14**
15**     Copyright 2016 Freescale Semiconductor, Inc.
16**     Copyright 2016-2023 NXP
17**     SPDX-License-Identifier: BSD-3-Clause
18**
19**     http:                 www.nxp.com
20**     mail:                 support@nxp.com
21**
22** ###################################################################
23*/
24
25/* Entry Point */
26ENTRY(Reset_Handler)
27
28HEAP_SIZE  = DEFINED(__heap_size__)  ? __heap_size__  : 0x0400;
29STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0x0400;
30M_VECTOR_RAM_SIZE = DEFINED(__ram_vector_table__) ? 0x0320 : 0x0;
31
32/* Memory region from [0x0FFC0000-0x0FFC1FFF] is reserved for ROM header */
33/* Memory region from [0x20040000-0x2006FFFF] is reserved for A35 ATF */
34/* Memory region from [0x20070000-0x2007FFFF] is reserved for ROM API and ROM boot */
35/* Memory region(ssram) from [0x20030000-0x20037FFF](size is 32 KiB) is reserved for noncacheable data(such as: srcAddr, destAddr of dma3_scatter_gather demo, dma0 will access these non secure address) */
36
37/* Specify the memory areas */
38/*
39 * 1. Reduce m_data section's size from 0x38000 to 0x28000
40 * 2. Adjust sequences of sections
41 */
42MEMORY
43{
44  m_interrupts          (RX)  : ORIGIN = 0x0FFC2000, LENGTH = 0x00000320
45  m_text                (RX)  : ORIGIN = 0x0FFC2320, LENGTH = 0x0003DCE0
46  m_m33_suspend_ram     (RW)  : ORIGIN = 0x20000000, LENGTH = 0x00004000
47  m_a35_suspend_ram     (RW)  : ORIGIN = 0x20004000, LENGTH = 0x00004000
48  m_data                (RW)  : ORIGIN = 0x20008000, LENGTH = 0x00028000
49  m_ncache              (RW)  : ORIGIN = 0x20030000, LENGTH = 0x00008000
50}
51
52/* Define output sections */
53SECTIONS
54{
55  /* The startup code goes first into internal RAM */
56  .interrupts :
57  {
58    __VECTOR_TABLE = .;
59    __Vectors = .;
60    . = ALIGN(4);
61    KEEP(*(.isr_vector))     /* Startup code */
62    . = ALIGN(4);
63  } > m_interrupts
64
65  __stext = .; /* start address of text section */
66  .resource_table :
67  {
68    . = ALIGN(8);
69    KEEP(*(.resource_table)) /* Resource table */
70    . = ALIGN(8);
71  } > m_text
72
73  /* The program code and other data goes into internal RAM */
74  .text :
75  {
76    . = ALIGN(4);
77    *(.text)                 /* .text sections (code) */
78    *(.text*)                /* .text* sections (code) */
79    __quickcodeaccess_start__ = .;
80    . = ALIGN(32);
81    *(CodeQuickAccess)
82    . = ALIGN(32);
83    __quickcodeaccess_end__ = .;
84    *(.rodata)               /* .rodata sections (constants, strings, etc.) */
85    *(.rodata*)              /* .rodata* sections (constants, strings, etc.) */
86    *(.glue_7)               /* glue arm to thumb code */
87    *(.glue_7t)              /* glue thumb to arm code */
88    *(.eh_frame)
89    KEEP (*(.init))
90    KEEP (*(.fini))
91    . = ALIGN(4);
92  } > m_text
93
94  .ARM.extab :
95  {
96    *(.ARM.extab* .gnu.linkonce.armextab.*)
97  } > m_text
98
99  .ARM :
100  {
101    __exidx_start = .;
102    *(.ARM.exidx*)
103    __exidx_end = .;
104  } > m_text
105
106 .ctors :
107  {
108    __CTOR_LIST__ = .;
109    /* gcc uses crtbegin.o to find the start of
110       the constructors, so we make sure it is
111       first.  Because this is a wildcard, it
112       doesn't matter if the user does not
113       actually link against crtbegin.o; the
114       linker won't look for a file to match a
115       wildcard.  The wildcard also means that it
116       doesn't matter which directory crtbegin.o
117       is in.  */
118    KEEP (*crtbegin.o(.ctors))
119    KEEP (*crtbegin?.o(.ctors))
120    /* We don't want to include the .ctor section from
121       from the crtend.o file until after the sorted ctors.
122       The .ctor section from the crtend file contains the
123       end of ctors marker and it must be last */
124    KEEP (*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors))
125    KEEP (*(SORT(.ctors.*)))
126    KEEP (*(.ctors))
127    __CTOR_END__ = .;
128  } > m_text
129
130  .dtors :
131  {
132    __DTOR_LIST__ = .;
133    KEEP (*crtbegin.o(.dtors))
134    KEEP (*crtbegin?.o(.dtors))
135    KEEP (*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors))
136    KEEP (*(SORT(.dtors.*)))
137    KEEP (*(.dtors))
138    __DTOR_END__ = .;
139  } > m_text
140
141  .preinit_array :
142  {
143    PROVIDE_HIDDEN (__preinit_array_start = .);
144    KEEP (*(.preinit_array*))
145    PROVIDE_HIDDEN (__preinit_array_end = .);
146  } > m_text
147
148  .init_array :
149  {
150    PROVIDE_HIDDEN (__init_array_start = .);
151    KEEP (*(SORT(.init_array.*)))
152    KEEP (*(.init_array*))
153    PROVIDE_HIDDEN (__init_array_end = .);
154  } > m_text
155
156  .fini_array :
157  {
158    PROVIDE_HIDDEN (__fini_array_start = .);
159    KEEP (*(SORT(.fini_array.*)))
160    KEEP (*(.fini_array*))
161    PROVIDE_HIDDEN (__fini_array_end = .);
162  } > m_text
163
164  __etext = .;    /* define a global symbol at end of code */
165  __DATA_ROM = .; /* Symbol is used by startup for data initialization */
166
167  .interrupts_ram :
168  {
169    . = ALIGN(4);
170    __VECTOR_RAM__ = .;
171    __interrupts_ram_start__ = .; /* Create a global symbol at data start */
172    *(.m_interrupts_ram)     /* This is a user defined section */
173    . += M_VECTOR_RAM_SIZE;
174    . = ALIGN(4);
175    __interrupts_ram_end__ = .; /* Define a global symbol at data end */
176  } > m_data
177
178  __VECTOR_RAM = DEFINED(__ram_vector_table__) ? __VECTOR_RAM__ : ORIGIN(m_interrupts);
179  __RAM_VECTOR_TABLE_SIZE_BYTES = DEFINED(__ram_vector_table__) ? (__interrupts_ram_end__ - __interrupts_ram_start__) : 0x0;
180
181  .data : AT(__DATA_ROM)
182  {
183    . = ALIGN(4);
184    __DATA_RAM = .;
185    __data_start__ = .;      /* create a global symbol at data start */
186    __quickdataaccess_start__ = .;
187    . = ALIGN(32);
188    *(DataQuickAccess)
189    . = ALIGN(32);
190    __quickdataaccess_end__ = .;
191    *(.data)                 /* .data sections */
192    *(.data*)                /* .data* sections */
193    KEEP(*(.jcr*))
194    . = ALIGN(4);
195    __data_end__ = .;        /* define a global symbol at data end */
196  } > m_data
197
198  __NDATA_ROM = __DATA_ROM + SIZEOF(.data); /* Symbol is used by startup for ncache data initialization */
199  .ncache.init : AT(__NDATA_ROM)
200  {
201    __noncachedata_start__ = .;   /* create a global symbol at ncache data start */
202    *(NonCacheable.init)
203    . = ALIGN(4);
204    __noncachedata_init_end__ = .;   /* create a global symbol at initialized ncache data end */
205  } > m_ncache
206
207  . = __noncachedata_init_end__;
208  .ncache :
209  {
210    *(NonCacheable)
211    . = ALIGN(4);
212    __noncachedata_end__ = .;     /* define a global symbol at ncache data end */
213  } > m_ncache
214
215  __DATA_END = __NDATA_ROM + SIZEOF(.ncache.init);
216  text_end = ORIGIN(m_text) + LENGTH(m_text);
217  ASSERT(__DATA_END <= text_end, "region m_text overflowed with text and data")
218
219  /* Uninitialized data section */
220  .bss :
221  {
222    /* This is used by the startup in order to initialize the .bss section */
223    . = ALIGN(4);
224    __START_BSS = .;
225    __bss_start__ = .;
226    *(.bss)
227    *(.bss*)
228    *(COMMON)
229    . = ALIGN(4);
230    __bss_end__ = .;
231    __END_BSS = .;
232  } > m_data
233
234  .m33_suspend :
235  {
236    *(M33SuspendRam)
237    . = ALIGN(4);
238  } > m_m33_suspend_ram
239
240  .heap :
241  {
242    . = ALIGN(8);
243    __end__ = .;
244    PROVIDE(end = .);
245    __HeapBase = .;
246    . += HEAP_SIZE;
247    __HeapLimit = .;
248    __heap_limit = .; /* Add for _sbrk */
249  } > m_data
250
251  .stack :
252  {
253    . = ALIGN(8);
254    . += STACK_SIZE;
255  } > m_data
256
257  /* Initializes stack on the end of block */
258  __StackTop   = ORIGIN(m_data) + LENGTH(m_data);
259  __StackLimit = __StackTop - STACK_SIZE;
260  PROVIDE(__stack = __StackTop);
261
262  .ARM.attributes 0 : { *(.ARM.attributes) }
263
264  ASSERT(__StackLimit >= __HeapLimit, "region m_data overflowed with stack and heap")
265}
266
267