Patchwork [07/10] flatload: fix bss clearing

login
register
mail settings
Submitter Peter Maydell
Date Aug. 14, 2012, 9:40 a.m.
Message ID <1344937236-611-8-git-send-email-peter.maydell@linaro.org>
Download mbox | patch
Permalink /patch/177204/
State New
Headers show

Comments

Peter Maydell - Aug. 14, 2012, 9:40 a.m.
From: Mike Frysinger <vapier@gentoo.org>

The current bss clear logic assumes the target mmap address and host
address are the same.  Use g2h to translate from the target address
space to the host so we can call memset on it.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 linux-user/flatload.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch

diff --git a/linux-user/flatload.c b/linux-user/flatload.c
index be79496..58f679e 100644
--- a/linux-user/flatload.c
+++ b/linux-user/flatload.c
@@ -660,7 +660,7 @@  static int load_flat_file(struct linux_binprm * bprm,
     }
 
     /* zero the BSS.  */
-    memset((void *)((unsigned long)datapos + data_len), 0, bss_len);
+    memset(g2h(datapos + data_len), 0, bss_len);
 
     return 0;
 }