@@ -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,9 +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-
117- let sys_statx = this. eval_libc ( "SYS_statx" ) . to_target_usize ( this) ?;
118-
119122 let sys_futex = this. eval_libc ( "SYS_futex" ) . to_target_usize ( this) ?;
120123
121124 if args. is_empty ( ) {
@@ -136,20 +139,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
136139 }
137140 getrandom ( this, & args[ 1 ] , & args[ 2 ] , & args[ 3 ] , dest) ?;
138141 }
139- // `statx` is used by `libstd` to retrieve metadata information on `linux`
140- // instead of using `stat`,`lstat` or `fstat` as on `macos`.
141- id if id == sys_statx => {
142- // The first argument is the syscall id, so skip over it.
143- if args. len ( ) < 6 {
144- throw_ub_format ! (
145- "incorrect number of arguments for `statx` syscall: got {}, expected at least 6" ,
146- args. len( )
147- ) ;
148- }
149- let result =
150- this. linux_statx ( & args[ 1 ] , & args[ 2 ] , & args[ 3 ] , & args[ 4 ] , & args[ 5 ] ) ?;
151- this. write_scalar ( Scalar :: from_target_isize ( result. into ( ) , this) , dest) ?;
152- }
153142 // `futex` is used by some synchronization primitives.
154143 id if id == sys_futex => {
155144 futex ( this, & args[ 1 ..] , dest) ?;
0 commit comments