Skip to content

Commit d9234b7

Browse files
committed
Differentiate between casted and transmute ptrs
1 parent d766294 commit d9234b7

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/intptrcast.rs

+8
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,14 @@ impl<'mir, 'tcx> GlobalStateInner {
9898
}
9999

100100
pub fn ptr_from_addr(ecx: &MiriEvalContext<'mir, 'tcx>, addr: u64) -> Pointer<Option<Tag>> {
101+
trace!("Transmuting 0x{:x} to a pointer", addr);
102+
103+
// TODO: fix this at some point once we deal with function pointers
104+
// Pointer::new(None, Size::from_bytes(addr))
105+
Self::ptr_from_casted_addr(ecx, addr)
106+
}
107+
108+
pub fn ptr_from_casted_addr(ecx: &MiriEvalContext<'mir, 'tcx>, addr: u64) -> Pointer<Option<Tag>> {
101109
trace!("Casting 0x{:x} to a pointer", addr);
102110
let global_state = ecx.machine.intptrcast.borrow();
103111

src/machine.rs

+8
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,14 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> {
627627
intptrcast::GlobalStateInner::ptr_from_addr(ecx, addr)
628628
}
629629

630+
#[inline(always)]
631+
fn ptr_from_casted_addr(
632+
ecx: &MiriEvalContext<'mir, 'tcx>,
633+
addr: u64,
634+
) -> Pointer<Option<Self::PointerTag>> {
635+
intptrcast::GlobalStateInner::ptr_from_casted_addr(ecx, addr)
636+
}
637+
630638
#[inline(always)]
631639
fn expose_ptr(
632640
ecx: &mut InterpCx<'mir, 'tcx, Self>,

0 commit comments

Comments
 (0)