@@ -70,7 +70,7 @@ pub struct AllocExtra {
7070
7171/// Extra global memory data
7272#[ derive( Clone , Debug ) ]
73- pub struct MemoryExtra {
73+ pub struct MemoryExtra < ' tcx > {
7474 pub stacked_borrows : Option < stacked_borrows:: MemoryExtra > ,
7575 pub intptrcast : intptrcast:: MemoryExtra ,
7676
@@ -80,11 +80,11 @@ pub struct MemoryExtra {
8080 /// The random number generator used for resolving non-determinism.
8181 /// Needs to be queried by ptr_to_int, hence needs interior mutability.
8282 pub ( crate ) rng : RefCell < StdRng > ,
83- /// The `AllocId` for the `environ` static.
84- pub ( crate ) environ : Option < Scalar < Tag > > ,
83+ /// Place where the `environ` static is stored .
84+ pub ( crate ) environ : Option < MPlaceTy < ' tcx , Tag > > ,
8585}
8686
87- impl MemoryExtra {
87+ impl < ' tcx > MemoryExtra < ' tcx > {
8888 pub fn new ( rng : StdRng , stacked_borrows : bool , tracked_pointer_tag : Option < PtrId > ) -> Self {
8989 let stacked_borrows = if stacked_borrows {
9090 Some ( Rc :: new ( RefCell :: new ( stacked_borrows:: GlobalState :: new ( tracked_pointer_tag) ) ) )
@@ -101,7 +101,7 @@ impl MemoryExtra {
101101 }
102102
103103 /// Sets up the "extern statics" for this machine.
104- pub fn init_extern_statics < ' mir , ' tcx > (
104+ pub fn init_extern_statics < ' mir > (
105105 this : & mut MiriEvalContext < ' mir , ' tcx > ,
106106 ) -> InterpResult < ' tcx > {
107107 match this. tcx . sess . target . target . target_os . as_str ( ) {
@@ -120,12 +120,13 @@ impl MemoryExtra {
120120 // "environ"
121121 let layout = this. layout_of ( this. tcx . types . usize ) ?;
122122 let place = this. allocate ( layout, MiriMemoryKind :: Machine . into ( ) ) ;
123- this. write_scalar ( this. memory . extra . environ . unwrap ( ) , place. into ( ) ) ?;
123+ this. write_scalar ( Scalar :: from_machine_usize ( 0 , & * this. tcx ) , place. into ( ) ) ?;
124124 this. memory
125125 . extra
126126 . extern_statics
127127 . insert ( "environ" , place. ptr . assert_ptr ( ) . alloc_id )
128128 . unwrap_none ( ) ;
129+ this. memory . extra . environ = Some ( place) ;
129130 }
130131 _ => { } // No "extern statics" supported on this platform
131132 }
@@ -211,7 +212,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'tcx> {
211212 type MemoryKinds = MiriMemoryKind ;
212213
213214 type FrameExtra = FrameData < ' tcx > ;
214- type MemoryExtra = MemoryExtra ;
215+ type MemoryExtra = MemoryExtra < ' tcx > ;
215216 type AllocExtra = AllocExtra ;
216217 type PointerTag = Tag ;
217218 type ExtraFnVal = Dlsym ;
@@ -337,7 +338,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'tcx> {
337338 }
338339
339340 fn init_allocation_extra < ' b > (
340- memory_extra : & MemoryExtra ,
341+ memory_extra : & MemoryExtra < ' tcx > ,
341342 id : AllocId ,
342343 alloc : Cow < ' b , Allocation > ,
343344 kind : Option < MemoryKind < Self :: MemoryKinds > > ,
@@ -370,7 +371,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'tcx> {
370371 }
371372
372373 #[ inline( always) ]
373- fn tag_static_base_pointer ( memory_extra : & MemoryExtra , id : AllocId ) -> Self :: PointerTag {
374+ fn tag_static_base_pointer ( memory_extra : & MemoryExtra < ' tcx > , id : AllocId ) -> Self :: PointerTag {
374375 if let Some ( stacked_borrows) = memory_extra. stacked_borrows . as_ref ( ) {
375376 stacked_borrows. borrow_mut ( ) . static_base_ptr ( id)
376377 } else {
0 commit comments