1/*
2 * Copyright (c) 2006-2023, RT-Thread Development Team
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 *
6 * Change Logs:
7 * Date           Author       Notes
8 * 2020/12/12     bernard      The first version
9 */
10
11INCLUDE "link_stacksize.lds"
12
13OUTPUT_ARCH( "riscv" )
14
15/*
16 * Memory layout:
17 * 0x10200000 - 0x10201000: Bootloader
18 * 0x10201000 - 0x10A00000: Kernel
19 * 0x10A00000 - 0x11200000: Heap
20 */
21
22MEMORY
23{
24   SRAM : ORIGIN = 0x45000000, LENGTH = 0x7FF000
25}
26
27ENTRY(_start)
28SECTIONS
29{
30    . = 0x45000000 ;
31
32    /* __STACKSIZE__ = 4096; */
33
34    .start :
35    {
36        *(.start);
37    } > SRAM
38
39    . = ALIGN(8);
40
41    .text :
42    {
43        *(.text)                        /* remaining code */
44        *(.text.*)                      /* remaining code */
45        *(.rodata)                      /* read-only data (constants) */
46        *(.rodata*)
47        *(.glue_7)
48        *(.glue_7t)
49        *(.gnu.linkonce.t*)
50
51        /* section information for finsh shell */
52        . = ALIGN(8);
53        __fsymtab_start = .;
54        KEEP(*(FSymTab))
55        __fsymtab_end = .;
56        . = ALIGN(8);
57        __vsymtab_start = .;
58        KEEP(*(VSymTab))
59        __vsymtab_end = .;
60        . = ALIGN(8);
61
62        /* section information for initial. */
63        . = ALIGN(8);
64        __rt_init_start = .;
65        KEEP(*(SORT(.rti_fn*)))
66        __rt_init_end = .;
67        . = ALIGN(8);
68
69        __rt_utest_tc_tab_start = .;
70        KEEP(*(UtestTcTab))
71        __rt_utest_tc_tab_end = .;
72
73        . = ALIGN(8);
74        _etext = .;
75    } > SRAM
76
77    .eh_frame_hdr :
78    {
79         *(.eh_frame_hdr)
80         *(.eh_frame_entry)
81    } > SRAM
82    .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) } > SRAM
83
84    . = ALIGN(8);
85
86    .data :
87    {
88        *(.data)
89        *(.data.*)
90
91        *(.data1)
92        *(.data1.*)
93
94        . = ALIGN(8);
95        PROVIDE( __global_pointer$ = . + 0x800 );
96
97        *(.sdata)
98        *(.sdata.*)
99    } > SRAM
100
101    . = ALIGN(8);
102    .ctors :
103    {
104        PROVIDE(__ctors_start__ = .);
105        KEEP(*(SORT(.init_array.*)))
106        KEEP(*(.init_array))
107        PROVIDE(__ctors_end__ = .);
108    } > SRAM
109
110    .dtors :
111    {
112        PROVIDE(__dtors_start__ = .);
113        KEEP(*(SORT(.fini_array.*)))
114        KEEP(*(.fini_array))
115        PROVIDE(__dtors_end__ = .);
116    } > SRAM
117
118    /* stack for dual core */
119    .stack :
120    {
121        . = ALIGN(64);
122        __stack_start__ = .;
123
124        . += __STACKSIZE__;
125        __stack_cpu0 = .;
126
127        . += __STACKSIZE__;
128        __stack_cpu1 = .;
129    } > SRAM
130
131    . = ALIGN(8);
132
133    .osdebug :
134    {
135        _osdebug_start = .;
136        . += 87K;
137        _osdebug_end = .;
138    } > SRAM
139
140    . = ALIGN(8);
141
142    .sbss :
143    {
144    __bss_start = .;
145        *(.sbss)
146        *(.sbss.*)
147        *(.dynsbss)
148        *(.scommon)
149    } > SRAM
150
151    .bss :
152    {
153        *(.bss)
154        *(.bss.*)
155        *(.dynbss)
156        *(COMMON)
157    __bss_end = .;
158    } > SRAM
159
160    _end = .;
161
162    /* Stabs debugging sections.  */
163    .stab          0 : { *(.stab) }
164    .stabstr       0 : { *(.stabstr) }
165    .stab.excl     0 : { *(.stab.excl) }
166    .stab.exclstr  0 : { *(.stab.exclstr) }
167    .stab.index    0 : { *(.stab.index) }
168    .stab.indexstr 0 : { *(.stab.indexstr) }
169    .comment       0 : { *(.comment) }
170    /* DWARF debug sections.
171     * Symbols in the DWARF debugging sections are relative to the beginning
172     * of the section so we begin them at 0.  */
173    /* DWARF 1 */
174    .debug          0 : { *(.debug) }
175    .line           0 : { *(.line) }
176    /* GNU DWARF 1 extensions */
177    .debug_srcinfo  0 : { *(.debug_srcinfo) }
178    .debug_sfnames  0 : { *(.debug_sfnames) }
179    /* DWARF 1.1 and DWARF 2 */
180    .debug_aranges  0 : { *(.debug_aranges) }
181    .debug_pubnames 0 : { *(.debug_pubnames) }
182    /* DWARF 2 */
183    .debug_info     0 : { *(.debug_info .gnu.linkonce.wi.*) }
184    .debug_abbrev   0 : { *(.debug_abbrev) }
185    .debug_line     0 : { *(.debug_line) }
186    .debug_frame    0 : { *(.debug_frame) }
187    .debug_str      0 : { *(.debug_str) }
188    .debug_loc      0 : { *(.debug_loc) }
189    .debug_macinfo  0 : { *(.debug_macinfo) }
190    /* SGI/MIPS DWARF 2 extensions */
191    .debug_weaknames 0 : { *(.debug_weaknames) }
192    .debug_funcnames 0 : { *(.debug_funcnames) }
193    .debug_typenames 0 : { *(.debug_typenames) }
194    .debug_varnames  0 : { *(.debug_varnames) }
195}
196