@@ -70,7 +70,7 @@ pub struct AllocExtra {
70
70
71
71
/// Extra global memory data
72
72
#[ derive( Clone , Debug ) ]
73
- pub struct MemoryExtra {
73
+ pub struct MemoryExtra < ' tcx > {
74
74
pub stacked_borrows : Option < stacked_borrows:: MemoryExtra > ,
75
75
pub intptrcast : intptrcast:: MemoryExtra ,
76
76
@@ -85,11 +85,11 @@ pub struct MemoryExtra {
85
85
/// (helps for debugging memory leaks).
86
86
tracked_alloc_id : Option < AllocId > ,
87
87
88
- /// The `AllocId` for the `environ` static.
89
- pub ( crate ) environ : Option < Scalar < Tag > > ,
88
+ /// Place where the `environ` static is stored .
89
+ pub ( crate ) environ : Option < MPlaceTy < ' tcx , Tag > > ,
90
90
}
91
91
92
- impl MemoryExtra {
92
+ impl < ' tcx > MemoryExtra < ' tcx > {
93
93
pub fn new ( rng : StdRng , stacked_borrows : bool , tracked_pointer_tag : Option < PtrId > , tracked_alloc_id : Option < AllocId > ) -> Self {
94
94
let stacked_borrows = if stacked_borrows {
95
95
Some ( Rc :: new ( RefCell :: new ( stacked_borrows:: GlobalState :: new ( tracked_pointer_tag) ) ) )
@@ -107,7 +107,7 @@ impl MemoryExtra {
107
107
}
108
108
109
109
/// Sets up the "extern statics" for this machine.
110
- pub fn init_extern_statics < ' mir , ' tcx > (
110
+ pub fn init_extern_statics < ' mir > (
111
111
this : & mut MiriEvalContext < ' mir , ' tcx > ,
112
112
) -> InterpResult < ' tcx > {
113
113
match this. tcx . sess . target . target . target_os . as_str ( ) {
@@ -126,12 +126,13 @@ impl MemoryExtra {
126
126
// "environ"
127
127
let layout = this. layout_of ( this. tcx . types . usize ) ?;
128
128
let place = this. allocate ( layout, MiriMemoryKind :: Machine . into ( ) ) ;
129
- this. write_scalar ( this. memory . extra . environ . unwrap ( ) , place. into ( ) ) ?;
129
+ this. write_scalar ( Scalar :: from_machine_usize ( 0 , & * this. tcx ) , place. into ( ) ) ?;
130
130
this. memory
131
131
. extra
132
132
. extern_statics
133
133
. insert ( Symbol :: intern ( "environ" ) , place. ptr . assert_ptr ( ) . alloc_id )
134
134
. unwrap_none ( ) ;
135
+ this. memory . extra . environ = Some ( place) ;
135
136
}
136
137
_ => { } // No "extern statics" supported on this platform
137
138
}
@@ -217,7 +218,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'tcx> {
217
218
type MemoryKinds = MiriMemoryKind ;
218
219
219
220
type FrameExtra = FrameData < ' tcx > ;
220
- type MemoryExtra = MemoryExtra ;
221
+ type MemoryExtra = MemoryExtra < ' tcx > ;
221
222
type AllocExtra = AllocExtra ;
222
223
type PointerTag = Tag ;
223
224
type ExtraFnVal = Dlsym ;
@@ -343,7 +344,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'tcx> {
343
344
}
344
345
345
346
fn init_allocation_extra < ' b > (
346
- memory_extra : & MemoryExtra ,
347
+ memory_extra : & MemoryExtra < ' tcx > ,
347
348
id : AllocId ,
348
349
alloc : Cow < ' b , Allocation > ,
349
350
kind : Option < MemoryKind < Self :: MemoryKinds > > ,
@@ -380,7 +381,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'tcx> {
380
381
}
381
382
382
383
#[ inline( always) ]
383
- fn tag_static_base_pointer ( memory_extra : & MemoryExtra , id : AllocId ) -> Self :: PointerTag {
384
+ fn tag_static_base_pointer ( memory_extra : & MemoryExtra < ' tcx > , id : AllocId ) -> Self :: PointerTag {
384
385
if let Some ( stacked_borrows) = memory_extra. stacked_borrows . as_ref ( ) {
385
386
stacked_borrows. borrow_mut ( ) . static_base_ptr ( id)
386
387
} else {
0 commit comments