patch for exception handlers in PIC code on ARM

Richard Henderson rth@redhat.com
Mon Jan 15 10:46:00 GMT 2001


[ You seem to only have send the mail to me.  But since you are
  also talking to Phil it is clear you didn't mean to.  So I've
  quoted the text in its entirety in cc'ing it back to gcc-patches.  ]

On Mon, Jan 15, 2001 at 06:34:22PM +0000, Richard Earnshaw wrote:
> > On Mon, Jan 15, 2001 at 10:30:23AM +1100, Fergus Henderson wrote:
> > > But after looking at the code a bit, I see that __builtin_longjmp()/
> > > __builtin_setjmp() do, in combination, implement normal
> > > setjmp()/longjmp() semantics with regard to restoring the
> > > values of ordinary call-saved registers.
> > 
> > Yes, I should perhaps have been clearer about this.
> 
> I haven't had chance to look at the code yet, but I'd be surprised if they 
> got it right for the ARM's hardware floating point registers. Special 
> non-trapping instructions have to be used for this (sfm/lfm or stfe/ldfe 
> in some compilation variants), and currently only the prologue and 
> epilogue code know what to do.  Also longjmp will have to know how to 
> switch to/from Thumb mode in some variants.

But that's exactly why things are done the way they are.

__builtin_longjmp doesn't touch anything it doesn't have to; all saving
and restoring of registers is done by the prologue and epilogue code of
the routine containing the __builtin_setjmp.

> I notice that the testsuite (at least c-torture) is very lacking in 
> builtin_setjmp/longjmp tests: just one, and that only tests that things 
> work in the presence of alloca.  Nothing to test registers (especially fp 
> registers) being handled correctly.  Nothing to test (or potentially test) 
> PIC code.

Yes, more tests would be a good thing.

> > > However, AFAICT all this only applies to ordinary call-saved
> > > registers, not to fixed registers, so I think the back-end's
> > > implementation of builtin_longjmp does need to restore those.
> > 
> > Correct.  Or rather, coordinate with builtin_setjmp_receiver
> > such that they are eventually restored.
> > 
> > > > I wouldn't think the exception_receiver part is, since dwarf2
> > > > does restore call-saved registers during unwinding.
> > > 
> > > Does that apply to fixed_regs?
> > 
> > No, as these are described to the compiler as call-clobbered.
> > Which is a very long-standing representational mistake, but
> > I've not had the guts to fix it.
> > 
> > Normally, however, most non-stack-related fixed registers are
> > call-clobbered, with the common exception being the pic register.
> > 
> 
> Phil, in the light of this, can you commit the parts of your patch that 
> handle sjlj PIC handling, but leave out the parts that alter dwarf2 eh 
> handling.
> 
> R.
> 


r~


More information about the Gcc-patches mailing list