This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: [PATCH] Fix thumb calls via PLT on ARM/SymbianOS
On Wed, 2005-03-16 at 14:42, Daniel Jacobowitz wrote:
> On Wed, Mar 16, 2005 at 02:23:12PM +0000, Richard Earnshaw wrote:
> > On Wed, 2005-03-16 at 14:17, Julian Brown wrote:
> > > Hi,
> > >
> > > This patch fixes calls made from thumb mode via the PLT on SymbianOS.
> > > PLT entries are written in ARM mode, but previously they were being
> > > called in thumb mode, with their address incorrectly offset by -4
> > > (PLT_THUMB_STUB_SIZE).
> > >
> > > Now, the target address has been corrected and the thumb BL instruction
> > > is rewritten as BLX to perform the mode switch before attempting to
> > > execute the PLT entry. (BLX is an armv5t instruction, but as SymbianOS
> > > is only targeted at armv5t+, this should always be OK.)
> > >
> > > The hardwired "4" for the thumb stub size on non-SymbianOS targets has
> > > also been rewritten as PLT_THUMB_STUB_SIZE.
> > >
> > > OK to apply?
> >
> > This sounds like a hack. I'd much rather a generic solution were found
> > (and which permitted the blx optimization if available).
>
> The SymbianOS bits sound generally right to me. The fact that the -4
> bias is currently included is just a bug; that's from the code to
> generate a Thumb header on PLT entries, which is already disabled
> for SymbianOS.
>
I'll have to look at that bit in further detail.
> OTOH, it may be missing some error checks - what if it's _not_ a BL?
> Could we reach here?
>
Possibly. Tail call? Doesn't happen in GCC, but another compiler might
do it.
> Ideally, yes, I want to do this transformation on non-SymbianOS too.
> But, we don't have a clear indicator saying "yes it is save to generate
> blx" yet.
We shouldn't be testing SymbianOS here. We should be testing whether
blx is available. If it is, then use the blx sequence; if not, then use
a further trampoline that switches to ARM state and then jumps to the
PLT. Other code in the initialization sequence can then mark that
symbianos always has blx available.
R.