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