aboutsummaryrefslogtreecommitdiff
path: root/linux-user/flatload.c
diff options
context:
space:
mode:
authorpbrook <pbrook@c046a42c-6fe2-441c-8c8c-71466251a162>2007-03-15 21:56:07 +0000
committerpbrook <pbrook@c046a42c-6fe2-441c-8c8c-71466251a162>2007-03-15 21:56:07 +0000
commitb35d7448b1d27a77bc6f59acc697710d5bd3823c (patch)
tree453edcbd611b995d83722c748756ddbd4c9ddfb1 /linux-user/flatload.c
parentbd967e05da8cbb2c863b0c75632530966cafcc11 (diff)
Align stack when loading bFLT binaries.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2478 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'linux-user/flatload.c')
-rw-r--r--linux-user/flatload.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/linux-user/flatload.c b/linux-user/flatload.c
index 7e3296e5aa..c9f1acd55f 100644
--- a/linux-user/flatload.c
+++ b/linux-user/flatload.c
@@ -756,6 +756,13 @@ int load_flt_binary(struct linux_binprm * bprm, struct target_pt_regs * regs,
p = copy_strings(p, bprm->argc, bprm->argv);
/* Align stack. */
sp = p & ~(target_ulong)(sizeof(target_ulong) - 1);
+ /* 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 *= sizeof(target_ulong);
+ if ((sp + stack_len) & 15)
+ sp -= 16 - ((sp + stack_len) & 15);
sp = loader_build_argptr(bprm->envc, bprm->argc, sp, p, 1);
/* Fake some return addresses to ensure the call chain will