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