Skip to content

Commit 89c722a

Browse files
author
hyd-dev
committed
Add some comments about check_shim
1 parent 49a8f00 commit 89c722a

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

src/shims/foreign_items.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,12 +223,16 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
223223
let (dest, ret) = match ret {
224224
None => match link_name {
225225
"miri_start_panic" => {
226+
// `check_shim` happens inside `handle_miri_start_panic`.
226227
this.handle_miri_start_panic(abi, link_name_sym, args, unwind)?;
227228
return Ok(None);
228229
}
229230
// This matches calls to the foreign item `panic_impl`.
230231
// The implementation is provided by the function with the `#[panic_handler]` attribute.
231232
"panic_impl" => {
233+
// We don't use `check_shim` here because we are just forwarding to the lang
234+
// item. Argument count checking will be performed when the returned `Body` is
235+
// called.
232236
this.check_abi_and_shim_symbol_clash(abi, Abi::Rust, link_name_sym)?;
233237
let panic_impl_id = tcx.lang_items().panic_impl().unwrap();
234238
let panic_impl_instance = ty::Instance::mono(tcx, panic_impl_id);
@@ -317,11 +321,13 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
317321

318322
// Obtains a Miri backtrace. See the README for details.
319323
"miri_get_backtrace" => {
324+
// `check_shim` happens inside `handle_miri_get_backtrace`.
320325
this.handle_miri_get_backtrace(abi, link_name_sym, args, dest)?;
321326
}
322327

323328
// Resolves a Miri backtrace frame. See the README for details.
324329
"miri_resolve_frame" => {
330+
// `check_shim` happens inside `handle_miri_resolve_frame`.
325331
this.handle_miri_resolve_frame(abi, link_name_sym, args, dest)?;
326332
}
327333

src/shims/posix/foreign_items.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
6060
this.write_scalar(Scalar::from_i32(result), dest)?;
6161
}
6262
"fcntl" => {
63+
// `fcntl` is variadic. The argument count is checked based on the first argument
64+
// in`this.fcntl()`, so we do not use `check_shim` here.
6365
this.check_abi_and_shim_symbol_clash(abi, Abi::C { unwind: false }, link_name_sym)?;
6466
let result = this.fcntl(args)?;
6567
this.write_scalar(Scalar::from_i32(result), dest)?;

src/shims/posix/linux/foreign_items.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
128128

129129
// Dynamically invoked syscalls
130130
"syscall" => {
131+
// We do not use `check_shim` here because `syscall` is variadic. The argument
132+
// count is checked bellow.
131133
this.check_abi_and_shim_symbol_clash(abi, Abi::C { unwind: false }, link_name_sym)?;
132134
// The syscall variadic function is legal to call with more arguments than needed,
133135
// extra arguments are simply ignored. However, all arguments need to be scalars;

0 commit comments

Comments
 (0)