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: [semi PATCH] ARM/Thumb branches out of range for MI thunks


> While building some C++ libraries for ARM/Thumb, we started seeing "branch
> out of range" errors from the assembler in thunk code, of the form
> 
>      thunk_for_realfunc:
>        [add/sub offset for 'this']
>        b   realfunc
> 
> Under -mthumb, the unconditional branch only has a small range, and
> config/arm/arm.c:arm_output_mi_thunk isn't Thumb-aware.
> 
> Elsewhere the 'bl' instruction was being used for unconditional branches.
> Since under Thumb it's magically decomposed into multiple fixups, it has
> a much longer range.
> 
> The patch below lets the libraries build.  It's almost certainly got a
> problem, though, because the additional "and link" semantics is hosing
> the return address of realfunc.  (I expect.)
> 
> Possibly an alternative would be to compose the address of realfunc in
> a register, and then use 'blx rN'.  That might have the same problem,
> in that it's another form of bl.
> 
> Anyone have suggestions on how to deal with this problem?  The bug is
> present in both 3.3 and the trunk.
> 

Yes.  Output the Thunk in ARM code (seriously, this is one of those cases 
where you get better code density in ARM state than you can in Thumb).  
But to do that, the C++ front end needs fixing so that we can get hold of 
the thunk properly in the back end and control how it outputs the thunk 
definition.

I've posted on this before.

R.


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