Skip to content

Commit

Permalink
adds test
Browse files Browse the repository at this point in the history
  • Loading branch information
Lichtso committed Aug 16, 2024
1 parent c72113b commit f37df20
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
12 changes: 12 additions & 0 deletions tests/elfs/callx_unaligned.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#![feature(asm_experimental_arch)]

#[no_mangle]
pub fn entrypoint() {
unsafe {
std::arch::asm!("
rsh64 r1, 2
or64 r1, 0x129
callx r1
");
}
}
Binary file added tests/elfs/callx_unaligned.so
Binary file not shown.
5 changes: 4 additions & 1 deletion tests/elfs/elfs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Requires Latest release of Solana's custom LLVM
# https://github.com/solana-labs/platform-tools/releases

TOOLCHAIN=../../../solana/sdk/sbf/dependencies/sbf-tools
TOOLCHAIN=../../../agave/sdk/sbf/dependencies/platform-tools
RC_COMMON="$TOOLCHAIN/rust/bin/rustc --target sbf-solana-solana --crate-type lib -C panic=abort -C opt-level=2"
RC="$RC_COMMON -C target_cpu=sbfv2"
RC_V1="$RC_COMMON -C target_cpu=generic"
Expand Down Expand Up @@ -56,4 +56,7 @@ $LD_V1 -o reloc_64_relative_sbpfv1.so reloc_64_relative.o
# $RC_V1 -o reloc_64_relative_data.o reloc_64_relative_data.rs
# $LD_V1 -o reloc_64_relative_data_sbpfv1.so reloc_64_relative_data.o

# $RC_V1 -o callx_unaligned.o callx_unaligned.rs
# $LD_V1 -o callx_unaligned.so callx_unaligned.o

rm *.o
11 changes: 11 additions & 0 deletions tests/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2320,6 +2320,17 @@ fn test_err_callx_oob_high() {
);
}

#[test]
fn test_callx_unaligned_text_section() {
test_interpreter_and_jit_elf!(
"tests/elfs/callx_unaligned.so",
[],
(),
TestContextObject::new(129),
ProgramResult::Err(EbpfError::CallDepthExceeded),
);
}

#[test]
fn test_bpf_to_bpf_depth() {
for max_call_depth in [20usize, Config::default().max_call_depth] {
Expand Down

0 comments on commit f37df20

Please sign in to comment.