aboutsummaryrefslogtreecommitdiff
path: root/linux-user/flatload.c
diff options
context:
space:
mode:
authorAlex Bennée <alex.bennee@linaro.org>2020-05-13 18:51:28 +0100
committerAlex Bennée <alex.bennee@linaro.org>2020-05-15 15:25:16 +0100
commitee94743034bfb443cf246eda4971bdc15d8ee066 (patch)
tree42d6c1c175513e4fc990511bced2cd62bb78caaa /linux-user/flatload.c
parentaae8b87e9c1658261f6c58ded9928d9ed24bdbef (diff)
downloadqemu-ee94743034bfb443cf246eda4971bdc15d8ee066.zip
qemu-ee94743034bfb443cf246eda4971bdc15d8ee066.tar.gz
qemu-ee94743034bfb443cf246eda4971bdc15d8ee066.tar.bz2
linux-user: completely re-write init_guest_space
First we ensure all guest space initialisation logic comes through probe_guest_base once we understand the nature of the binary we are loading. The convoluted init_guest_space routine is removed and replaced with a number of pgb_* helpers which are called depending on what requirements we have when loading the binary. We first try to do what is requested by the host. Failing that we try and satisfy the guest requested base address. If all those options fail we fall back to finding a space in the memory map using our recently written read_self_maps() helper. There are some additional complications we try and take into account when looking for holes in the address space. We try not to go directly after the system brk() space so there is space for a little growth. We also don't want to have to use negative offsets which would result in slightly less efficient code on x86 when it's unable to use the segment offset register. Less mind-binding gotos and hopefully clearer logic throughout. Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Acked-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <20200513175134.19619-5-alex.bennee@linaro.org>
Diffstat (limited to 'linux-user/flatload.c')
-rw-r--r--linux-user/flatload.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/linux-user/flatload.c b/linux-user/flatload.c
index 66901f3..8fb448f 100644
--- a/linux-user/flatload.c
+++ b/linux-user/flatload.c
@@ -442,6 +442,12 @@ static int load_flat_file(struct linux_binprm * bprm,
indx_len = (indx_len + 15) & ~(abi_ulong)15;
/*
+ * Alloate the address space.
+ */
+ probe_guest_base(bprm->filename, 0,
+ text_len + data_len + extra + indx_len);
+
+ /*
* there are a couple of cases here, the separate code/data
* case, and then the fully copied to RAM case which lumps
* it all together.