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