Skip to content

Commit ef78540

Browse files
committed
Only relocate test code to RAM if the test actually needs it
1 parent 629a069 commit ef78540

File tree

4 files changed

+52
-4
lines changed

4 files changed

+52
-4
lines changed

riscof/mlogv32/env/model_test.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
la t0, __sitext; \
2424
la t1, __stext; \
2525
la t2, __etext; \
26+
beqz t2, mlogv32_text_done; \
2627
mlogv32_load_text: \
2728
bgeu t1, t2, mlogv32_text_done; \
2829
lb t3, 0(t0); \
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ OUTPUT_ARCH( "riscv" )
22
ENTRY(rvtest_entry_point)
33

44
MEMORY {
5-
ROM (rx) : ORIGIN = 0x00000000, LENGTH = 0x480000
6-
RAM (rwx) : ORIGIN = 0x80000000, LENGTH = 0x480000
7-
MMIO (rw) : ORIGIN = 0xf0000000, LENGTH = 16
5+
ROM (rx) : ORIGIN = 0x00000000, LENGTH = 0x480000
6+
RAM (rwx) : ORIGIN = 0x80000000, LENGTH = 0x480000
87
}
98

109
SECTIONS

riscof/mlogv32/env/xip.ld

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
OUTPUT_ARCH( "riscv" )
2+
ENTRY(rvtest_entry_point)
3+
4+
MEMORY {
5+
ROM (rx) : ORIGIN = 0x00000000, LENGTH = 0x480000
6+
RAM (rwx) : ORIGIN = 0x80000000, LENGTH = 0x480000
7+
}
8+
9+
__stext = 0;
10+
__etext = 0;
11+
__sitext = 0;
12+
13+
SECTIONS
14+
{
15+
.text : ALIGN(4) {
16+
KEEP(*(.text.init.rom));
17+
*(.text.init);
18+
*(.text);
19+
. = ALIGN(4);
20+
__etext_rom = .;
21+
} > ROM
22+
23+
.data : ALIGN(4) {
24+
__sdata = .;
25+
*(.data);
26+
*(.data.string);
27+
. = ALIGN(4);
28+
__edata = .;
29+
} > RAM AT > ROM
30+
31+
__sidata = LOADADDR(.data);
32+
33+
.bss (NOLOAD) : ALIGN(4) {
34+
__sbss = .;
35+
*(.bss);
36+
. = ALIGN(4);
37+
__ebss = .;
38+
} > RAM
39+
40+
_end = .;
41+
}

riscof/mlogv32/riscof_mlogv32.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def initialise(self, suite: str, workdir: str, env: str):
6767
-static -mcmodel=medany -fvisibility=hidden -nostdlib -nostartfiles -g\
6868
-T "
6969
+ self.pluginpath
70-
+ "/env/link.ld\
70+
+ "/env/{linker_script}\
7171
-I "
7272
+ self.pluginpath
7373
+ "/env/\
@@ -160,6 +160,12 @@ def runTests(self, testlist: dict[str, Any]):
160160
# prefix with "-D". The following does precisely that.
161161
compile_macros = " -D" + " -D".join(testentry["macros"])
162162

163+
# use a different linker script for tests that require .text to be writable
164+
if testname.endswith("/Zifencei/src/Fencei.S"):
165+
linker_script = "reloc.ld"
166+
else:
167+
linker_script = "xip.ld"
168+
163169
# substitute all variables in the compile command that we created in the initialize
164170
# function
165171
compile_cmd = self.compile_cmd.format(
@@ -168,6 +174,7 @@ def runTests(self, testlist: dict[str, Any]):
168174
test=test,
169175
elf=elf,
170176
macros=compile_macros,
177+
linker_script=linker_script,
171178
)
172179

173180
objcopy_cmd = self.objcopy_cmd.format(

0 commit comments

Comments
 (0)