1OUTPUT_ARCH( "riscv" )
2
3ENTRY( _start )
4
5MEMORY
6{
7    /* Run in FLASH */
8    flash (rxai!w) : ORIGIN = 0x08000000, LENGTH = 128k
9    ram   (wxa!ri) : ORIGIN = 0x20000000, LENGTH = 32K
10
11    /* Run in RAM */
12/* flash (rxai!w) : ORIGIN = 0x20000000, LENGTH = 24k
13    ram   (wxa!ri) : ORIGIN = 0x20006000, LENGTH = 8K
14*/
15}
16
17
18SECTIONS
19{
20  __stack_size = DEFINED(__stack_size) ? __stack_size : 4K;
21
22
23  .init           :
24  {
25    KEEP (*(SORT_NONE(.init)))
26  } >flash AT>flash
27
28  .ilalign         :
29  {
30    . = ALIGN(4);
31    PROVIDE( _ilm_lma = . );
32  } >flash AT>flash
33
34  .ialign         :
35  {
36    PROVIDE( _ilm = . );
37  } >flash AT>flash
38
39  .text           :
40  {
41    *(.rodata .rodata.*)
42    *(.text.unlikely .text.unlikely.*)
43    *(.text.startup .text.startup.*)
44    *(.text .text.*)
45    *(.gnu.linkonce.t.*)
46
47    /* section information for finsh shell */
48    . = ALIGN(4);
49    __fsymtab_start = .;
50    KEEP(*(FSymTab))
51    __fsymtab_end = .;
52    . = ALIGN(4);
53    __vsymtab_start = .;
54    KEEP(*(VSymTab))
55    __vsymtab_end = .;
56    . = ALIGN(4);
57
58    /* section information for initial. */
59    . = ALIGN(4);
60    __rt_init_start = .;
61    KEEP(*(SORT(.rti_fn*)))
62    __rt_init_end = .;
63    . = ALIGN(4);
64
65    /* section information for modules */
66    . = ALIGN(4);
67    __rtmsymtab_start = .;
68    KEEP(*(RTMSymTab))
69    __rtmsymtab_end = .;
70  } >flash AT>flash
71
72  .fini           :
73  {
74    KEEP (*(SORT_NONE(.fini)))
75  } >flash AT>flash
76
77  . = ALIGN(4);
78
79  PROVIDE (__etext = .);
80  PROVIDE (_etext = .);/*0x80022c8*/
81  PROVIDE (etext = .);/*0x80022c8*/
82  PROVIDE( _eilm = . );
83
84  .preinit_array  :
85  {
86    PROVIDE_HIDDEN (__preinit_array_start = .);
87    KEEP (*(.preinit_array))
88    PROVIDE_HIDDEN (__preinit_array_end = .);
89  } >flash AT>flash
90
91  .init_array     :
92  {
93    PROVIDE_HIDDEN (__init_array_start = .);
94    KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
95    KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors))
96    PROVIDE_HIDDEN (__init_array_end = .);
97  } >flash AT>flash
98
99  .fini_array     :
100  {
101    PROVIDE_HIDDEN (__fini_array_start = .);
102    KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))
103    KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors))
104    PROVIDE_HIDDEN (__fini_array_end = .);
105  } >flash AT>flash
106
107  .ctors          :
108  {
109    /* gcc uses crtbegin.o to find the start of
110       the constructors, so we make sure it is
111       first.  Because this is a wildcard, it
112       doesn't matter if the user does not
113       actually link against crtbegin.o; the
114       linker won't look for a file to match a
115       wildcard.  The wildcard also means that it
116       doesn't matter which directory crtbegin.o
117       is in.  */
118    KEEP (*crtbegin.o(.ctors))
119    KEEP (*crtbegin?.o(.ctors))
120    /* We don't want to include the .ctor section from
121       the crtend.o file until after the sorted ctors.
122       The .ctor section from the crtend file contains the
123       end of ctors marker and it must be last */
124    KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
125    KEEP (*(SORT(.ctors.*)))
126    KEEP (*(.ctors))
127  } >flash AT>flash
128
129  .dtors          :
130  {
131    KEEP (*crtbegin.o(.dtors))
132    KEEP (*crtbegin?.o(.dtors))
133    KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
134    KEEP (*(SORT(.dtors.*)))
135    KEEP (*(.dtors))
136  } >flash AT>flash
137
138    . = ALIGN(4);
139    PROVIDE( _eilm = . );
140
141  .lalign         :
142  {
143    . = ALIGN(4);
144    PROVIDE( _data_lma = . );
145  } >flash AT>flash
146
147  .dalign         :
148  {
149    . = ALIGN(4);
150    PROVIDE( _data = . );
151  } >ram AT>flash
152
153
154  .data          :
155  {
156    *(.rdata)
157
158    *(.gnu.linkonce.r.*)
159    *(.data .data.*)
160    *(.gnu.linkonce.d.*)
161    . = ALIGN(8);
162    PROVIDE( __global_pointer$ = . + 0x800);
163    *(.sdata .sdata.*)
164    *(.gnu.linkonce.s.*)
165    . = ALIGN(8);
166    *(.srodata.cst16)
167    *(.srodata.cst8)
168    *(.srodata.cst4)
169    *(.srodata.cst2)
170    *(.srodata .srodata.*)
171  } >ram AT>flash
172
173  . = ALIGN(4);
174  PROVIDE( _edata = . );
175  PROVIDE( edata = . );
176
177  PROVIDE( _fbss = . ); /*0X200052A0  0X200002A0*/
178  PROVIDE( __bss_start = . );
179  .bss            :
180  {
181    *(.sbss*)
182    *(.gnu.linkonce.sb.*)
183    *(.bss .bss.*)
184    *(.gnu.linkonce.b.*)
185    *(COMMON)
186    . = ALIGN(4);
187  } >ram AT>ram
188
189  . = ALIGN(8);
190  PROVIDE( _end = . ); /*0X2000,0340*/
191  PROVIDE( end = . );
192
193  .stack ORIGIN(ram) + LENGTH(ram) - __stack_size :
194  {
195    PROVIDE( _heap_end = . );
196    . = __stack_size;
197    PROVIDE( _sp = . );
198    PROVIDE( __rt_rvstack = .);
199  } >ram AT>ram
200}
201