let-bind exp_abi of "exit" | "ExitProcess"

This commit is contained in:
hyd-dev 2021-06-11 15:53:01 +08:00
parent e46aab5816
commit 49a8f002a0
No known key found for this signature in database
GPG key ID: 74FA7FD5B8DA14B8

View file

@ -238,7 +238,12 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
| "exit"
| "ExitProcess"
=> {
let &[ref code] = this.check_shim(abi, if link_name == "exit" { Abi::C { unwind: false } } else { Abi::System { unwind: false } }, link_name_sym, args)?;
let exp_abi = if link_name == "exit" {
Abi::C { unwind: false }
} else {
Abi::System { unwind: false }
};
let &[ref code] = this.check_shim(abi, exp_abi, link_name_sym, args)?;
// it's really u32 for ExitProcess, but we have to put it into the `Exit` variant anyway
let code = this.read_scalar(code)?.to_i32()?;
throw_machine_stop!(TerminationInfo::Exit(code.into()));