On 8/2/25 02:17, Peter Maydell wrote:
-static inline void init_thread(struct target_pt_regs *regs,
- struct image_info *infop)
-{
- regs->esp = infop->start_stack;
- regs->eip = infop->entry;
-
- /* SVR4/i386 ABI (pages 3-31, 3-32) says that when the program
- starts %edx contains a pointer to a function which might be
- registered using `atexit'. This provides a mean for the
- dynamic linker to call DT_FINI functions for shared libraries
- that have been loaded before the code runs.
-
- A value of 0 tells we have no such handler. */
This seems like a useful comment to retain -- it's nice
to know whether we're zeroing a register as an ABI requirement
versus just being tidy.
Fair.
+ memset(env->regs, 0, sizeof(env->regs));
Are we not allowed to assume the regs are zero out of reset ?
For whatever reason, x86 doesn't do that.
Eliding this line causes failures.
I think the SVR4 comment applies to x86_64 as well. Yep, glibc/sysdeps/x86_64/start.S
contains the same comment, although the linux kernel source does not. The kernel simply
zeros all registers regardless of normal (x64) vs compat (x32).
I'll move the one comment and expand it.
r~