do padding correctly

This commit is contained in:
Christian Poveda 2019-12-25 18:22:33 -05:00
parent d176259002
commit 1bc3629084
No known key found for this signature in database
GPG key ID: 27525EF5E7420A50

View file

@ -302,12 +302,11 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
let blksize_t_layout = this.libc_ty_layout("blksize_t")?;
let uint32_t_layout = this.libc_ty_layout("uint32_t")?;
// We need to add 32 bits of padding after `st_rdev` if we are in a 64-bit platform. To do
// this, we store `st_rdev` as a `c_long` instead of a `dev_t`.
let st_rdev_layout = if this.tcx.sess.target.ptr_width == 64 {
long_layout
// We need to add 32 bits of padding after `st_rdev` if we are in a 64-bit platform.
let pad_layout = if this.tcx.sess.target.ptr_width == 64 {
uint32_t_layout
} else {
dev_t_layout
this.layout_of(this.tcx.mk_unit())?
};
let imms = [
@ -317,7 +316,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
immty_from_uint_checked(0u128, ino_t_layout)?, // st_ino
immty_from_uint_checked(0u128, uid_t_layout)?, // st_uid
immty_from_uint_checked(0u128, gid_t_layout)?, // st_gid
immty_from_uint_checked(0u128, st_rdev_layout)?, // st_rdev
immty_from_uint_checked(0u128, dev_t_layout)?, // st_rdev
immty_from_uint_checked(0u128, pad_layout)?, // padding for 64-bit targets
immty_from_uint_checked(access_sec, time_t_layout)?, // st_atime
immty_from_uint_checked(access_nsec, long_layout)?, // st_atime_nsec
immty_from_uint_checked(modified_sec, time_t_layout)?, // st_mtime