pass arguments to start
This commit is contained in:
parent
8abd293119
commit
a55ac1fea8
4 changed files with 24 additions and 3 deletions
|
@ -48,6 +48,17 @@ impl<'a> CompilerCalls<'a> for MiriCompilerCalls {
|
||||||
|
|
||||||
ecx.push_stack_frame(def_id, mir.span, CachedMir::Ref(mir), substs, Some(return_ptr));
|
ecx.push_stack_frame(def_id, mir.span, CachedMir::Ref(mir), substs, Some(return_ptr));
|
||||||
|
|
||||||
|
if mir.arg_decls.len() == 2 {
|
||||||
|
// start function
|
||||||
|
let ptr_size = ecx.memory().pointer_size;
|
||||||
|
let nargs = ecx.memory_mut().allocate(ptr_size);
|
||||||
|
ecx.memory_mut().write_usize(nargs, 0).unwrap();
|
||||||
|
let args = ecx.memory_mut().allocate(ptr_size);
|
||||||
|
ecx.memory_mut().write_usize(args, 0).unwrap();
|
||||||
|
ecx.frame_mut().locals[0] = nargs;
|
||||||
|
ecx.frame_mut().locals[1] = args;
|
||||||
|
}
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
match step(&mut ecx) {
|
match step(&mut ecx) {
|
||||||
Ok(true) => {}
|
Ok(true) => {}
|
||||||
|
|
|
@ -154,6 +154,10 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
|
||||||
&self.memory
|
&self.memory
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn memory_mut(&mut self) -> &mut Memory<'tcx> {
|
||||||
|
&mut self.memory
|
||||||
|
}
|
||||||
|
|
||||||
pub fn stack(&self) -> &[Frame] {
|
pub fn stack(&self) -> &[Frame] {
|
||||||
&self.stack
|
&self.stack
|
||||||
}
|
}
|
||||||
|
@ -1373,7 +1377,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
|
||||||
self.stack.last().expect("no call frames exist")
|
self.stack.last().expect("no call frames exist")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn frame_mut(&mut self) -> &mut Frame<'a, 'tcx> {
|
pub fn frame_mut(&mut self) -> &mut Frame<'a, 'tcx> {
|
||||||
self.stack.last_mut().expect("no call frames exist")
|
self.stack.last_mut().expect("no call frames exist")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,9 @@ fn run_mode(mode: &'static str) {
|
||||||
let targets = &["x86_64-unknown-linux-gnu", "i686-unknown-linux-gnu"];
|
let targets = &["x86_64-unknown-linux-gnu", "i686-unknown-linux-gnu"];
|
||||||
|
|
||||||
for &target in targets {
|
for &target in targets {
|
||||||
|
use std::io::Write;
|
||||||
|
let stderr = std::io::stderr();
|
||||||
|
write!(stderr.lock(), "running tests for target {}", target).unwrap();
|
||||||
let mut config = compiletest::default_config();
|
let mut config = compiletest::default_config();
|
||||||
config.host_rustcflags = Some(flags.clone());
|
config.host_rustcflags = Some(flags.clone());
|
||||||
config.mode = mode.parse().expect("Invalid mode");
|
config.mode = mode.parse().expect("Invalid mode");
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
#![feature(start)]
|
#![feature(start)]
|
||||||
|
|
||||||
#[start]
|
#[start]
|
||||||
fn foo(_nargs: isize, _args: *const *const u8) -> isize {
|
fn foo(nargs: isize, args: *const *const u8) -> isize {
|
||||||
return 0;
|
if nargs > 0 {
|
||||||
|
assert!(unsafe{*args} as usize != 0);
|
||||||
|
}
|
||||||
|
0
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue