1/*
2** ###################################################################
3**     Processor:           LPC54S018J2MET180
4**     Compiler:            GNU C Compiler
5**     Reference manual:    LPC54018JxM/LPC54S018JxM User manual Rev.1.0 20 September 2018
6**     Version:             rev. 1.2, 2017-06-08
7**     Build:               b200611
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
25
26/* Entry Point */
27ENTRY(Reset_Handler)
28
29HEAP_SIZE  = DEFINED(__heap_size__)  ? __heap_size__  : 0x0400;
30STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0x0800;
31
32IMAGE_START_ADDR  = DEFINED(XIP_IMAGE)  ? 0x10000000  : 0x00000000;
33DATA_START_ADDR   = DEFINED(XIP_IMAGE)  ? 0x00000004  : 0x20000000;
34TEXT_SECTION_SIZE = DEFINED(XIP_IMAGE)  ? 0x001FFE00  : 0x0002FE00;
35DATA_SECTION_SIZE = DEFINED(XIP_IMAGE)  ? 0x0002FFFC  : 0x00028000;
36
37/* Specify the memory areas */
38MEMORY
39{
40  m_interrupts          (RX)  : ORIGIN = IMAGE_START_ADDR, LENGTH = 0x00000200
41  m_text                (RX)  : ORIGIN = IMAGE_START_ADDR + 0x00000200, LENGTH = TEXT_SECTION_SIZE
42  m_data                (RW)  : ORIGIN = DATA_START_ADDR, LENGTH = DATA_SECTION_SIZE
43  m_usb_sram            (RW)  : ORIGIN = 0x40100000, LENGTH = 0x00002000
44}
45
46/* Define output sections */
47SECTIONS
48{
49  /* The startup code goes first into internal flash */
50  .interrupts :
51  {
52    __vector_start = .;
53    . = ALIGN(4);
54    KEEP(*(.isr_vector))     /* Startup code */
55    . = ALIGN(4);
56  } > m_interrupts
57
58  /* The program code and other data goes into internal flash */
59  .text :
60  {
61    . = ALIGN(4);
62    *(.text)                 /* .text sections (code) */
63    *(.text*)                /* .text* sections (code) */
64    *(.rodata)               /* .rodata sections (constants, strings, etc.) */
65    *(.rodata*)              /* .rodata* sections (constants, strings, etc.) */
66    *(.glue_7)               /* glue arm to thumb code */
67    *(.glue_7t)              /* glue thumb to arm code */
68    *(.eh_frame)
69    KEEP (*(.init))
70    KEEP (*(.fini))
71    . = ALIGN(4);
72  } > m_text
73
74  .ARM.extab :
75  {
76    *(.ARM.extab* .gnu.linkonce.armextab.*)
77  } > m_text
78
79  .ARM :
80  {
81    __exidx_start = .;
82    *(.ARM.exidx*)
83    __exidx_end = .;
84  } > m_text
85
86 .ctors :
87  {
88    __CTOR_LIST__ = .;
89    /* gcc uses crtbegin.o to find the start of
90       the constructors, so we make sure it is
91       first.  Because this is a wildcard, it
92       doesn't matter if the user does not
93       actually link against crtbegin.o; the
94       linker won't look for a file to match a
95       wildcard.  The wildcard also means that it
96       doesn't matter which directory crtbegin.o
97       is in.  */
98    KEEP (*crtbegin.o(.ctors))
99    KEEP (*crtbegin?.o(.ctors))
100    /* We don't want to include the .ctor section from
101       from the crtend.o file until after the sorted ctors.
102       The .ctor section from the crtend file contains the
103       end of ctors marker and it must be last */
104    KEEP (*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors))
105    KEEP (*(SORT(.ctors.*)))
106    KEEP (*(.ctors))
107    __CTOR_END__ = .;
108  } > m_text
109
110  .dtors :
111  {
112    __DTOR_LIST__ = .;
113    KEEP (*crtbegin.o(.dtors))
114    KEEP (*crtbegin?.o(.dtors))
115    KEEP (*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors))
116    KEEP (*(SORT(.dtors.*)))
117    KEEP (*(.dtors))
118    __DTOR_END__ = .;
119  } > m_text
120
121  .preinit_array :
122  {
123    PROVIDE_HIDDEN (__preinit_array_start = .);
124    KEEP (*(.preinit_array*))
125    PROVIDE_HIDDEN (__preinit_array_end = .);
126  } > m_text
127
128  .init_array :
129  {
130    PROVIDE_HIDDEN (__init_array_start = .);
131    KEEP (*(SORT(.init_array.*)))
132    KEEP (*(.init_array*))
133    PROVIDE_HIDDEN (__init_array_end = .);
134  } > m_text
135
136  .fini_array :
137  {
138    PROVIDE_HIDDEN (__fini_array_start = .);
139    KEEP (*(SORT(.fini_array.*)))
140    KEEP (*(.fini_array*))
141    PROVIDE_HIDDEN (__fini_array_end = .);
142  } > m_text
143
144  __etext = .;    /* define a global symbol at end of code */
145  __DATA_ROM = .; /* Symbol is used by startup for data initialization */
146
147  .data : ALIGN(4)
148  {
149    . = ALIGN(4);
150    __DATA_RAM = .;
151    __data_start__ = .;      /* create a global symbol at data start */
152    *(.ramfunc*)             /* for functions in ram */
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 AT>m_text
159
160  __DATA_END = __DATA_ROM + (__data_end__ - __data_start__);
161  __IMAGE_START = LOADADDR(.interrupts);
162  __IMAGE_END = LOADADDR(.data) + SIZEOF(.data);
163  __IMAGE_SIZE = __IMAGE_END - __IMAGE_START;
164
165  text_end = ORIGIN(m_text) + LENGTH(m_text);
166  ASSERT(__DATA_END <= text_end, "region m_text overflowed with text and data")
167
168  /* Uninitialized data section */
169  .bss :
170  {
171    /* This is used by the startup in order to initialize the .bss section */
172    . = ALIGN(4);
173    __START_BSS = .;
174    __bss_start__ = .;
175    *(.bss)
176    *(.bss*)
177    *(COMMON)
178    . = ALIGN(4);
179    __bss_end__ = .;
180    __END_BSS = .;
181  } > m_data
182
183  .heap :
184  {
185    . = ALIGN(8);
186    __end__ = .;
187    PROVIDE(end = .);
188    __HeapBase = .;
189    . += HEAP_SIZE;
190    __HeapLimit = .;
191    __heap_limit = .; /* Add for _sbrk */
192  } > m_data
193
194  .stack :
195  {
196    . = ALIGN(8);
197    . += STACK_SIZE;
198  } > m_data
199
200  m_usb_bdt (NOLOAD) :
201  {
202    . = ALIGN(512);
203    *(m_usb_bdt)
204  } > m_usb_sram
205
206  m_usb_global (NOLOAD) :
207  {
208    *(m_usb_global)
209  } > m_usb_sram
210
211  /* Initializes stack on the end of block */
212  __StackTop   = ORIGIN(m_data) + LENGTH(m_data);
213  __StackLimit = __StackTop - STACK_SIZE;
214  PROVIDE(__stack = __StackTop);
215
216  .ARM.attributes 0 : { *(.ARM.attributes) }
217
218  ASSERT(__StackLimit >= __HeapLimit, "region m_data overflowed with stack and heap")
219}
220
221