Revision 60dcbcb5
b/linux-user/elfload.c | ||
---|---|---|
1002 | 1002 |
static abi_ulong setup_arg_pages(abi_ulong p, struct linux_binprm *bprm, |
1003 | 1003 |
struct image_info *info) |
1004 | 1004 |
{ |
1005 |
abi_ulong stack_base, size, error; |
|
1005 |
abi_ulong stack_base, size, error, guard;
|
|
1006 | 1006 |
int i; |
1007 | 1007 |
|
1008 | 1008 |
/* Create enough stack to hold everything. If we don't use |
1009 |
* it for args, we'll use it for something else... |
|
1010 |
*/ |
|
1009 |
it for args, we'll use it for something else. */ |
|
1011 | 1010 |
size = guest_stack_size; |
1012 |
if (size < MAX_ARG_PAGES*TARGET_PAGE_SIZE) |
|
1011 |
if (size < MAX_ARG_PAGES*TARGET_PAGE_SIZE) {
|
|
1013 | 1012 |
size = MAX_ARG_PAGES*TARGET_PAGE_SIZE; |
1014 |
error = target_mmap(0, |
|
1015 |
size + qemu_host_page_size, |
|
1016 |
PROT_READ | PROT_WRITE, |
|
1017 |
MAP_PRIVATE | MAP_ANONYMOUS, |
|
1018 |
-1, 0); |
|
1013 |
} |
|
1014 |
guard = TARGET_PAGE_SIZE; |
|
1015 |
if (guard < qemu_real_host_page_size) { |
|
1016 |
guard = qemu_real_host_page_size; |
|
1017 |
} |
|
1018 |
|
|
1019 |
error = target_mmap(0, size + guard, PROT_READ | PROT_WRITE, |
|
1020 |
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); |
|
1019 | 1021 |
if (error == -1) { |
1020 |
perror("stk mmap");
|
|
1022 |
perror("mmap stack");
|
|
1021 | 1023 |
exit(-1); |
1022 | 1024 |
} |
1023 |
/* we reserve one extra page at the top of the stack as guard */ |
|
1024 |
target_mprotect(error + size, qemu_host_page_size, PROT_NONE); |
|
1025 | 1025 |
|
1026 |
info->stack_limit = error; |
|
1027 |
stack_base = error + size - MAX_ARG_PAGES*TARGET_PAGE_SIZE; |
|
1026 |
/* We reserve one extra page at the top of the stack as guard. */ |
|
1027 |
target_mprotect(error, guard, PROT_NONE); |
|
1028 |
|
|
1029 |
info->stack_limit = error + guard; |
|
1030 |
stack_base = info->stack_limit + size - MAX_ARG_PAGES*TARGET_PAGE_SIZE; |
|
1028 | 1031 |
p += stack_base; |
1029 | 1032 |
|
1030 | 1033 |
for (i = 0 ; i < MAX_ARG_PAGES ; i++) { |
Also available in: Unified diff