aboutsummaryrefslogtreecommitdiff
path: root/linux-user/elfload.c
diff options
context:
space:
mode:
authorPaul Brook <paul@codesourcery.com>2009-07-17 12:48:08 +0100
committerPaul Brook <paul@codesourcery.com>2009-07-17 13:12:41 +0100
commit379f6698d73f476de38682b3ff96ecb226728c43 (patch)
tree35ec0c77416322f16fa27d646af50c60363168e3 /linux-user/elfload.c
parenta9ff9df188615d653a5a904bafbe724d40143e35 (diff)
Userspace guest address offsetting
Re-implement GUEST_BASE support. Offset guest ddress space by default if the guest binary contains regions below the host mmap_min_addr. Implement support for i386, x86-64 and arm hosts. Signed-off-by: Riku Voipio <riku.voipio@iki.fi> Signed-off-by: Paul Brook <paul@codesourcery.com>
Diffstat (limited to 'linux-user/elfload.c')
-rw-r--r--linux-user/elfload.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index d31cca71d1..d4c9274206 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -1545,6 +1545,29 @@ int load_elf_binary(struct linux_binprm * bprm, struct target_pt_regs * regs,
info->mmap = 0;
elf_entry = (abi_ulong) elf_ex.e_entry;
+#if defined(CONFIG_USE_GUEST_BASE)
+ /*
+ * In case where user has not explicitly set the guest_base, we
+ * probe here that should we set it automatically.
+ */
+ if (!have_guest_base) {
+ /*
+ * Go through ELF program header table and find out whether
+ * any of the segments drop below our current mmap_min_addr and
+ * in that case set guest_base to corresponding address.
+ */
+ for (i = 0, elf_ppnt = elf_phdata; i < elf_ex.e_phnum;
+ i++, elf_ppnt++) {
+ if (elf_ppnt->p_type != PT_LOAD)
+ continue;
+ if (HOST_PAGE_ALIGN(elf_ppnt->p_vaddr) < mmap_min_addr) {
+ guest_base = HOST_PAGE_ALIGN(mmap_min_addr);
+ break;
+ }
+ }
+ }
+#endif /* CONFIG_USE_GUEST_BASE */
+
/* Do this so that we can load the interpreter, if need be. We will
change some of these later */
info->rss = 0;