deadwood2 / AROS

https://www.axrt.org
Other
54 stars 6 forks source link

inlines for x86_64 miscompile with -fomit-frame-pointer #173

Open deadwood2 opened 5 days ago

deadwood2 commented 5 days ago

"Yes, it seems likely that the current code requires a base pointer. In the current implementation I believe that the function pointer is stored in a local variable and then passed to the assembler code, and if there is no base pointer the compiler uses the stack pointer to access local variables."

Dump of assembler code for function __inline_Exec_AllocMem:
   0x0000000049ae65b8 <+0>:    push   %r13
   0x0000000049ae65ba <+2>:    push   %r12
   0x0000000049ae65bc <+4>:    sub    $0x38,%rsp
   0x0000000049ae65c0 <+8>:    mov    %rdi,0x10(%rsp)
   0x0000000049ae65c5 <+13>:    mov    %esi,0xc(%rsp)
   0x0000000049ae65c9 <+17>:    mov    %rdx,(%rsp)
   0x0000000049ae65cd <+21>:    mov    (%rsp),%rax
   0x0000000049ae65d1 <+25>:    mov    %rax,0x20(%rsp)
   0x0000000049ae65d6 <+30>:    mov    0x20(%rsp),%rax
   0x0000000049ae65db <+35>:    sub    $0x108,%rax
   0x0000000049ae65e1 <+41>:    mov    (%rax),%rax
   0x0000000049ae65e4 <+44>:    mov    %rax,0x30(%rsp)
   0x0000000049ae65e9 <+49>:    mov    0x10(%rsp),%rdi
   0x0000000049ae65ee <+54>:    mov    0xc(%rsp),%eax
   0x0000000049ae65f2 <+58>:    mov    %rax,%rsi
   0x0000000049ae65f5 <+61>:    mov    %rsi,%rax
   0x0000000049ae65f8 <+64>:    mov    %eax,%eax
   0x0000000049ae65fa <+66>:    mov    %rax,%rsi
   0x0000000049ae65fd <+69>:    push   %r12
   0x0000000049ae65ff <+71>:    push   %r13
   0x0000000049ae6601 <+73>:    mov    0x20(%rsp),%r12
   0x0000000049ae6606 <+78>:    mov    %rsp,%r13
   0x0000000049ae6609 <+81>:    and    $0xfffffffffffffff0,%rsp
   0x0000000049ae660d <+85>:    call   *0x30(%rsp)
=> 0x0000000049ae6611 <+89>:    mov    %r13,%rsp
   0x0000000049ae6614 <+92>:    pop    %r13
   0x0000000049ae6616 <+94>:    pop    %r12
   0x0000000049ae6618 <+96>:    mov    %rax,0x28(%rsp)
   0x0000000049ae661d <+101>:    mov    0x28(%rsp),%rax
   0x0000000049ae6622 <+106>:    add    $0x38,%rsp
   0x0000000049ae6626 <+110>:    pop    %r12
   0x0000000049ae6628 <+112>:    pop    %r13
   0x0000000049ae662a <+114>:    ret    
deadwood2 commented 1 day ago

Fix for functions with only register arguments: 8b96c752bf2733f7b2303b1155c02a1e287bb354