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 = 0x40400000, LENGTH = 60M
25}
26
27ENTRY(_start)
28SECTIONS
29{
30    . = 0x40400000 ;
31
32    /* __STACKSIZE__ = 4096; */
33    __text_start = .;
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    __text_end = .;
86    __text_size = __text_end - __text_start;
87
88    .data :
89    {
90        *(.data)
91        *(.data.*)
92
93        *(.data1)
94        *(.data1.*)
95
96        . = ALIGN(8);
97        PROVIDE( __global_pointer$ = . + 0x800 );
98
99        *(.sdata)
100        *(.sdata.*)
101    } > SRAM
102
103    . = ALIGN(8);
104    .ctors :
105    {
106        PROVIDE(__ctors_start__ = .);
107        KEEP(*(SORT(.init_array.*)))
108        KEEP(*(.init_array))
109        PROVIDE(__ctors_end__ = .);
110    } > SRAM
111
112    .dtors :
113    {
114        PROVIDE(__dtors_start__ = .);
115        KEEP(*(SORT(.fini_array.*)))
116        KEEP(*(.fini_array))
117        PROVIDE(__dtors_end__ = .);
118    } > SRAM
119
120    /* stack for dual core */
121    .stack :
122    {
123        . = ALIGN(64);
124        __stack_start__ = .;
125
126        . += __STACKSIZE__;
127        __stack_cpu0 = .;
128
129        . += __STACKSIZE__;
130        __stack_cpu1 = .;
131    } > SRAM
132
133    . = ALIGN(8);
134
135    .osdebug :
136    {
137        _osdebug_start = .;
138        . += 87K;
139        _osdebug_end = .;
140    } > SRAM
141
142    . = ALIGN(8);
143
144    .sbss :
145    {
146    __bss_start = .;
147        *(.sbss)
148        *(.sbss.*)
149        *(.dynsbss)
150        *(.scommon)
151    } > SRAM
152
153    .bss :
154    {
155        *(.bss)
156        *(.bss.*)
157        *(.dynbss)
158        *(COMMON)
159    __bss_end = .;
160    } > SRAM
161
162    _end = .;
163
164    /* Stabs debugging sections.  */
165    .stab          0 : { *(.stab) }
166    .stabstr       0 : { *(.stabstr) }
167    .stab.excl     0 : { *(.stab.excl) }
168    .stab.exclstr  0 : { *(.stab.exclstr) }
169    .stab.index    0 : { *(.stab.index) }
170    .stab.indexstr 0 : { *(.stab.indexstr) }
171    .comment       0 : { *(.comment) }
172    /* DWARF debug sections.
173     * Symbols in the DWARF debugging sections are relative to the beginning
174     * of the section so we begin them at 0.  */
175    /* DWARF 1 */
176    .debug          0 : { *(.debug) }
177    .line           0 : { *(.line) }
178    /* GNU DWARF 1 extensions */
179    .debug_srcinfo  0 : { *(.debug_srcinfo) }
180    .debug_sfnames  0 : { *(.debug_sfnames) }
181    /* DWARF 1.1 and DWARF 2 */
182    .debug_aranges  0 : { *(.debug_aranges) }
183    .debug_pubnames 0 : { *(.debug_pubnames) }
184    /* DWARF 2 */
185    .debug_info     0 : { *(.debug_info .gnu.linkonce.wi.*) }
186    .debug_abbrev   0 : { *(.debug_abbrev) }
187    .debug_line     0 : { *(.debug_line) }
188    .debug_frame    0 : { *(.debug_frame) }
189    .debug_str      0 : { *(.debug_str) }
190    .debug_loc      0 : { *(.debug_loc) }
191    .debug_macinfo  0 : { *(.debug_macinfo) }
192    /* SGI/MIPS DWARF 2 extensions */
193    .debug_weaknames 0 : { *(.debug_weaknames) }
194    .debug_funcnames 0 : { *(.debug_funcnames) }
195    .debug_typenames 0 : { *(.debug_typenames) }
196    .debug_varnames  0 : { *(.debug_varnames) }
197}
198