Date: Fri, 4 Jan 2019 20:51:46 -0800 From: Mark Millard <marklmi@yahoo.com> To: Kyle Evans <kevans@FreeBSD.org>, freebsd-emulation@freebsd.org, ports-list freebsd <freebsd-ports@freebsd.org> Cc: Sean Bruno <sbruno@freebsd.org> Subject: Re: qemu-x86_64-static has target_freebsd_flock being too small (__packed use issue) [subject correction: fixed to be "too small"] Message-ID: <B9B82495-F526-4CA0-B0C1-AC6048572819@yahoo.com> In-Reply-To: <1139EAD0-FED3-428C-AA0E-00ABB8BD111D@yahoo.com> References: <1139EAD0-FED3-428C-AA0E-00ABB8BD111D@yahoo.com>
next in thread | previous in thread | raw e-mail | index | archive | help
[Just correcting the "larger" to be "smaller".] On 2019-Jan-4, at 19:29, Mark Millard <marklmi@yahoo.com> wrote: [qemu-aarch64-static has the same problem but qemu-armv7-sstatic does = not. The context here is FreeBSD head -r341836 based and ports head -r488859 based.] Note: I assume that "struct target_freebsd_flock" is meant to match the = memory layout of the target's native "struct flock". Otherwise the reported = differences below could be irrelevant. For amd64 and aarch64 the following code: printf("sizeof(struct flock) =3D %lu\n", (unsigned long) = sizeof(struct flock)); printf("l_start %lu\n", (unsigned long) offsetof(struct flock, = l_start)); printf("l_len %lu\n", (unsigned long) offsetof(struct flock, = l_len)); printf("l_pid %lu\n", (unsigned long) offsetof(struct flock, = l_pid)); printf("l_type %lu\n", (unsigned long) offsetof(struct flock, = l_type)); printf("l_whence %lu\n", (unsigned long) offsetof(struct flock, = l_whence)); printf("l_sysid %lu\n", (unsigned long) offsetof(struct flock, = l_sysid)); produces: sizeof(struct flock) =3D 32 l_start 0 l_len 8 l_pid 16 l_type 20 l_whence 22 l_sysid 24 However gdb reports for qemu-x86_64-static and qemu-aarch64-static and qemu-arm-static: (gdb) p/d sizeof(struct target_freebsd_flock) $10 =3D 28 (gdb) p/d &((struct target_freebsd_flock *)0)->l_start =20 $11 =3D 0 (gdb) p/d &((struct target_freebsd_flock *)0)->l_len =20 $12 =3D 8 (gdb) p/d &((struct target_freebsd_flock *)0)->l_pid $13 =3D 16 (gdb) p/d &((struct target_freebsd_flock *)0)->l_type $14 =3D 20 (gdb) p/d &((struct target_freebsd_flock *)0)->l_whence $15 =3D 22 (gdb) p/d &((struct target_freebsd_flock *)0)->l_sysid=20 $16 =3D 24 So only the overall size is different for this information. But: struct target_freebsd_flock { int64_t l_start; int64_t l_len; int32_t l_pid; int16_t l_type; int16_t l_whence; int32_t l_sysid; } QEMU_PACKED; with a potential packed vs. /usr/include/sys/fcntl.h : struct flock { off_t l_start; /* starting offset */ off_t l_len; /* len =3D 0 means until end of file */ pid_t l_pid; /* lock owner */ short l_type; /* lock type: read/write, etc. */ short l_whence; /* type of l_start */ int l_sysid; /* remote system id or zero for local */ }; with no potential __packed. =3D=3D=3D Mark Millard marklmi at yahoo.com ( dsl-only.net went away in early 2018-Mar)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?B9B82495-F526-4CA0-B0C1-AC6048572819>