summaryrefslogtreecommitdiff
path: root/linux-user
diff options
context:
space:
mode:
authorths <ths@c046a42c-6fe2-441c-8c8c-71466251a162>2006-12-14 13:32:11 +0000
committerths <ths@c046a42c-6fe2-441c-8c8c-71466251a162>2006-12-14 13:32:11 +0000
commit768a4a36a444ef5aef1f103adf42553eadfe4614 (patch)
tree52e5b4ff93fb9173b575be8fa590d9c3b9942e4c /linux-user
parent0d3267a728ee392bd5113b1d9ad3b135565012e3 (diff)
downloadqemu-768a4a36a444ef5aef1f103adf42553eadfe4614.zip
Fix userland ELF loader for zero sized BSS.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2244 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'linux-user')
-rw-r--r--linux-user/elfload.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index 042c65dc7a..c0ea5a0125 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -553,10 +553,13 @@ static void set_brk(unsigned long start, unsigned long end)
/* 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 @@ static unsigned long load_elf_interp(struct elfhdr * interp_elf_ex,
* 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 @@ int load_elf_binary(struct linux_binprm * bprm, struct target_pt_regs * regs,
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);