@@ -12,7 +12,7 @@ use shims::unix::linux::mem::EvalContextExt as _;
1212use shims:: unix:: linux:: sync:: futex;
1313
1414pub fn is_dyn_sym ( name : & str ) -> bool {
15- matches ! ( name, "getrandom" )
15+ matches ! ( name, "getrandom" | "statx" )
1616}
1717
1818impl < ' mir , ' tcx : ' mir > EvalContextExt < ' mir , ' tcx > for crate :: MiriInterpCx < ' mir , ' tcx > { }
@@ -29,7 +29,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
2929 // See `fn emulate_foreign_item_inner` in `shims/foreign_items.rs` for the general pattern.
3030
3131 match link_name. as_str ( ) {
32- // File related shims (but also see "syscall" below for statx)
32+ // File related shims
3333 "readdir64" => {
3434 let [ dirp] = this. check_shim ( abi, Abi :: C { unwind : false } , link_name, args) ?;
3535 let result = this. linux_readdir64 ( dirp) ?;
@@ -41,6 +41,12 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
4141 let result = this. sync_file_range ( fd, offset, nbytes, flags) ?;
4242 this. write_scalar ( result, dest) ?;
4343 }
44+ "statx" => {
45+ let [ dirfd, pathname, flags, mask, statxbuf] =
46+ this. check_shim ( abi, Abi :: C { unwind : false } , link_name, args) ?;
47+ let result = this. linux_statx ( dirfd, pathname, flags, mask, statxbuf) ?;
48+ this. write_scalar ( Scalar :: from_i32 ( result) , dest) ?;
49+ }
4450
4551 // epoll, eventfd
4652 "epoll_create1" => {
@@ -113,7 +119,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
113119 // have the right type.
114120
115121 let sys_getrandom = this. eval_libc ( "SYS_getrandom" ) . to_target_usize ( this) ?;
116- let sys_statx = this. eval_libc ( "SYS_statx" ) . to_target_usize ( this) ?;
117122 let sys_futex = this. eval_libc ( "SYS_futex" ) . to_target_usize ( this) ?;
118123
119124 if args. is_empty ( ) {
@@ -134,20 +139,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
134139 }
135140 getrandom ( this, & args[ 1 ] , & args[ 2 ] , & args[ 3 ] , dest) ?;
136141 }
137- // `statx` is used by `libstd` to retrieve metadata information on `linux`
138- // instead of using `stat`,`lstat` or `fstat` as on `macos`.
139- id if id == sys_statx => {
140- // The first argument is the syscall id, so skip over it.
141- if args. len ( ) < 6 {
142- throw_ub_format ! (
143- "incorrect number of arguments for `statx` syscall: got {}, expected at least 6" ,
144- args. len( )
145- ) ;
146- }
147- let result =
148- this. linux_statx ( & args[ 1 ] , & args[ 2 ] , & args[ 3 ] , & args[ 4 ] , & args[ 5 ] ) ?;
149- this. write_scalar ( Scalar :: from_target_isize ( result. into ( ) , this) , dest) ?;
150- }
151142 // `futex` is used by some synchronization primitives.
152143 id if id == sys_futex => {
153144 futex ( this, & args[ 1 ..] , dest) ?;
0 commit comments