Skip to content

Commit 61a51dc

Browse files
committed
Added SRC
1 parent 5e7669c commit 61a51dc

File tree

3 files changed

+267
-0
lines changed

3 files changed

+267
-0
lines changed

src/Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#
2+
# Makefile for AEMB Software
3+
#
4+
# -Wl,-T -Wl,ld/linker.ld should be added to Lflags for implementation and omitted for simulation
5+
sim:
6+
riscv32-unknown-elf-objcopy -O srec rom.elf rom.srec
7+
srec_cat rom.srec -byte-swap 4 -fill 0xAE -within rom.srec -range-pad 4 -o dump.vmem -vmem 32
8+
9+
clean:
10+
rm *.dump *.srec *.elf

src/link.ld

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
OUTPUT_ARCH( "riscv" )
2+
ENTRY(_start)
3+
4+
SECTIONS
5+
{
6+
. = 0x80000000;
7+
.text.init : { *(.text.init) }
8+
. = ALIGN(0x1000);
9+
.tohost : { *(.tohost) }
10+
. = ALIGN(0x1000);
11+
.text : { *(.text) }
12+
. = ALIGN(0x1000);
13+
.data : { *(.data) }
14+
.data.string : { *(.data.string)}
15+
.bss : { *(.bss) }
16+
_end = .;
17+
}
18+

src/shawn.ld

