@@ -131,25 +131,29 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
131131 let ( dest, ret) = match ret {
132132 None => match link_name {
133133 "miri_start_panic" => {
134+ check_abi ( abi, Abi :: Rust ) ?;
134135 this. handle_miri_start_panic ( args, unwind) ?;
135136 return Ok ( None ) ;
136137 }
137138 // This matches calls to the foreign item `panic_impl`.
138139 // The implementation is provided by the function with the `#[panic_handler]` attribute.
139140 "panic_impl" => {
141+ check_abi ( abi, Abi :: Rust ) ?;
140142 let panic_impl_id = tcx. lang_items ( ) . panic_impl ( ) . unwrap ( ) ;
141143 let panic_impl_instance = ty:: Instance :: mono ( tcx, panic_impl_id) ;
142144 return Ok ( Some ( & * this. load_mir ( panic_impl_instance. def , None ) ?) ) ;
143145 }
144146 | "exit"
145147 | "ExitProcess"
146148 => {
149+ check_abi ( abi, if link_name == "exit" { Abi :: C } else { Abi :: System } ) ?;
147150 let & [ code] = check_arg_count ( args) ?;
148151 // it's really u32 for ExitProcess, but we have to put it into the `Exit` variant anyway
149152 let code = this. read_scalar ( code) ?. to_i32 ( ) ?;
150153 throw_machine_stop ! ( TerminationInfo :: Exit ( code. into( ) ) ) ;
151154 }
152155 "abort" => {
156+ check_abi ( abi, Abi :: C ) ?;
153157 throw_machine_stop ! ( TerminationInfo :: Abort ( "the program aborted execution" . to_owned( ) ) )
154158 }
155159 _ => throw_unsup_format ! ( "can't call (diverging) foreign function: {}" , link_name) ,
@@ -504,6 +508,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
504508
505509 // Architecture-specific shims
506510 "llvm.x86.sse2.pause" if this. tcx . sess . target . arch == "x86" || this. tcx . sess . target . arch == "x86_64" => {
511+ check_abi ( abi, Abi :: C ) ?;
507512 let & [ ] = check_arg_count ( args) ?;
508513 this. yield_active_thread ( ) ;
509514 }
0 commit comments