diff --git a/tests/elfs/callx_unaligned.rs b/tests/elfs/callx_unaligned.rs new file mode 100644 index 00000000..825d8f56 --- /dev/null +++ b/tests/elfs/callx_unaligned.rs @@ -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 + "); + } +} diff --git a/tests/elfs/callx_unaligned.so b/tests/elfs/callx_unaligned.so new file mode 100644 index 00000000..cec87a10 Binary files /dev/null and b/tests/elfs/callx_unaligned.so differ diff --git a/tests/elfs/elfs.sh b/tests/elfs/elfs.sh index 1c208cdc..419cc427 100755 --- a/tests/elfs/elfs.sh +++ b/tests/elfs/elfs.sh @@ -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" @@ -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 diff --git a/tests/execution.rs b/tests/execution.rs index 6d8f151f..20431324 100644 --- a/tests/execution.rs +++ b/tests/execution.rs @@ -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] {