On Sat, Jan 6, 2024 at 9:45 PM Samuel Thibault <samuel.thiba...@gnu.org> wrote: > > Luca, le sam. 06 janv. 2024 19:41:17 +0100, a ecrit: > > Il 29/12/23 15:14, Luca Dariz ha scritto: > > > Il 29/12/23 14:44, Samuel Thibault ha scritto: > > > > Also, it would be useful to compile the tests with > > > > -ftrivial-auto-var-init=pattern so as to fill the structures with random > > > > values before making the gnumach calls. > > > > with this option all tests fail on the first mig-generated stub entry, which > > is task_get_special_port(), in _start(). Maybe it's related to SSE somehow, > > I see a page fault here: > > Is $rbp unaligned? > > (we do want to fix such bug anyway) > > > (gdb) disassemble task_get_special_port > > Dump of assembler code for function task_get_special_port: > > 0x0000000000416bc6 <+0>: push %rbp > > 0x0000000000416bc7 <+1>: mov %rsp,%rbp > > 0x0000000000416bca <+4>: sub $0xa0,%rsp > > 0x0000000000416bd1 <+11>: mov %edi,-0x94(%rbp) > > 0x0000000000416bd7 <+17>: mov %esi,-0x98(%rbp) > > 0x0000000000416bdd <+23>: mov %rdx,-0xa0(%rbp) > > 0x0000000000416be4 <+30>: lea -0x60(%rbp),%rax > > 0x0000000000416be8 <+34>: movdqa 0x124f0(%rip),%xmm0 # 0x4290e0 > > => 0x0000000000416bf0 <+42>: movaps %xmm0,(%rax) > > 0x0000000000416bf3 <+45>: movaps %xmm0,0x10(%rax)
Yes, you have to align the stack. An executable gets entered at _start (or whatever the ELF header specifies) with %rsp 16-aligned, but you must enter C code with %rsp being 8 modulo 8. To fix this, change your _start like so: asm(".global _start\n" "_start:\n" " callq c_start"); void __attribute__((used, retain)) c_start() { ... } This is only required on x86_64 (among the three architectures we care about for now). Sergey