Skip to content

Commit 515c119

Browse files
committed
Add padding on 64-bits only
1 parent 6d88a47 commit 515c119

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/shims/fs.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
295295
"S_IFLNK"
296296
};
297297

298+
// FIXME: use Scalar::to_u16
298299
let mode = this.eval_libc(mode_name)?.to_bits(Size::from_bits(16))? as u16;
299300

300301
let size = metadata.len();
@@ -316,15 +317,22 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
316317
let blksize_t_layout = this.libc_ty_layout("blksize_t")?;
317318
let uint32_t_layout = this.libc_ty_layout("uint32_t")?;
318319

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+
319328
let imms = [
320329
immty_from_uint_checked(0u128, dev_t_layout)?, // st_dev
321330
immty_from_uint_checked(mode, mode_t_layout)?, // st_mode
322331
immty_from_uint_checked(0u128, nlink_t_layout)?, // st_nlink
323332
immty_from_uint_checked(0u128, ino_t_layout)?, // st_ino
324333
immty_from_uint_checked(0u128, uid_t_layout)?, // st_uid
325334
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
328336
immty_from_uint_checked(access_sec, time_t_layout)?, // st_atime
329337
immty_from_uint_checked(access_nsec, long_layout)?, // st_atime_nsec
330338
immty_from_uint_checked(modified_sec, time_t_layout)?, // st_mtime

0 commit comments

Comments
 (0)