@@ -20,6 +20,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
20
20
_ret : mir:: BasicBlock ,
21
21
) -> InterpResult < ' tcx , EmulateByNameResult < ' mir , ' tcx > > {
22
22
let this = self . eval_context_mut ( ) ;
23
+ let target_os = this. tcx . sess . target . os . as_str ( ) ;
23
24
24
25
match & * link_name. as_str ( ) {
25
26
// errno
@@ -30,7 +31,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
30
31
}
31
32
32
33
// File related shims (but also see "syscall" below for statx)
33
- // These symbols have different names on Linux and macOS, which is the only reason they are not
34
+ // These symbols have different names/signatures on Linux and macOS, which is the only reason they are not
34
35
// in the `posix` module.
35
36
"close" => {
36
37
let & [ ref fd] = this. check_shim ( abi, Abi :: C { unwind : false } , link_name, args) ?;
@@ -143,7 +144,12 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
143
144
144
145
let sys_getrandom = this. eval_libc ( "SYS_getrandom" ) ?. to_machine_usize ( this) ?;
145
146
146
- let sys_statx = this. eval_libc ( "SYS_statx" ) ?. to_machine_usize ( this) ?;
147
+ let sys_statx = if target_os == "android" {
148
+ // libc's Android target currently does not support SYS_statx -- fail gracefully
149
+ None
150
+ } else {
151
+ Some ( this. eval_libc ( "SYS_statx" ) ?. to_machine_usize ( this) ?)
152
+ } ;
147
153
148
154
let sys_futex = this. eval_libc ( "SYS_futex" ) ?. to_machine_usize ( this) ?;
149
155
@@ -167,7 +173,10 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
167
173
}
168
174
// `statx` is used by `libstd` to retrieve metadata information on `linux`
169
175
// instead of using `stat`,`lstat` or `fstat` as on `macos`.
170
- id if id == sys_statx => {
176
+ //
177
+ // the libc crate for android however cannot properly lookup this syscall,
178
+ // so we have to make this gracefull fail
179
+ id if sys_statx. map ( |statx| statx == id) . unwrap_or ( false ) => {
171
180
// The first argument is the syscall id, so skip over it.
172
181
if args. len ( ) < 6 {
173
182
throw_ub_format ! (
0 commit comments