Lines changed: 239 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,239 @@
1+
/* Default linker script, for normal executables */
2+
/* Copyright (C) 2014-2018 Free Software Foundation, Inc.
3+
Copying and distribution of this script, with or without modification,
4+
are permitted in any medium without royalty provided the copyright
5+
notice and this notice are preserved. */
6+
OUTPUT_FORMAT("elf32-littleriscv", "elf32-littleriscv",
7+
"elf32-littleriscv")
8+
OUTPUT_ARCH(riscv)
9+
ENTRY(_start)
10+
SEARCH_DIR("/home/sybreon/riscv/riscv32-unknown-elf/lib");
11+
SECTIONS
12+
{
13+
/* Read-only sections, merged into text segment: */
14+
PROVIDE (__executable_start = SEGMENT_START("text-segment", 0x0)); . = SEGMENT_START("text-segment", 0x0);
15+
.interp : { *(.interp) }
16+
.note.gnu.build-id : { *(.note.gnu.build-id) }
17+
.hash : { *(.hash) }
18+
.gnu.hash : { *(.gnu.hash) }
19+
.dynsym : { *(.dynsym) }
20+
.dynstr : { *(.dynstr) }
21+
.gnu.version : { *(.gnu.version) }
22+
.gnu.version_d : { *(.gnu.version_d) }
23+
.gnu.version_r : { *(.gnu.version_r) }
24+
.rela.init : { *(.rela.init) }
25+
.rela.text : { *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) }
26+
.rela.fini : { *(.rela.fini) }
27+
.rela.rodata : { *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) }
28+
.rela.data.rel.ro : { *(.rela.data.rel.ro .rela.data.rel.ro.* .rela.gnu.linkonce.d.rel.ro.*) }
29+
.rela.data : { *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) }
30+
.rela.tdata : { *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) }
31+
.rela.tbss : { *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) }
32+
.rela.ctors : { *(.rela.ctors) }
33+
.rela.dtors : { *(.rela.dtors) }
34+
.rela.got : { *(.rela.got) }
35+
.rela.sdata : { *(.rela.sdata .rela.sdata.* .rela.gnu.linkonce.s.*) }
36+
.rela.sbss : { *(.rela.sbss .rela.sbss.* .rela.gnu.linkonce.sb.*) }
37+
.rela.sdata2 : { *(.rela.sdata2 .rela.sdata2.* .rela.gnu.linkonce.s2.*) }
38+
.rela.sbss2 : { *(.rela.sbss2 .rela.sbss2.* .rela.gnu.linkonce.sb2.*) }
39+
.rela.bss : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) }
40+
.rela.iplt :
41+
{
42+
PROVIDE_HIDDEN (__rela_iplt_start = .);
43+
*(.rela.iplt)
44+
PROVIDE_HIDDEN (__rela_iplt_end = .);
45+
}
46+
.rela.plt :
47+
{
48+
*(.rela.plt)
49+
}
50+
.init :
51+
{
52+
KEEP (*(SORT_NONE(.init)))
53+
}
54+
.plt : { *(.plt) }
55+
.iplt : { *(.iplt) }
56+
.text :
57+
{
58+
*(.text.unlikely .text.*_unlikely .text.unlikely.*)
59+
*(.text.exit .text.exit.*)
60+
*(.text.startup .text.startup.*)
61+
*(.text.hot .text.hot.*)
62+
*(.text .stub .text.* .gnu.linkonce.t.*)
63+
/* .gnu.warning sections are handled specially by elf32.em. */
64+
*(.gnu.warning)
65+
}
66+
.fini :
67+
{
68+
KEEP (*(SORT_NONE(.fini)))
69+
}
70+
PROVIDE (__etext = .);
71+
PROVIDE (_etext = .);
72+
PROVIDE (etext = .);
73+
.rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
74+
.rodata1 : { *(.rodata1) }
75+
.sdata2 :
76+
{
77+
*(.sdata2 .sdata2.* .gnu.linkonce.s2.*)
78+
}
79+
.sbss2 : { *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*) }
80+
.eh_frame_hdr : { *(.eh_frame_hdr) *(.eh_frame_entry .eh_frame_entry.*) }
81+
.eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) *(.eh_frame.*) }
82+
.gcc_except_table : ONLY_IF_RO { *(.gcc_except_table
83+
.gcc_except_table.*) }
84+
.gnu_extab : ONLY_IF_RO { *(.gnu_extab*) }
85+
/* These sections are generated by the Sun/Oracle C++ compiler. */
86+
.exception_ranges : ONLY_IF_RO { *(.exception_ranges
87+
.exception_ranges*) }
88+
/* Adjust the address for the data segment. We want to adjust up to
89+
the same address within the page on the next page up. */
90+
. = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE));
91+
/* Exception handling */
92+
.eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) *(.eh_frame.*) }
93+
.gnu_extab : ONLY_IF_RW { *(.gnu_extab) }
94+
.gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }
95+
.exception_ranges : ONLY_IF_RW { *(.exception_ranges .exception_ranges*) }
96+
/* Thread Local Storage sections */
97+
.tdata :
98+
{
99+
PROVIDE_HIDDEN (__tdata_start = .);
100+
*(.tdata .tdata.* .gnu.linkonce.td.*)
101+
}
102+
.tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
103+
.preinit_array :
104+
{
105+
PROVIDE_HIDDEN (__preinit_array_start = .);
106+
KEEP (*(.preinit_array))
107+
PROVIDE_HIDDEN (__preinit_array_end = .);
108+
}
109+
.init_array :
110+
{
111+
PROVIDE_HIDDEN (__init_array_start = .);
112+
KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
113+
KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors))
114+
PROVIDE_HIDDEN (__init_array_end = .);
115+
}
116+
.fini_array :
117+
{
118+
PROVIDE_HIDDEN (__fini_array_start = .);
119+
KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))
120+
KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors))
121+
PROVIDE_HIDDEN (__fini_array_end = .);
122+
}
123+
.ctors :
124+
{
125+
/* gcc uses crtbegin.o to find the start of
126+
the constructors, so we make sure it is
127+
first. Because this is a wildcard, it
128+
doesn't matter if the user does not
129+
actually link against crtbegin.o; the
130+
linker won't look for a file to match a
131+
wildcard. The wildcard also means that it
132+
doesn't matter which directory crtbegin.o
133+
is in. */
134+
KEEP (*crtbegin.o(.ctors))
135+
KEEP (*crtbegin?.o(.ctors))
136+
/* We don't want to include the .ctor section from
137+
the crtend.o file until after the sorted ctors.
138+
The .ctor section from the crtend file contains the
139+
end of ctors marker and it must be last */
140+
KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
141+
KEEP (*(SORT(.ctors.*)))
142+
KEEP (*(.ctors))
143+
}
144+
.dtors :
145+
{
146+
KEEP (*crtbegin.o(.dtors))
147+
KEEP (*crtbegin?.o(.dtors))
148+
KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
149+
KEEP (*(SORT(.dtors.*)))
150+
KEEP (*(.dtors))
151+
}
152+
.jcr : { KEEP (*(.jcr)) }
153+
.data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) }
154+
.dynamic : { *(.dynamic) }
155+
. = DATA_SEGMENT_RELRO_END (0, .);
156+
.data :
157+
{
158+
*(.data .data.* .gnu.linkonce.d.*)
159+
SORT(CONSTRUCTORS)
160+
}
161+
.data1 : { *(.data1) }
162+
.got : { *(.got.plt) *(.igot.plt) *(.got) *(.igot) }
163+
/* We want the small data sections together, so single-instruction offsets
164+
can access them all, and initialized data all before uninitialized, so
165+
we can shorten the on-disk segment size. */
166+
.sdata :
167+
{
168+
__global_pointer$ = . + 0x800;
169+
*(.srodata.cst16) *(.srodata.cst8) *(.srodata.cst4) *(.srodata.cst2) *(.srodata .srodata.*)
170+
*(.sdata .sdata.* .gnu.linkonce.s.*)
171+
}
172+
_edata = .; PROVIDE (edata = .);
173+
. = .;
174+
__bss_start = .;
175+
.sbss :
176+
{
177+
*(.dynsbss)
178+
*(.sbss .sbss.* .gnu.linkonce.sb.*)
179+
*(.scommon)
180+
}
181+
.bss :
182+
{
183+
*(.dynbss)
184+
*(.bss .bss.* .gnu.linkonce.b.*)
185+
*(COMMON)
186+
/* Align here to ensure that the .bss section occupies space up to
187+
_end. Align after .bss to ensure correct alignment even if the
188+
.bss section disappears because there are no input sections.
189+
FIXME: Why do we need it? When there is no .bss section, we don't
190+
pad the .data section. */
191+
. = ALIGN(. != 0 ? 32 / 8 : 1);
192+
}
193+
. = ALIGN(32 / 8);
194+
. = SEGMENT_START("ldata-segment", .);
195+
. = ALIGN(32 / 8);
196+
_end = .; PROVIDE (end = .);
197+
. = DATA_SEGMENT_END (.);
198+
/* Stabs debugging sections. */
199+
.stab 0 : { *(.stab) }
200+
.stabstr 0 : { *(.stabstr) }
201+
.stab.excl 0 : { *(.stab.excl) }
202+
.stab.exclstr 0 : { *(.stab.exclstr) }
203+
.stab.index 0 : { *(.stab.index) }
204+
.stab.indexstr 0 : { *(.stab.indexstr) }
205+
.comment 0 : { *(.comment) }
206+
/* DWARF debug sections.
207+
Symbols in the DWARF debugging sections are relative to the beginning
208+
of the section so we begin them at 0. */
209+
/* DWARF 1 */
210+
.debug 0 : { *(.debug) }
211+
.line 0 : { *(.line) }
212+
/* GNU DWARF 1 extensions */
213+
.debug_srcinfo 0 : { *(.debug_srcinfo) }
214+
.debug_sfnames 0 : { *(.debug_sfnames) }
215+
/* DWARF 1.1 and DWARF 2 */
216+
.debug_aranges 0 : { *(.debug_aranges) }
217+
.debug_pubnames 0 : { *(.debug_pubnames) }
218+
/* DWARF 2 */
219+
.debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
220+
.debug_abbrev 0 : { *(.debug_abbrev) }
221+
.debug_line 0 : { *(.debug_line .debug_line.* .debug_line_end ) }
222+
.debug_frame 0 : { *(.debug_frame) }
223+
.debug_str 0 : { *(.debug_str) }
224+
.debug_loc 0 : { *(.debug_loc) }
225+
.debug_macinfo 0 : { *(.debug_macinfo) }
226+
/* SGI/MIPS DWARF 2 extensions */
227+
.debug_weaknames 0 : { *(.debug_weaknames) }
228+
.debug_funcnames 0 : { *(.debug_funcnames) }
229+
.debug_typenames 0 : { *(.debug_typenames) }
230+
.debug_varnames 0 : { *(.debug_varnames) }
231+
/* DWARF 3 */
232+
.debug_pubtypes 0 : { *(.debug_pubtypes) }
233+
.debug_ranges 0 : { *(.debug_ranges) }
234+
/* DWARF Extension. */
235+
.debug_macro 0 : { *(.debug_macro) }
236+
.debug_addr 0 : { *(.debug_addr) }
237+
.gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }
238+
/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }
239+
}

0 commit comments

Comments
 (0)