This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch i386]: Expand sibling-tail-calls via accumulator register
- From: Bernd Edlinger <bernd dot edlinger at hotmail dot de>
- To: Kai Tietz <ktietz at redhat dot com>
- Cc: "H.J. Lu" <hjl dot tools at gmail dot com>, Richard Henderson <rth at redhat dot com>, Jeff Law <law at redhat dot com>, Jakub Jelinek <jakub at redhat dot com>, "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Date: Sat, 31 May 2014 01:07:47 +0200
- Subject: Re: [patch i386]: Expand sibling-tail-calls via accumulator register
- Authentication-results: sourceware.org; auth=none
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
Regards
Bernd.