From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GuCcw-0001ZA-Pi for qemu-devel@nongnu.org; Tue, 12 Dec 2006 13:45:19 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GuCce-0001VN-FJ for qemu-devel@nongnu.org; Tue, 12 Dec 2006 13:45:02 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GuCce-0001VK-C7 for qemu-devel@nongnu.org; Tue, 12 Dec 2006 13:45:00 -0500 Received: from [193.7.176.60] (helo=mail.bawue.net) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1GuCce-0005YT-4U for qemu-devel@nongnu.org; Tue, 12 Dec 2006 13:45:00 -0500 Received: from lagash (intrt.mips-uk.com [194.74.144.130]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.bawue.net (Postfix) with ESMTP id 39301B8EB8 for ; Tue, 12 Dec 2006 19:41:02 +0100 (CET) Received: from ths by lagash with local (Exim 4.63) (envelope-from ) id 1GuCWf-0007DG-Do for qemu-devel@nongnu.org; Tue, 12 Dec 2006 18:38:49 +0000 Date: Tue, 12 Dec 2006 18:38:49 +0000 Message-ID: <20061212183849.GI21819@networkno.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline From: Thiemo Seufer Subject: [Qemu-devel] [PATCH] Fix userland ELF load failure when no .bss is present 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 Hello All, the appended patch fixes the case where a ELF Linux binary has a zero-sized .bss, or none at all. Thiemo Index: qemu-work/linux-user/elfload.c =================================================================== --- qemu-work.orig/linux-user/elfload.c 2006-12-12 18:25:00.000000000 +0000 +++ qemu-work/linux-user/elfload.c 2006-12-12 18:33:08.000000000 +0000 @@ -553,10 +553,13 @@ /* We need to explicitly zero any fractional pages after the data section (i.e. bss). This would contain the junk from the file that should not be in memory. */ -static void padzero(unsigned long elf_bss) +static void padzero(unsigned long elf_bss, unsigned long last_bss) { unsigned long nbyte; + if (elf_bss >= last_bss) + return; + /* XXX: this is really a hack : if the real host page size is smaller than the target page size, some pages after the end of the file may not be mapped. A better fix would be to @@ -798,7 +801,7 @@ * that there are zeromapped pages up to and including the last * bss page. */ - padzero(elf_bss); + padzero(elf_bss, last_bss); elf_bss = TARGET_ELF_PAGESTART(elf_bss + qemu_host_page_size - 1); /* What we have mapped so far */ /* Map the last of the bss segment */ @@ -1227,7 +1230,7 @@ sections */ set_brk(elf_bss, elf_brk); - padzero(elf_bss); + padzero(elf_bss, elf_brk); #if 0 printf("(start_brk) %x\n" , info->start_brk);