Skip to content

Commit

Permalink
Differentiate between casted and transmute ptrs
Browse files Browse the repository at this point in the history
  • Loading branch information
carbotaniuman committed Apr 21, 2022
1 parent d766294 commit d9234b7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/intptrcast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,14 @@ impl<'mir, 'tcx> GlobalStateInner {
}

pub fn ptr_from_addr(ecx: &MiriEvalContext<'mir, 'tcx>, addr: u64) -> Pointer<Option<Tag>> {
trace!("Transmuting 0x{:x} to a pointer", addr);

// TODO: fix this at some point once we deal with function pointers
// Pointer::new(None, Size::from_bytes(addr))
Self::ptr_from_casted_addr(ecx, addr)
}

pub fn ptr_from_casted_addr(ecx: &MiriEvalContext<'mir, 'tcx>, addr: u64) -> Pointer<Option<Tag>> {
trace!("Casting 0x{:x} to a pointer", addr);
let global_state = ecx.machine.intptrcast.borrow();

Expand Down
8 changes: 8 additions & 0 deletions src/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,14 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> {
intptrcast::GlobalStateInner::ptr_from_addr(ecx, addr)
}

#[inline(always)]
fn ptr_from_casted_addr(
ecx: &MiriEvalContext<'mir, 'tcx>,
addr: u64,
) -> Pointer<Option<Self::PointerTag>> {
intptrcast::GlobalStateInner::ptr_from_casted_addr(ecx, addr)
}

#[inline(always)]
fn expose_ptr(
ecx: &mut InterpCx<'mir, 'tcx, Self>,
Expand Down

0 comments on commit d9234b7

Please sign in to comment.