This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch i386]: Expand sibling-tail-calls via accumulator register

Hi Kai,

this patch also mis-compiles binuitls-2.24 on x86_64.

In the function walk_wild_consider_section (ld/ldlang.c)
a tail-call gets miscompiled:

The stack frame is cleaned up, but now the jump target is invalid.

   0x000000000040c801 <+193>:    add    $0x28,%rsp
   0x000000000040c805 <+197>:    mov    %r13,%rsi
   0x000000000040c808 <+200>:    pop    %rbx
   0x000000000040c809 <+201>:    mov    %r14,%rdi
   0x000000000040c80c <+204>:    pop    %rbp
   0x000000000040c80d <+205>:    pop    %r12
   0x000000000040c80f <+207>:    pop    %r13
   0x000000000040c811 <+209>:    pop    %r14
   0x000000000040c813 <+211>:    pop    %r15
   0x000000000040c815 <+213>:    jmpq   *0x10(%rsp)

before the patch the sequence did save the jump target in rax:

   0x000000000040c801 <+193>:    mov    0x10(%rsp),%rax
   0x000000000040c806 <+198>:    add    $0x28,%rsp
   0x000000000040c80a <+202>:    pop    %rbx
   0x000000000040c80b <+203>:    mov    %r13,%rsi
   0x000000000040c80e <+206>:    mov    %r14,%rdi
   0x000000000040c811 <+209>:    pop    %rbp
   0x000000000040c812 <+210>:    pop    %r12
   0x000000000040c814 <+212>:    pop    %r13
   0x000000000040c816 <+214>:    pop    %r14
   0x000000000040c818 <+216>:    pop    %r15
   0x000000000040c81a <+218>:    jmpq   *%rax


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]