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