Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1CAFVI-00074k-QR for qemu-devel@nongnu.org; Wed, 22 Sep 2004 18:22:24 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1CAFVG-00073z-Q5 for qemu-devel@nongnu.org; Wed, 22 Sep 2004 18:22:24 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CAFVG-00073p-Lr for qemu-devel@nongnu.org; Wed, 22 Sep 2004 18:22:22 -0400 Received: from [81.104.201.223] (helo=cray) by monty-python.gnu.org with esmtp (Exim 4.34) id 1CAFP4-0000jy-PI for qemu-devel@nongnu.org; Wed, 22 Sep 2004 18:15:59 -0400 Received: from cgb23 by cray with local (Exim 3.36 #1 (Debian)) id 1CAFPs-0002L2-00 for ; Wed, 22 Sep 2004 23:16:48 +0100 Date: Wed, 22 Sep 2004 23:16:48 +0100 From: cb-qemu@fish.zetnet.co.uk Message-ID: <20040922221648.GD11336@cray.fish.zetnet.co.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Sender: Charlie Baylis Subject: [Qemu-devel] linux-user/mmap.c query 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 Hi Fabrice and everyone I'm trying to use qemu-arm to run some statically linked linux binaries, and I've come across an issue with the target_mmap function. The test at line 185: if (offset & ~TARGET_PAGE_MASK) return -EINVAL; seems to be unnecessary as there is code to handle a non-aligned offset later on in the function which is introduced by the comment /* worst case: we cannot map the file because the offset is not aligned, so we read it */ In addition, there seems to be an inconsistency in the way errors are reported from target_mmap and what is expected by linux-user/elfload.c. target_mmap() returns -EINVAL, but elfload.c expects errors to be reported with -1 and errno to be set. The following (totally minimal) patch enables me to run a few simple statically linked ARM binaries. (This is just to make it clear the change I am talking about). Once this is addressed I run into problems with binaries which execute code from writable pages - the code pages are marked non-writable by tb_link_phys() but segfaults arising from writes are not handled. I haven't fully investigated this problem yet. Is this supposed to work? I'll try and create a test case if I don't make any progress on this. BTW, is it possible to run qemu-arm under gdb and get breakpoints working? When I try, gdb complains because the qemu binary is remapped somewhere else in the addres space. Regards Charlie --- linux-user/mmap.c 5 Jul 2004 21:25:16 -0000 1.7 +++ linux-user/mmap.c 22 Sep 2004 20:18:53 -0000 @@ -182,7 +182,7 @@ } #endif - if (offset & ~TARGET_PAGE_MASK) + if (offset & ~TARGET_PAGE_MASK && 0) return -EINVAL; len = TARGET_PAGE_ALIGN(len);