X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=linux-user%2Fflatload.c;h=c9f1acd55fa1055d7a203b66c7a3bc4e19488ca2;hb=c35734b2a6f9b028edacd5813ff271728ce2a9e3;hp=1e2634b5a274df42cc46f610ac07ea7cd685e059;hpb=e5fe0c5230cc7780de852cefb5df57e05e2c613e;p=qemu diff --git a/linux-user/flatload.c b/linux-user/flatload.c index 1e2634b..c9f1acd 100644 --- a/linux-user/flatload.c +++ b/linux-user/flatload.c @@ -752,10 +752,17 @@ int load_flt_binary(struct linux_binprm * bprm, struct target_pt_regs * regs, DBG_FLT("p=%x\n", (int)p); /* Copy argv/envp. */ - p = copy_strings(p, bprm->argc, bprm->argv); p = copy_strings(p, bprm->envc, bprm->envp); + 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 @@ -783,6 +790,9 @@ int load_flt_binary(struct linux_binprm * bprm, struct target_pt_regs * regs, info->start_brk = libinfo[0].start_brk; info->start_stack = sp; info->entry = start_addr; + info->code_offset = info->start_code; + info->data_offset = info->start_data - libinfo[0].text_len; + DBG_FLT("start_thread(entry=0x%x, start_stack=0x%x)\n", (int)info->entry, (int)info->start_stack);