diff options
author | Max Filippov <jcmvbkbc@gmail.com> | 2018-10-23 19:30:02 -0700 |
---|---|---|
committer | Max Filippov <jcmvbkbc@gmail.com> | 2018-10-30 11:23:32 -0700 |
commit | 5c76d652ab567a230f2ef0022b7ea5acb693e19c (patch) | |
tree | f6f33897d598f177feaf88fdd68e578d523cbb92 /linux-user | |
parent | 02e33e9ffd6056657e6f82ee7b942c3bc8060cbe (diff) |
linux-user/flatload: fix initial stack pointer alignment
Stack pointer alignment code incorrectly adds stack_size to sp instead
of subtracting it. It also does not take flat_argvp_envp_on_stack() into
account when calculating stack_size. This results in initial stack
pointer misalignment with certain set of command line arguments and
environment variables and correct alignment for the same binary with a
different set of arguments. This misalignment causes failures in the
following tests in the testsuite of gcc built for xtensa uclinux:
gcc.dg/torture/vshuf-v64qi.c
gcc.dg/torture/vshuf-v8sf.c
gcc.dg/torture/vshuf-v8si.c
Reviewed-by: Laurent Vivier <lvivier@redhat.com>
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Diffstat (limited to 'linux-user')
-rw-r--r-- | linux-user/flatload.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/linux-user/flatload.c b/linux-user/flatload.c index 2eefe55e50..0122ab3afe 100644 --- a/linux-user/flatload.c +++ b/linux-user/flatload.c @@ -771,10 +771,10 @@ int load_flt_binary(struct linux_binprm *bprm, struct image_info *info) /* Enforce final stack alignment of 16 bytes. This is sufficient for all current targets, and excess alignment is harmless. */ stack_len = bprm->envc + bprm->argc + 2; - stack_len += 3; /* argc, arvg, argp */ + stack_len += flat_argvp_envp_on_stack() ? 2 : 0; /* arvg, argp */ + stack_len += 1; /* argc */ stack_len *= sizeof(abi_ulong); - if ((sp + stack_len) & 15) - sp -= 16 - ((sp + stack_len) & 15); + sp -= (sp - stack_len) & 15; sp = loader_build_argptr(bprm->envc, bprm->argc, sp, p, flat_argvp_envp_on_stack()); |