1/*
2 * @copyright (C) 2020 Nuvoton Technology Corp. All rights reserved.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 *
6 * Change Logs:
7 * Date           Author       Notes
8 * 2020-09-2      Philo        First version
9 */
10
11/* Program Entry, set to mark it as "used" and avoid gc */
12MEMORY
13{
14    CODE (rx) : ORIGIN = 0x00000000, LENGTH = 512K   /* 512K flash */
15    DATA (rw) : ORIGIN = 0x20000000, LENGTH = 96K    /* 96K sram */
16}
17ENTRY(Reset_Handler)
18_system_stack_size = 0x2000;
19
20SECTIONS
21{
22    .vector :
23    {
24        . = ALIGN(4);
25        _stext = .;
26        KEEP(*(.isr_vector))            /* Startup code */
27    } > CODE = 0
28
29    .text :
30    {
31        . = ALIGN(4);
32        *(.text)                        /* remaining code */
33        *(.text.*)                      /* remaining code */
34        *(.rodata)                      /* read-only data (constants) */
35        *(.rodata*)
36        *(.glue_7)
37        *(.glue_7t)
38        *(.gnu.linkonce.t*)
39
40        /* section information for finsh shell */
41        . = ALIGN(4);
42        __fsymtab_start = .;
43        KEEP(*(FSymTab))
44        __fsymtab_end = .;
45        . = ALIGN(4);
46        __vsymtab_start = .;
47        KEEP(*(VSymTab))
48        __vsymtab_end = .;
49        . = ALIGN(4);
50
51        /* section information for initial. */
52        . = ALIGN(4);
53        __rt_init_start = .;
54        KEEP(*(SORT(.rti_fn*)))
55        __rt_init_end = .;
56        . = ALIGN(4);
57
58        /* section information for utest */
59        . = ALIGN(4);
60        __rt_utest_tc_tab_start = .;
61        KEEP(*(UtestTcTab))
62        __rt_utest_tc_tab_end = .;
63
64        . = ALIGN(4);
65        _etext = .;
66    } > CODE = 0
67
68    /* .ARM.exidx is sorted, so has to go in its own output section.  */
69    __exidx_start = .;
70    .ARM.exidx :
71    {
72        *(.ARM.exidx* .gnu.linkonce.armexidx.*)
73
74        /* This is used by the startup in order to initialize the .data section */
75        _sidata = .;
76    } > CODE
77    __exidx_end = .;
78
79    .stack :
80    {
81        _sstack = .;
82        . = . + _system_stack_size;
83        . = ALIGN(4);
84        _estack = .;
85    } >DATA
86
87    /* .data section which is used for initialized data */
88    .data : AT (_sidata)
89    {
90        . = ALIGN(4);
91        /* This is used by the startup in order to initialize the .data section */
92        _sdata = . ;
93
94        *(.data)
95        *(.data.*)
96        *(.gnu.linkonce.d*)
97
98        . = ALIGN(4);
99        /* This is used by the startup in order to initialize the .data section */
100        _edata = . ;
101    } >DATA
102
103    __bss_start = .;
104    .bss :
105    {
106        . = ALIGN(4);
107        /* This is used by the startup in order to initialize the .bss section */
108        _sbss = .;
109
110        *(.bss)
111        *(.bss.*)
112        *(COMMON)
113
114        . = ALIGN(4);
115        /* This is used by the startup in order to initialize the .bss section */
116        _ebss = . ;
117
118        *(.bss.init)
119    } > DATA
120    __bss_end = .;
121
122    _end = .;
123
124    __ram_top = ORIGIN(DATA) + LENGTH(DATA);
125
126    /* Stabs debugging sections.  */
127    .stab          0 : { *(.stab) }
128    .stabstr       0 : { *(.stabstr) }
129    .stab.excl     0 : { *(.stab.excl) }
130    .stab.exclstr  0 : { *(.stab.exclstr) }
131    .stab.index    0 : { *(.stab.index) }
132    .stab.indexstr 0 : { *(.stab.indexstr) }
133    .comment       0 : { *(.comment) }
134    /* DWARF debug sections.
135     * Symbols in the DWARF debugging sections are relative to the beginning
136     * of the section so we begin them at 0.  */
137    /* DWARF 1 */
138    .debug          0 : { *(.debug) }
139    .line           0 : { *(.line) }
140    /* GNU DWARF 1 extensions */
141    .debug_srcinfo  0 : { *(.debug_srcinfo) }
142    .debug_sfnames  0 : { *(.debug_sfnames) }
143    /* DWARF 1.1 and DWARF 2 */
144    .debug_aranges  0 : { *(.debug_aranges) }
145    .debug_pubnames 0 : { *(.debug_pubnames) }
146    /* DWARF 2 */
147    .debug_info     0 : { *(.debug_info .gnu.linkonce.wi.*) }
148    .debug_abbrev   0 : { *(.debug_abbrev) }
149    .debug_line     0 : { *(.debug_line) }
150    .debug_frame    0 : { *(.debug_frame) }
151    .debug_str      0 : { *(.debug_str) }
152    .debug_loc      0 : { *(.debug_loc) }
153    .debug_macinfo  0 : { *(.debug_macinfo) }
154    /* SGI/MIPS DWARF 2 extensions */
155    .debug_weaknames 0 : { *(.debug_weaknames) }
156    .debug_funcnames 0 : { *(.debug_funcnames) }
157    .debug_typenames 0 : { *(.debug_typenames) }
158    .debug_varnames  0 : { *(.debug_varnames) }
159}
160