diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 1d5f651..eaabdac 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -513,12 +513,11 @@ do { \ static inline void init_thread(struct target_pt_regs *_regs, struct image_info *infop) { abi_ulong pos = infop->start_stack; - abi_ulong tmp; #if defined(TARGET_PPC64) && !defined(TARGET_ABI32) abi_ulong entry, toc; #endif - _regs->gpr[1] = infop->start_stack; + _regs->gpr[1] = pos; #if defined(TARGET_PPC64) && !defined(TARGET_ABI32) entry = ldq_raw(infop->entry) + infop->load_addr; toc = ldq_raw(infop->entry + 8) + infop->load_addr; @@ -526,6 +525,8 @@ static inline void init_thread(struct target_pt_regs *_regs, struct image_info * infop->entry = entry; #endif _regs->nip = infop->entry; + +#if defined(CONFIG_BSD) /* Note that isn't exactly what regular kernel does * but this is what the ABI wants and is needed to allow * execution of PPC BSD programs. @@ -534,9 +535,13 @@ static inline void init_thread(struct target_pt_regs *_regs, struct image_info * get_user_ual(_regs->gpr[3], pos); pos += sizeof(abi_ulong); _regs->gpr[4] = pos; - for (tmp = 1; tmp != 0; pos += sizeof(abi_ulong)) - tmp = ldl(pos); + for (;;) { + abi_ulong tmp = pos; + pos += sizeof(abi_ulong); + if (!ldl(tmp)) break; + } _regs->gpr[5] = pos; +#endif } /* See linux kernel: arch/powerpc/include/asm/elf.h. */