This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [semi PATCH] ARM/Thumb branches out of range for MI thunks
- From: Richard Earnshaw <rearnsha at arm dot com>
- To: Phil Edwards <phil at codesourcery dot com>
- Cc: gcc-patches at gcc dot gnu dot org, rearnsha at arm dot com
- Date: Fri, 24 Oct 2003 09:31:53 +0100
- Subject: Re: [semi PATCH] ARM/Thumb branches out of range for MI thunks
- Organization: ARM Ltd.
- Reply-to: Richard dot Earnshaw at arm dot com
> 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.