Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
pvdrz committed Jan 15, 2020
1 parent 04b669d commit 04523fe
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,8 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'tcx> {
fn find_foreign_static(
tcx: TyCtxt<'tcx>,
def_id: DefId,
_memory_extra: &MemoryExtra,
) -> InterpResult<'tcx, Cow<'tcx, Allocation>> {
memory_extra: &MemoryExtra,
) -> InterpResult<'tcx, Cow<'tcx, Allocation<Tag, AllocExtra>>> {
let attrs = tcx.get_attrs(def_id);
let link_name = match attr::first_attr_value_str_by_name(&attrs, sym::link_name) {
Some(name) => name.as_str(),
Expand All @@ -287,6 +287,9 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'tcx> {
let data = vec![0; size.bytes() as usize];
Allocation::from_bytes(&data, tcx.data_layout.pointer_align.abi)
}
"environ" => {
memory_extra.environ.as_ref().unwrap().clone()
}
_ => throw_unsup_format!("can't access foreign static: {}", link_name),
};
Ok(Cow::Owned(alloc))
Expand Down
3 changes: 2 additions & 1 deletion src/shims/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ impl EnvVars {
}
ecx.memory.mark_immutable(environ_place.ptr.assert_ptr().alloc_id).unwrap();
// A pointer to that place corresponds to the `environ` static.
let environ_alloc = ecx.memory.get_raw(environ_place.ptr.assert_ptr().alloc_id).unwrap().clone();
let environ_ptr = ecx.force_ptr(environ_place.ptr).unwrap();
let environ_alloc = ecx.memory.get_raw(environ_ptr.alloc_id).unwrap().clone();
ecx.memory.extra.environ = Some(environ_alloc);
}
}
Expand Down

0 comments on commit 04523fe

Please sign in to comment.