Commit b35d7448b1d27a77bc6f59acc697710d5bd3823c
1 parent
bd967e05
Align stack when loading bFLT binaries.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2478 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
7 additions
and
0 deletions
linux-user/flatload.c
... | ... | @@ -756,6 +756,13 @@ int load_flt_binary(struct linux_binprm * bprm, struct target_pt_regs * regs, |
756 | 756 | p = copy_strings(p, bprm->argc, bprm->argv); |
757 | 757 | /* Align stack. */ |
758 | 758 | sp = p & ~(target_ulong)(sizeof(target_ulong) - 1); |
759 | + /* Enforce final stack alignment of 16 bytes. This is sufficient | |
760 | + for all current targets, and excess alignment is harmless. */ | |
761 | + stack_len = bprm->envc + bprm->argc + 2; | |
762 | + stack_len += 3; /* argc, arvg, argp */ | |
763 | + stack_len *= sizeof(target_ulong); | |
764 | + if ((sp + stack_len) & 15) | |
765 | + sp -= 16 - ((sp + stack_len) & 15); | |
759 | 766 | sp = loader_build_argptr(bprm->envc, bprm->argc, sp, p, 1); |
760 | 767 | |
761 | 768 | /* Fake some return addresses to ensure the call chain will | ... | ... |