Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IboL0-0001IP-3p for qemu-devel@nongnu.org; Sat, 29 Sep 2007 22:15:18 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IboKx-0001Hl-O6 for qemu-devel@nongnu.org; Sat, 29 Sep 2007 22:15:16 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IboKx-0001Hi-KD for qemu-devel@nongnu.org; Sat, 29 Sep 2007 22:15:15 -0400 Received: from miranda.se.axis.com ([193.13.178.8]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1IboKx-0005tf-3o for qemu-devel@nongnu.org; Sat, 29 Sep 2007 22:15:15 -0400 Received: from axis.com (edgar.se.axis.com [10.92.151.1]) by miranda.se.axis.com (8.13.4/8.13.4/Debian-3sarge3) with ESMTP id l8U2FDHT009099 for ; Sun, 30 Sep 2007 04:15:13 +0200 Date: Sun, 30 Sep 2007 04:15:13 +0200 From: "Edgar E. Iglesias" Subject: Re: [Qemu-devel] RFC: cleanups in ELF loader Message-ID: <20070930021512.GB19016@edgar.underground.se.axis.com> References: <1191116355.29900.86.camel@rapid> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1191116355.29900.86.camel@rapid> 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 On Sun, Sep 30, 2007 at 03:39:15AM +0200, J. Mayer wrote: > Following what I've done in the syscalls emulation routines, it appeared > to me that there seems to be a lot of confusions between host and target > long in the ELF loader. > I tried to fix this. I also noticed that the image infos start_data > field was not computed as the Linux kernel does. As the ARM and the > Alpha targets use this information to initialize the program state > before execution, it seems a good idea (to me !) to fix it. > As this patch can have an impact on all user-mode emulated targets, I'd > be glad to have some comments about it to figure if it seems safe to be > commited or if some rework will be needed. > > Thanks by advance. Hello, I'm new but FWIW your changes look fine to me. Recently while trying out the sparc64 user emulation on a 32bit host I found another similar cause of confusion. I'm not sure if it's a problem in reality but I thought I'd mention it for the record. target_mmap currently returns a long, but most of it's callers seem to assign the returned address to a target_ulong (elfload.c) or to a target_long (syscall.c). On my particular build (64bit target and 32bit host) the address returned by the host mmap was sign-extended when assigned to a target_ulong. For example, if the host returns 0x80000000, the 64bit address ended up beeing 0xffffffff80000000. I assumed this was intentional to simplify the catching of the -1 failure code. Not sure if it's a problem, but it confused me at least. I would have expected target_mmap to return a target_long, and that it internally would conditionally sign extend the hosts mmap return value only if it was -1. This would make it easy for the callers to check for errors while preserving valid addresses through zero-extension. Does this make any sense? Best regards -- Edgar E. Iglesias Axis Communications AB