diff --git a/src/elf.rs b/src/elf.rs index b306a3790..810d9e33f 100644 --- a/src/elf.rs +++ b/src/elf.rs @@ -1916,6 +1916,22 @@ mod test { ElfExecutable::load(&elf_bytes, loader()).expect("validation failed"); } + #[test] + #[should_panic(expected = "validation failed: UnresolvedSymbol(\"log\", 39, 312)")] + fn test_err_unresolved_syscall_reloc_64_32() { + let loader = BuiltinProgram::new_loader( + Config { + enabled_sbpf_versions: SBPFVersion::V1..=SBPFVersion::V1, + reject_broken_elfs: true, + ..Config::default() + }, + FunctionRegistry::default(), + ); + let elf_bytes = + std::fs::read("tests/elfs/syscall_reloc_64_32_sbpfv1.so").expect("failed to read elf file"); + ElfExecutable::load(&elf_bytes, Arc::new(loader)).expect("validation failed"); + } + #[test] fn test_long_section_name() { let elf_bytes = std::fs::read("tests/elfs/long_section_name.so").unwrap(); diff --git a/tests/execution.rs b/tests/execution.rs index 00259f110..3eea021aa 100644 --- a/tests/execution.rs +++ b/tests/execution.rs @@ -3035,25 +3035,6 @@ fn test_syscall_reloc_64_32() { ); } -#[test] -fn test_err_unresolved_syscall_reloc_64_32() { - let loader = BuiltinProgram::new_loader( - Config { - enabled_sbpf_versions: SBPFVersion::V1..=SBPFVersion::V1, - reject_broken_elfs: true, - ..Config::default() - }, - FunctionRegistry::default(), - ); - let mut file = File::open("tests/elfs/syscall_reloc_64_32_sbpfv1.so").unwrap(); - let mut elf = Vec::new(); - file.read_to_end(&mut elf).unwrap(); - assert_error!( - Executable::::from_elf(&elf, Arc::new(loader)), - "UnresolvedSymbol(\"log\", 39, 312)" - ); -} - #[test] fn test_reloc_64_64_sbpfv1() { // Tests the correctness of R_BPF_64_64 relocations. The program returns the