Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add BPF-to-BPF and PC relative call tests #2395

Merged
merged 3 commits into from
Jan 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
345 changes: 202 additions & 143 deletions Cargo.lock

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions programs/bpf/c/src/relative_call/relative_call.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* @brief test program that generates BPF PC relative call instructions
*/

#include <solana_sdk.h>

void __attribute__ ((noinline)) helper() {
sol_log(__func__);
}

extern bool entrypoint(const uint8_t *input) {
sol_log(__func__);
helper();
return true;
}

11 changes: 0 additions & 11 deletions programs/bpf/c/test/bench_alu.c

This file was deleted.

2 changes: 1 addition & 1 deletion programs/native/bpf_loader/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ byteorder = "1.2.1"
elf = "0.0.10"
libc = "0.2.46"
log = "0.4.2"
solana_rbpf = "=0.1.6"
solana_rbpf = "=0.1.8"
serde = "1.0.84"
solana-logger = { path = "../../../logger", version = "0.12.0" }
solana-sdk = { path = "../../../sdk", version = "0.12.0" }
Expand Down
12 changes: 5 additions & 7 deletions programs/native/bpf_loader/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pub mod bpf_verifier;
use byteorder::{ByteOrder, LittleEndian, WriteBytesExt};
use libc::c_char;
use log::*;
use solana_rbpf::EbpfVmRaw;
use solana_rbpf::{EbpfVmRaw, RegionPtrs};
use solana_sdk::account::KeyedAccount;
use solana_sdk::loader_instruction::LoaderInstruction;
use solana_sdk::native_program::ProgramError;
Expand Down Expand Up @@ -36,15 +36,13 @@ pub fn helper_sol_log_verify(
unused3: u64,
unused4: u64,
unused5: u64,
ro_regions: &[&[u8]],
unused7: &[&[u8]],
ro_regions: &[RegionPtrs],
unused7: &[RegionPtrs],
) -> Result<(()), Error> {
for region in ro_regions.iter() {
if region.as_ptr() as u64 <= addr
&& addr as u64 <= region.as_ptr() as u64 + region.len() as u64
{
if region.bot <= addr && addr as u64 <= region.top {
let c_buf: *const c_char = addr as *const c_char;
let max_size = (region.as_ptr() as u64 + region.len() as u64) - addr;
let max_size = region.top - addr;
unsafe {
for i in 0..max_size {
if std::ptr::read(c_buf.offset(i as isize)) == 0 {
Expand Down
2 changes: 2 additions & 0 deletions tests/programs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,11 @@ fn test_program_bpf_c() {
solana_logger::setup();

let programs = [
"bpf_to_bpf",
"multiple_static",
"noop",
"noop++",
"relative_call",
"struct_pass",
"struct_ret",
];
Expand Down