Skip to content

Commit a5411ba

Browse files
committed
Add padding on 64-bits only
1 parent cdaed07 commit a5411ba

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/shims/fs.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,15 +316,22 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
316316
let blksize_t_layout = this.libc_ty_layout("blksize_t")?;
317317
let uint32_t_layout = this.libc_ty_layout("uint32_t")?;
318318

319+
// We need to add 32 bits of padding after `st_rdev` if we are in a 64-bit platform. To do
320+
// this, we store `st_rdev` as a `c_long` instead of a `dev_t`.
321+
let st_rdev_layout = if this.tcx.sess.target.ptr_width == 64 {
322+
long_layout
323+
} else {
324+
dev_t_layout
325+
};
326+
319327
let imms = [
320328
immty_from_uint_checked(0u128, dev_t_layout)?, // st_dev
321329
immty_from_uint_checked(mode, mode_t_layout)?, // st_mode
322330
immty_from_uint_checked(0u128, nlink_t_layout)?, // st_nlink
323331
immty_from_uint_checked(0u128, ino_t_layout)?, // st_ino
324332
immty_from_uint_checked(0u128, uid_t_layout)?, // st_uid
325333
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
334+
immty_from_uint_checked(0u128, st_rdev_layout)?, // st_rdev
328335
immty_from_uint_checked(access_sec, time_t_layout)?, // st_atime
329336
immty_from_uint_checked(access_nsec, long_layout)?, // st_atime_nsec
330337
immty_from_uint_checked(modified_sec, time_t_layout)?, // st_mtime

0 commit comments

Comments
 (0)