All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thiemo Seufer <ths@networkno.de>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] Fix userland ELF load failure when no .bss is present
Date: Tue, 12 Dec 2006 18:38:49 +0000	[thread overview]
Message-ID: <20061212183849.GI21819@networkno.de> (raw)

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);

                 reply	other threads:[~2006-12-12 18:45 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20061212183849.GI21819@networkno.de \
    --to=ths@networkno.de \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.