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>
This commit is contained in:
Timothy E Baldwin 2020-07-28 23:46:15 +01:00 committed by Laurent Vivier
parent e5ce9688b4
commit 8a04518868
1 changed files with 3 additions and 4 deletions

View File

@ -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()) {