Skip to content

Commit

Permalink
Gate pointer alignment enforcement (#12176)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackcmay authored Sep 11, 2020
1 parent de4a613 commit ae7b15f
Show file tree
Hide file tree
Showing 4 changed files with 228 additions and 101 deletions.
6 changes: 3 additions & 3 deletions programs/bpf/benches/bpf_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use solana_runtime::{
loader_utils::load_program,
};
use solana_sdk::{
account::{create_keyed_readonly_accounts, Account, KeyedAccount},
account::{create_keyed_readonly_accounts, Account},
bpf_loader, bpf_loader_deprecated,
client::SyncClient,
entrypoint::SUCCESS,
Expand Down Expand Up @@ -92,12 +92,12 @@ fn bench_program_alu(bencher: &mut Bencher) {
.write_u64::<LittleEndian>(ARMSTRONG_LIMIT)
.unwrap();
inner_iter.write_u64::<LittleEndian>(0).unwrap();
let loader_id = bpf_loader::id();
let mut invoke_context = MockInvokeContext::default();

let elf = load_elf("bench_alu").unwrap();
let (mut vm, _) =
solana_bpf_loader_program::create_vm(&bpf_loader::id(), &elf, &[], &mut invoke_context)
.unwrap();
solana_bpf_loader_program::create_vm(&loader_id, &elf, &[], &mut invoke_context).unwrap();

println!("Interpreted:");
assert_eq!(
Expand Down
3 changes: 2 additions & 1 deletion programs/bpf/tests/programs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,10 @@ fn run_program(
let mut program_account = Account::default();
file.read_to_end(&mut program_account.data).unwrap();

let loader_id = bpf_loader::id();
let mut invoke_context = MockInvokeContext::default();
let (mut vm, heap_region) = create_vm(
&bpf_loader::id(),
&loader_id,
&program_account.data,
parameter_accounts,
&mut invoke_context,
Expand Down
2 changes: 1 addition & 1 deletion programs/bpf_loader/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub enum BPFError {
impl UserDefinedError for BPFError {}

pub fn create_vm<'a>(
loader_id: &Pubkey,
loader_id: &'a Pubkey,
prog: &'a [u8],
parameter_accounts: &'a [KeyedAccount<'a>],
invoke_context: &'a mut dyn InvokeContext,
Expand Down
Loading

0 comments on commit ae7b15f

Please sign in to comment.