Il 06/01/24 20:02, Sergey Bugaev ha scritto:
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()
{
...
}
Uhm, I still have an issue, although a bit different now:
(gdb) disassemble c_start
Dump of assembler code for function c_start:
0x0000000000402ec1 <+0>: push %rbp
0x0000000000402ec2 <+1>: mov %rsp,%rbp
0x0000000000402ec5 <+4>: sub $0x30,%rsp
0x0000000000402ec9 <+8>: movl $0xfefefefe,-0x8(%rbp)
0x0000000000402ed0 <+15>: movl $0xfefefefe,-0xc(%rbp)
0x0000000000402ed7 <+22>: mov %rbp,%rax
0x0000000000402eda <+25>: add $0x8,%rax
0x0000000000402ede <+29>: mov %rax,-0x18(%rbp)
0x0000000000402ee2 <+33>: mov -0x18(%rbp),%rax
0x0000000000402ee6 <+37>: mov %rax,-0x20(%rbp)
0x0000000000402eea <+41>: mov -0x20(%rbp),%rax
0x0000000000402eee <+45>: mov (%rax),%rax
0x0000000000402ef1 <+48>: mov %eax,0x2a111(%rip) #
0x42d008 <argc>
0x0000000000402ef7 <+54>: mov -0x20(%rbp),%rax
0x0000000000402efb <+58>: add $0x8,%rax
0x0000000000402eff <+62>: mov %rax,0x2915a(%rip) #
0x42c060 <argv>
0x0000000000402f06 <+69>: mov 0x29153(%rip),%rax #
0x42c060 <argv>
0x0000000000402f0d <+76>: mov 0x2a0f5(%rip),%edx #
0x42d008 <argc>
0x0000000000402f13 <+82>: movslq %edx,%rdx
0x0000000000402f16 <+85>: add $0x1,%rdx
0x0000000000402f1a <+89>: shl $0x3,%rdx
0x0000000000402f1e <+93>: add %rdx,%rax
0x0000000000402f21 <+96>: mov %rax,0x2a0e8(%rip) #
0x42d010 <envp>
0x0000000000402f28 <+103>: movl $0x0,0x2a0e6(%rip) #
0x42d018 <envc>
0x0000000000402f32 <+113>: jmp 0x402f43 <c_start+130>
0x0000000000402f34 <+115>: mov 0x2a0de(%rip),%eax #
0x42d018 <envc>
0x0000000000402f3a <+121>: add $0x1,%eax
0x0000000000402f3d <+124>: mov %eax,0x2a0d5(%rip) #
0x42d018 <envc>
0x0000000000402f43 <+130>: mov 0x2a0c6(%rip),%rax #
0x42d010 <envp>
0x0000000000402f4a <+137>: mov 0x2a0c8(%rip),%edx #
0x42d018 <envc>
0x0000000000402f50 <+143>: movslq %edx,%rdx
0x0000000000402f53 <+146>: shl $0x3,%rdx
0x0000000000402f57 <+150>: add %rdx,%rax
=> 0x0000000000402f5a <+153>: mov (%rax),%rax
0x0000000000402f5d <+156>: test %rax,%rax
By the way, the exception is still the same (General Protection, which
is usually forwarded to user space), but for a different reason,
apparently a non-canonical address in $rax=0x8000020175c0
Luca