Sergey Bugaev, le sam. 18 févr. 2023 23:37:15 +0300, a ecrit: > Signed-off-by: Sergey Bugaev <buga...@gmail.com> > --- > sysdeps/mach/hurd/{i386 => x86}/init-first.c | 17 ++++++++++++++--- > 1 file changed, 14 insertions(+), 3 deletions(-) > rename sysdeps/mach/hurd/{i386 => x86}/init-first.c (96%) > > diff --git a/sysdeps/mach/hurd/i386/init-first.c > b/sysdeps/mach/hurd/x86/init-first.c > similarity index 96% > rename from sysdeps/mach/hurd/i386/init-first.c > rename to sysdeps/mach/hurd/x86/init-first.c > index a558da16..75ac1ff2 100644 > --- a/sysdeps/mach/hurd/i386/init-first.c > +++ b/sysdeps/mach/hurd/x86/init-first.c > @@ -227,10 +227,15 @@ init (int *data) > values we set just above. We have stashed in %eax the user code > return address. Push it on the top of the stack so it acts as > init1's return address, and then jump there. */ > +#ifdef __x86_64__ > +asm ("call_init1:\n" > + " push %rax\n" > + " jmp *%rcx\n"); > +#else > asm ("call_init1:\n" > " push %eax\n" > " jmp *%ecx\n"); > - > +#endif > > /* Do the first essential initializations that must precede all else. */ > static inline void > @@ -242,7 +247,7 @@ first_init (void) > #ifndef SHARED > /* In the static case, we need to set up TLS early so that the stack > protection guard can be read at gs:0x14 by the gcc-generated snippets. > */ > - _hurd_tls_init(&__init1_tcbhead); > + _hurd_tls_init (&__init1_tcbhead); > asm ("movw %%gs,%w0" : "=m" (__init1_desc)); > #endif > > @@ -300,7 +305,7 @@ _hurd_stack_setup (void) > { > /* If we use ``__builtin_frame_address (0) + 2'' here, GCC gets > confused. */ > - init ((int *) &argc); > + init (&argc);
That won't work on x86_64: there, arguments are passed mostly through registers, so &argc won't actually give you the address of arguments on the stack. This can probably be checked on linux x86_64 to make sure how arguments are passed. > } > > /* Push the user return address after the argument data, and then > @@ -308,9 +313,15 @@ _hurd_stack_setup (void) > caller had called `doinit1' with the argument data already on the > stack. */ > *--data = caller; > +# ifdef __x86_64__ > + asm volatile ("movq %0, %%rsp\n" /* Switch to new outermost stack. */ > + "movq $0, %%rbp\n" /* Clear outermost frame pointer. */ > + "jmp *%1" : : "r" (data), "r" (&doinit1)); > +# else > asm volatile ("movl %0, %%esp\n" /* Switch to new outermost stack. */ > "movl $0, %%ebp\n" /* Clear outermost frame pointer. */ > "jmp *%1" : : "r" (data), "r" (&doinit1)); > +# endif > /* NOTREACHED */ > } > > -- > 2.39.2 > > -- Samuel --- Pour une évaluation indépendante, transparente et rigoureuse ! Je soutiens la Commission d'Évaluation de l'Inria.