diff options
Diffstat (limited to 'tools/standalone_miri/main.cpp')
-rw-r--r-- | tools/standalone_miri/main.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/tools/standalone_miri/main.cpp b/tools/standalone_miri/main.cpp index deed08be..8ee118f7 100644 --- a/tools/standalone_miri/main.cpp +++ b/tools/standalone_miri/main.cpp @@ -51,6 +51,7 @@ int main(int argc, const char* argv[]) try { tree.load_file(opts.infile); + tree.validate(); } catch(const DebugExceptionTodo& /*e*/) { @@ -71,26 +72,28 @@ int main(int argc, const char* argv[]) return 1; } + // Create argc/argv based on input arguments - auto argv_alloc = Allocation::new_alloc((1 + opts.args.size()) * POINTER_SIZE); - argv_alloc->write_usize(0 * POINTER_SIZE, 0); - argv_alloc->relocations.push_back({ 0 * POINTER_SIZE, RelocationPtr::new_ffi(FFIPointer { "", (void*)(opts.infile.c_str()), opts.infile.size() + 1 }) }); + auto argv_alloc = Allocation::new_alloc((1 + opts.args.size()) * POINTER_SIZE, "argv"); + argv_alloc->write_usize(0 * POINTER_SIZE, Allocation::PTR_BASE); + argv_alloc->relocations.push_back({ 0 * POINTER_SIZE, RelocationPtr::new_ffi(FFIPointer::new_const_bytes("argv0", opts.infile.c_str(), opts.infile.size() + 1)) }); for(size_t i = 0; i < opts.args.size(); i ++) { - argv_alloc->write_usize((1 + i) * POINTER_SIZE, 0); - argv_alloc->relocations.push_back({ (1 + i) * POINTER_SIZE, RelocationPtr::new_ffi({ "", (void*)(opts.args[0]), ::std::strlen(opts.args[0]) + 1 }) }); + argv_alloc->write_usize((1 + i) * POINTER_SIZE, Allocation::PTR_BASE); + argv_alloc->relocations.push_back({ (1 + i) * POINTER_SIZE, RelocationPtr::new_ffi(FFIPointer::new_const_bytes("argv", opts.args[i], ::std::strlen(opts.args[i]) + 1)) }); } - + LOG_DEBUG("argv_alloc = " << *argv_alloc); + // Construct argc/argv values auto val_argc = Value::new_isize(1 + opts.args.size()); auto argv_ty = ::HIR::TypeRef(RawType::I8).wrap(TypeWrapper::Ty::Pointer, 0 ).wrap(TypeWrapper::Ty::Pointer, 0); - auto val_argv = Value::new_pointer(argv_ty, 0, RelocationPtr::new_alloc(argv_alloc)); + auto val_argv = Value::new_pointer(argv_ty, Allocation::PTR_BASE, RelocationPtr::new_alloc(argv_alloc)); // Catch various exceptions from the interpreter try { InterpreterThread root_thread(tree); - + ::std::vector<Value> args; args.push_back(::std::move(val_argc)); args.push_back(::std::move(val_argv)); |