Skip to content

Commit

Permalink
Merge branch 'asm-linker' into exceptions-integration
Browse files Browse the repository at this point in the history
  • Loading branch information
piotro888 committed Nov 24, 2023
2 parents 45f534a + 4d7cecc commit b0dc052
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
26 changes: 26 additions & 0 deletions test/asm/link.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
OUTPUT_ARCH( "riscv" )

start = 0x0;

MEMORY
{
data (wxa!ri) : ORIGIN = 0x00000000, LENGTH = 1K
text (rxai!w) : ORIGIN = 0x10000000, LENGTH = 64K
}

PHDRS
{
text PT_LOAD;
data_init PT_LOAD;
data PT_NULL;
}

SECTIONS
{
.text.init : { *(.text.init) } >text AT>text :text
.text : { *(.text) } >text AT>text :text
. = ALIGN(0x1000);
.data : { *(.data) } >data AT>data :data_init
.bss : { *(.bss) } >data AT>data :data
_end = .;
}
20 changes: 18 additions & 2 deletions test/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,11 @@ def test_asm_source(self):
self.base_dir = "test/asm/"
self.bin_src = []

with tempfile.NamedTemporaryFile() as asm_tmp, tempfile.NamedTemporaryFile() as bin_tmp:
with (
tempfile.NamedTemporaryFile() as asm_tmp,
tempfile.NamedTemporaryFile() as ld_tmp,
tempfile.NamedTemporaryFile() as bin_tmp,
):
subprocess.check_call(
[
"riscv64-unknown-elf-as",
Expand All @@ -280,7 +284,19 @@ def test_asm_source(self):
]
)
subprocess.check_call(
["riscv64-unknown-elf-objcopy", "-O", "binary", "-j", ".text", asm_tmp.name, bin_tmp.name]
[
"riscv64-unknown-elf-ld",
"-m",
"elf32lriscv",
"-T",
self.base_dir + "link.ld",
asm_tmp.name,
"-o",
ld_tmp.name,
]
)
subprocess.check_call(
["riscv64-unknown-elf-objcopy", "-O", "binary", "-j", ".text", ld_tmp.name, bin_tmp.name]
)
code = bin_tmp.read()
for word_idx in range(0, len(code), 4):
Expand Down

0 comments on commit b0dc052

Please sign in to comment.