forked from paritytech/polkavm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
polkavm-linker: Fix R_RISCV_ADD* && R_RISCV_SUB* relocation
We do not calculate the final offset correctly, because range value is reversed. Also add a test to verify relocation is working properly. Signed-off-by: Aman <[email protected]>
- Loading branch information
Showing
6 changed files
with
120 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
cd "${0%/*}/" | ||
|
||
function build_asm_tests_64bit() { | ||
output_path="output/$1.elf" | ||
echo "> Building: '$1' (-> $output_path)" | ||
riscv64-linux-gnu-as -fPIC -march "rv64ima_zifencei_zbb" -mabi="lp64" $1.S -o $output_path | ||
zstd -f -q -19 -o $output_path.zst $output_path | ||
chmod -x $output_path* | ||
} | ||
|
||
build_asm_tests_64bit "reloc_add_sub_64" | ||
|
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
.global get_string | ||
|
||
get_string: | ||
slli a0, a0, 2 | ||
la a1, magic_table | ||
mv a2, a1 | ||
add a1, a1, a0 | ||
lw a0, 0(a1) | ||
add a0, a0, a2 | ||
ret | ||
|
||
.pushsection .metadata,"",@progbits | ||
_entry_point_name: | ||
.asciz "get_string" | ||
|
||
_metadata: | ||
.byte 1 | ||
.word 0 | ||
.word 10 | ||
.quad _entry_point_name | ||
.byte 1 | ||
.byte 1 | ||
.popsection | ||
|
||
.pushsection .polkavm_exports,"R",@note | ||
.byte 1 | ||
.quad _metadata | ||
.quad get_string | ||
.popsection | ||
|
||
.pushsection .rodata.secrets | ||
magic0: .word 0x01010101 | ||
magic1: .word 0x02020202 | ||
magic2: .word 0x03030303 | ||
.popsection | ||
|
||
.pushsection .rodata.table | ||
magic_table: | ||
.word magic0 - magic_table | ||
.word magic1 - magic_table | ||
.word magic2 - magic_table | ||
.popsection | ||
|