@@ -295,6 +295,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
295
295
"S_IFLNK"
296
296
} ;
297
297
298
+ // FIXME: use Scalar::to_u16
298
299
let mode = this. eval_libc ( mode_name) ?. to_bits ( Size :: from_bits ( 16 ) ) ? as u16 ;
299
300
300
301
let size = metadata. len ( ) ;
@@ -316,15 +317,22 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
316
317
let blksize_t_layout = this. libc_ty_layout ( "blksize_t" ) ?;
317
318
let uint32_t_layout = this. libc_ty_layout ( "uint32_t" ) ?;
318
319
320
+ // We need to add 32 bits of padding after `st_rdev` if we are in a 64-bit platform. To do
321
+ // this, we store `st_rdev` as a `c_long` instead of a `dev_t`.
322
+ let st_rdev_layout = if this. tcx . sess . target . ptr_width == 64 {
323
+ long_layout
324
+ } else {
325
+ dev_t_layout
326
+ } ;
327
+
319
328
let imms = [
320
329
immty_from_uint_checked ( 0u128 , dev_t_layout) ?, // st_dev
321
330
immty_from_uint_checked ( mode, mode_t_layout) ?, // st_mode
322
331
immty_from_uint_checked ( 0u128 , nlink_t_layout) ?, // st_nlink
323
332
immty_from_uint_checked ( 0u128 , ino_t_layout) ?, // st_ino
324
333
immty_from_uint_checked ( 0u128 , uid_t_layout) ?, // st_uid
325
334
immty_from_uint_checked ( 0u128 , gid_t_layout) ?, // st_gid
326
- immty_from_uint_checked ( 0u128 , dev_t_layout) ?, // st_rdev
327
- immty_from_uint_checked ( 0u128 , dev_t_layout) ?, // padding
335
+ immty_from_uint_checked ( 0u128 , st_rdev_layout) ?, // st_rdev
328
336
immty_from_uint_checked ( access_sec, time_t_layout) ?, // st_atime
329
337
immty_from_uint_checked ( access_nsec, long_layout) ?, // st_atime_nsec
330
338
immty_from_uint_checked ( modified_sec, time_t_layout) ?, // st_mtime
0 commit comments