From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KryfY-0004gc-A3 for qemu-devel@nongnu.org; Mon, 20 Oct 2008 13:35:52 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KryfW-0004gF-UG for qemu-devel@nongnu.org; Mon, 20 Oct 2008 13:35:52 -0400 Received: from [199.232.76.173] (port=47623 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KryfW-0004gC-P9 for qemu-devel@nongnu.org; Mon, 20 Oct 2008 13:35:50 -0400 Received: from ms01.sssup.it ([193.205.80.99]:38536 helo=sssup.it) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KryfW-0000uR-Nh for qemu-devel@nongnu.org; Mon, 20 Oct 2008 13:35:51 -0400 Message-ID: <48FCC166.4080200@gandalf.sssup.it> Date: Mon, 20 Oct 2008 19:35:34 +0200 From: michael MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH] SH: Fix struct target_stat64 for 64bit host References: <48F62D38.50001@gandalf.sssup.it> <200810201131.m9KBV7MM024318@smtp12.dti.ne.jp> In-Reply-To: <200810201131.m9KBV7MM024318@smtp12.dti.ne.jp> Content-Type: multipart/mixed; boundary="------------000602060200060704060706" Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: takasi-y@ops.dti.ne.jp This is a multi-part message in MIME format. --------------000602060200060704060706 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit hi, takasi-y@ops.dti.ne.jp wrote: > Hi, > > >> I have some trouble using the qemu emulator on the x86_64 host system. >> The system emulate >> an qemu-sh4 machine. I try to fix it without success: >> > > I found stat64 has damaged return address on stack because of bloated > struct stat64. > > On sh4 target, struct target_stat64 has "unsigned int" as its member. > It may results unwanted struct layout on 64bit host. Switched to abi_ulong. > We also have to use packed attribute for sh4, because the struct has > unaligned 64bit member st_size. > > Signed-off-by: Takashi YOSHII > > --- > linux-user/syscall_defs.h | 6 +++--- > 1 files changed, 3 insertions(+), 3 deletions(-) > > diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h > index 5a58010..01e48fd 100644 > --- a/linux-user/syscall_defs.h > +++ b/linux-user/syscall_defs.h > @@ -1475,15 +1475,15 @@ struct target_stat { > /* This matches struct stat64 in glibc2.1, hence the absolutely > * insane amounts of padding around dev_t's. > */ > -struct target_stat64 { > +struct __attribute__((__packed__)) target_stat64 { > unsigned long long st_dev; > unsigned char __pad0[4]; > > #define TARGET_STAT64_HAS_BROKEN_ST_INO 1 > abi_ulong __st_ino; > > - unsigned int st_mode; > - unsigned int st_nlink; > + abi_ulong st_mode; > + abi_ulong st_nlink; > > abi_ulong st_uid; > abi_ulong st_gid; > What would you think about this one? --------------000602060200060704060706 Content-Type: text/plain; name="stat64_patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="stat64_patch" Index: linux-user/syscall_defs.h =================================================================== --- linux-user/syscall_defs.h (revision 5499) +++ linux-user/syscall_defs.h (working copy) @@ -1506,7 +1506,7 @@ abi_ulong target_st_ctime_nsec; unsigned long long st_ino; -}; +} __attribute__((packed)); #elif defined(TARGET_I386) && !defined(TARGET_ABI32) struct target_stat { --------------000602060200060704060706--