1/* Entry Point */
2OUTPUT_ARCH( "riscv" )
3
4STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0x1000;
5
6/* Specify the memory areas */
7MEMORY
8{
9  m_vector              (RX)  : ORIGIN = 0x000FFF00, LENGTH = 0x00000100
10  m_text                (RX)  : ORIGIN = 0x00000000, LENGTH = 0x000FFF00
11  m_data                (RW)  : ORIGIN = 0x20000000, LENGTH = 0x00030000 - 0x1800
12}
13
14/* Define output sections */
15SECTIONS
16{
17  .vectors : ALIGN(4)
18  {
19    __VECTOR_TABLE = .;
20    KEEP(*(.vectors))
21  } > m_vector
22
23  /* The program code and other data goes into internal flash */
24  .text :
25  {
26    . = ALIGN(4);
27    KEEP(*(.startup))
28    . = ALIGN(4);
29    __user_vector = .;
30    KEEP(*(user_vectors))
31    *(.text)                 /* .text sections (code) */
32    *(.text*)                /* .text* sections (code) */
33    *(.rodata)               /* .rodata sections (constants, strings, etc.) */
34    *(.rodata*)              /* .rodata* sections (constants, strings, etc.) */
35    *(.eh_frame)
36    *(.init)
37    *(.fini)
38
39    /* section information for finsh shell */
40    . = ALIGN(4);
41    __fsymtab_start = .;
42    KEEP(*(FSymTab))
43    __fsymtab_end = .;
44    . = ALIGN(4);
45    __vsymtab_start = .;
46    KEEP(*(VSymTab))
47    __vsymtab_end = .;
48    . = ALIGN(4);
49
50    /* section information for initial. */
51    . = ALIGN(4);
52    __rt_init_start = .;
53    KEEP(*(SORT(.rti_fn*)))
54    __rt_init_end = .;
55    . = ALIGN(4);
56  } > m_text
57
58  .preinit_array :
59  {
60    PROVIDE_HIDDEN (__preinit_array_start = .);
61    KEEP (*(.preinit_array*))
62    PROVIDE_HIDDEN (__preinit_array_end = .);
63  } > m_text
64
65  .init_array :
66  {
67    PROVIDE_HIDDEN (__init_array_start = .);
68    KEEP (*(SORT(.init_array.*)))
69    KEEP (*(.init_array*))
70    PROVIDE_HIDDEN (__init_array_end = .);
71  } > m_text
72
73  .fini_array :
74  {
75    PROVIDE_HIDDEN (__fini_array_start = .);
76    KEEP (*(SORT(.fini_array.*)))
77    KEEP (*(.fini_array*))
78    PROVIDE_HIDDEN (__fini_array_end = .);
79  } > m_text
80
81  __etext = .;    /* define a global symbol at end of code */
82  __global_pointer = .;    /* define a global symbol at end of code */
83  __DATA_ROM = .; /* Symbol is used by startup for data initialization */
84
85  .data : AT(__DATA_ROM)
86  {
87    . = ALIGN(4);
88    __DATA_RAM = .;
89    __data_start__ = .;      /* create a global symbol at data start */
90    *(.data)                 /* .data sections */
91    *(.data*)                /* .data* sections */
92    *(.sdata .sdata.*)
93    *(.heapsram*)            /* This is only for the pulpino official test code. */
94    __noncachedata_start__ = .;   /* create a global symbol at ncache data start */
95    *(NonCacheable)
96    __noncachedata_end__ = .;     /* define a global symbol at ncache data end */
97    KEEP(*(.jcr*))
98    . = ALIGN(4);
99    __data_end__ = .;        /* define a global symbol at data end */
100  } > m_data
101
102  __DATA_END = __DATA_ROM + (__data_end__ - __data_start__);
103  text_end = ORIGIN(m_text) + LENGTH(m_text);
104  ASSERT(__DATA_END <= text_end, "region m_text overflowed with text and data")
105
106  _edata = .;
107
108  .stack :
109  {
110    . = ALIGN(8);
111    __StackLimit = .;
112    . += STACK_SIZE;
113    __StackTop = .;
114  } > m_data
115
116  /* Initializes stack on the end of block */
117  PROVIDE(__stack = __StackTop);
118  PROVIDE( __rt_rvstack = .);
119
120  /* Uninitialized data section */
121  .bss :
122  {
123    /* This is used by the startup in order to initialize the .bss section */
124    . = ALIGN(4);
125    __START_BSS = .;
126    __bss_start__ = .;
127    *(.bss)
128    *(.bss*)
129    *(.sbss)
130    *(.sbss*)
131    *(COMMON)
132    . = ALIGN(4);
133    __bss_end__ = .;
134    __END_BSS = .;
135  } > m_data
136
137  /* End of uninitalized data segement */
138  _end = .;
139  PROVIDE(end = .);
140}
141