diff options
author | Timothy E Baldwin <T.E.Baldwin99@members.leeds.ac.uk> | 2020-07-28 23:46:15 +0100 |
---|---|---|
committer | Laurent Vivier <laurent@vivier.eu> | 2020-09-05 22:51:07 +0200 |
commit | 8a0451886824fb266fbdcd1ca01d6acb023e3e09 (patch) | |
tree | 0e81e0ca54c6c11266da2053769a63d0038df83a /linux-user/elfload.c | |
parent | e5ce9688b47a8f60337ce1e4108f35577494a46a (diff) | |
download | qemu-8a0451886824fb266fbdcd1ca01d6acb023e3e09.zip qemu-8a0451886824fb266fbdcd1ca01d6acb023e3e09.tar.gz qemu-8a0451886824fb266fbdcd1ca01d6acb023e3e09.tar.bz2 |
linux-user: Correctly start brk after executable
info->brk was erroneously set to the end of highest addressed
writable segment which could result it in overlapping the executable.
As per load_elf_binary in fs/binfmt_elf.c in Linux, it should be
set to end of highest addressed segment.
Signed-off-by: Timothy E Baldwin <T.E.Baldwin99@members.leeds.ac.uk>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20200728224615.326675-1-T.E.Baldwin99@members.leeds.ac.uk>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Diffstat (limited to 'linux-user/elfload.c')
-rw-r--r-- | linux-user/elfload.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 04c28cb..4961e61 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -2580,9 +2580,9 @@ static void load_elf_image(const char *image_name, int image_fd, if (vaddr_ef > info->end_data) { info->end_data = vaddr_ef; } - if (vaddr_em > info->brk) { - info->brk = vaddr_em; - } + } + if (vaddr_em > info->brk) { + info->brk = vaddr_em; } } else if (eppnt->p_type == PT_INTERP && pinterp_name) { char *interp_name; @@ -2637,7 +2637,6 @@ static void load_elf_image(const char *image_name, int image_fd, if (info->end_data == 0) { info->start_data = info->end_code; info->end_data = info->end_code; - info->brk = info->end_code; } if (qemu_log_enabled()) { |