Skip to content

Commit 54f48ae

Browse files
author
Lander Brandt
committed
add more foreign items for linux/android
1 parent fd0534d commit 54f48ae

File tree

10 files changed

+337
-24
lines changed

10 files changed

+337
-24
lines changed

src/helpers.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
440440
/// Helper function used inside the shims of foreign functions to assert that the target OS
441441
/// is based on the Linux kernel. It panics showing a message with the `name` of the foreign function
442442
/// if this is not the case.
443-
fn assert_linux_based_target_os(&self, name: &str) {
443+
fn assert_target_os_is_linux_based(&self, name: &str) {
444444
assert!(
445445
matches!(self.eval_context_ref().tcx.sess.target.os.as_str(), "linux" | "android"),
446446
"`{}` is only available for supported Linux-based targets",

src/shims/posix/android/foreign_items.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use rustc_middle::mir;
22
use rustc_span::Symbol;
3-
use rustc_target::abi::{Align, Size};
43
use rustc_target::spec::abi::Abi;
54

65
use crate::*;

src/shims/posix/foreign_items.rs

+6
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
6060
let result = this.open(args)?;
6161
this.write_scalar(Scalar::from_i32(result), dest)?;
6262
}
63+
"openat" => {
64+
// `open` is variadic, the third argument is only present when the second argument has O_CREAT (or on linux O_TMPFILE, but miri doesn't support that) set
65+
this.check_abi_and_shim_symbol_clash(abi, Abi::C { unwind: false }, link_name)?;
66+
let result = this.openat(args)?;
67+
this.write_scalar(Scalar::from_i32(result), dest)?;
68+
}
6369
"fcntl" => {
6470
// `fcntl` is variadic. The argument count is checked based on the first argument
6571
// in `this.fcntl()`, so we do not use `check_shim` here.

0 commit comments

Comments
 (0)