Skip to content

Commit 04523fe

Browse files
committed
wip
1 parent 04b669d commit 04523fe

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/machine.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,8 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'tcx> {
272272
fn find_foreign_static(
273273
tcx: TyCtxt<'tcx>,
274274
def_id: DefId,
275-
_memory_extra: &MemoryExtra,
276-
) -> InterpResult<'tcx, Cow<'tcx, Allocation>> {
275+
memory_extra: &MemoryExtra,
276+
) -> InterpResult<'tcx, Cow<'tcx, Allocation<Tag, AllocExtra>>> {
277277
let attrs = tcx.get_attrs(def_id);
278278
let link_name = match attr::first_attr_value_str_by_name(&attrs, sym::link_name) {
279279
Some(name) => name.as_str(),
@@ -287,6 +287,9 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'tcx> {
287287
let data = vec![0; size.bytes() as usize];
288288
Allocation::from_bytes(&data, tcx.data_layout.pointer_align.abi)
289289
}
290+
"environ" => {
291+
memory_extra.environ.as_ref().unwrap().clone()
292+
}
290293
_ => throw_unsup_format!("can't access foreign static: {}", link_name),
291294
};
292295
Ok(Cow::Owned(alloc))

src/shims/env.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ impl EnvVars {
4444
}
4545
ecx.memory.mark_immutable(environ_place.ptr.assert_ptr().alloc_id).unwrap();
4646
// A pointer to that place corresponds to the `environ` static.
47-
let environ_alloc = ecx.memory.get_raw(environ_place.ptr.assert_ptr().alloc_id).unwrap().clone();
47+
let environ_ptr = ecx.force_ptr(environ_place.ptr).unwrap();
48+
let environ_alloc = ecx.memory.get_raw(environ_ptr.alloc_id).unwrap().clone();
4849
ecx.memory.extra.environ = Some(environ_alloc);
4950
}
5051
}

0 commit comments

Comments
 (0)