From d9234b78b22304be67b695ac4bde68eeeb8ab724 Mon Sep 17 00:00:00 2001 From: carbotaniuman <41451839+carbotaniuman@users.noreply.github.com> Date: Wed, 20 Apr 2022 21:49:46 -0500 Subject: [PATCH] Differentiate between casted and transmute ptrs --- src/intptrcast.rs | 8 ++++++++ src/machine.rs | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/src/intptrcast.rs b/src/intptrcast.rs index 60cfca5425..fad1521627 100644 --- a/src/intptrcast.rs +++ b/src/intptrcast.rs @@ -98,6 +98,14 @@ impl<'mir, 'tcx> GlobalStateInner { } pub fn ptr_from_addr(ecx: &MiriEvalContext<'mir, 'tcx>, addr: u64) -> Pointer> { + 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> { trace!("Casting 0x{:x} to a pointer", addr); let global_state = ecx.machine.intptrcast.borrow(); diff --git a/src/machine.rs b/src/machine.rs index 126e481a05..043ba961d4 100644 --- a/src/machine.rs +++ b/src/machine.rs @@ -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> { + intptrcast::GlobalStateInner::ptr_from_casted_addr(ecx, addr) + } + #[inline(always)] fn expose_ptr( ecx: &mut InterpCx<'mir, 'tcx, Self>,