This is the mail archive of the gcc-patches@gcc.gnu.org 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 for broken thunk on sparc


On Fri, 14 Apr 2006, Eric Botcazou wrote:

It doesn't solve gdb issue, so to me they are absolutely equivalent.
But if you want to have it this way, it's fine with me.

Installed on all active branches. Thanks to both of you.

Few emails back when I said: "... but +68 has a small chance of being clobbered by the signal handler executed in the middle of the thunk."

I've been worried to see this situation:

--------------------------------------------
Breakpoint 2, 0x00010c34 in handler ()
(gdb) bt
#0  0x00010c34 in handler ()
#1  0x00010fac in virtual thunk to C::foo() ()
#2  0x00010fac in virtual thunk to C::foo() ()
Previous frame identical to this frame (corrupt stack?)
(gdb) x/2i $pc
0x10c34 <handler+4>:    st  %i0, [ %fp + 0x44 ]
0x10c38 <handler+8>:    st  %i1, [ %fp + 0x48 ]
(gdb) p $fp+0x44
$1 = (void *) 0xffbfe9bc
(gdb) fr 1
#1  0x00010fac in virtual thunk to C::foo() ()
(gdb) p $sp+0x44
$2 = (void *) 0xffbfe9bc
(gdb) x/10i $pc
0x10fac <_ZTv0_n12_N1C3fooEv+40>:       sethi  %hi(0), %g1
0x10fb0 <_ZTv0_n12_N1C3fooEv+44>:       or  %g1, 8, %g1 ! 0x8
0x10fb4 <_ZTv0_n12_N1C3fooEv+48>:       ld  [ %l7 + %g1 ], %g1
0x10fb8 <_ZTv0_n12_N1C3fooEv+52>:       ld  [ %sp + 0x44 ], %o7
0x10fbc <_ZTv0_n12_N1C3fooEv+56>:       ld  [ %sp + 0x40 ], %l7
0x10fc0 <_ZTv0_n12_N1C3fooEv+60>:       add  %sp, 0x48, %sp
0x10fc4 <_ZTv0_n12_N1C3fooEv+64>:       jmp  %g1

--------------------------------------

That's on Solaris. This dump is from real prog when 'handler' is set via 'syscall (SYS_sigaction,...'. No numbers altered.

So if you trust GDB it's a bug in the submitted patch.
First two insn after 'save' in handler seems to be clobbering
save space of the thunk.

But it turned out that I shouldn't have trusted GDB.
%sp for frame 1 is different than what gdb shows.

So any sort of handlers work fine with the applied patch on Solaris and Linux.

Alex.


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