@@ -55,6 +55,12 @@ impl Pointer {
55
55
pub fn points_to_zst ( & self ) -> bool {
56
56
self . alloc_id == ZST_ALLOC_ID
57
57
}
58
+ pub fn from_int ( i : usize ) -> Self {
59
+ Pointer {
60
+ alloc_id : ZST_ALLOC_ID ,
61
+ offset : i,
62
+ }
63
+ }
58
64
fn zst_ptr ( ) -> Self {
59
65
Pointer {
60
66
alloc_id : ZST_ALLOC_ID ,
@@ -279,7 +285,7 @@ impl<'a, 'tcx> Memory<'a, 'tcx> {
279
285
Some ( alloc) => Ok ( alloc) ,
280
286
None => match self . functions . get ( & id) {
281
287
Some ( _) => Err ( EvalError :: DerefFunctionPointer ) ,
282
- None if id == ZST_ALLOC_ID => Err ( EvalError :: ZstAllocAccess ) ,
288
+ None if id == ZST_ALLOC_ID => Err ( EvalError :: InvalidMemoryAccess ) ,
283
289
None => Err ( EvalError :: DanglingPointerDeref ) ,
284
290
}
285
291
}
@@ -291,7 +297,7 @@ impl<'a, 'tcx> Memory<'a, 'tcx> {
291
297
Some ( alloc) => Ok ( alloc) ,
292
298
None => match self . functions . get ( & id) {
293
299
Some ( _) => Err ( EvalError :: DerefFunctionPointer ) ,
294
- None if id == ZST_ALLOC_ID => Err ( EvalError :: ZstAllocAccess ) ,
300
+ None if id == ZST_ALLOC_ID => Err ( EvalError :: InvalidMemoryAccess ) ,
295
301
None => Err ( EvalError :: DanglingPointerDeref ) ,
296
302
}
297
303
}
@@ -511,7 +517,7 @@ impl<'a, 'tcx> Memory<'a, 'tcx> {
511
517
let alloc = self . get ( ptr. alloc_id ) ?;
512
518
match alloc. relocations . get ( & ptr. offset ) {
513
519
Some ( & alloc_id) => Ok ( Pointer { alloc_id : alloc_id, offset : offset } ) ,
514
- None => Err ( EvalError :: ReadBytesAsPointer ) ,
520
+ None => Ok ( Pointer :: from_int ( offset ) ) ,
515
521
}
516
522
}
517
523
@@ -522,7 +528,6 @@ impl<'a, 'tcx> Memory<'a, 'tcx> {
522
528
}
523
529
524
530
pub fn write_primval ( & mut self , ptr : Pointer , val : PrimVal ) -> EvalResult < ' tcx , ( ) > {
525
- let pointer_size = self . pointer_size ( ) ;
526
531
match val {
527
532
PrimVal :: Bool ( b) => self . write_bool ( ptr, b) ,
528
533
PrimVal :: I8 ( n) => self . write_int ( ptr, n as i64 , 1 ) ,
@@ -534,7 +539,6 @@ impl<'a, 'tcx> Memory<'a, 'tcx> {
534
539
PrimVal :: U32 ( n) => self . write_uint ( ptr, n as u64 , 4 ) ,
535
540
PrimVal :: U64 ( n) => self . write_uint ( ptr, n as u64 , 8 ) ,
536
541
PrimVal :: Char ( c) => self . write_uint ( ptr, c as u64 , 4 ) ,
537
- PrimVal :: IntegerPtr ( n) => self . write_uint ( ptr, n as u64 , pointer_size) ,
538
542
PrimVal :: F32 ( f) => self . write_f32 ( ptr, f) ,
539
543
PrimVal :: F64 ( f) => self . write_f64 ( ptr, f) ,
540
544
PrimVal :: FnPtr ( p) |
0 commit comments