This is the mail archive of the
mailing list for the GCC project.
[semi PATCH] ARM/Thumb branches out of range for MI thunks
- From: Phil Edwards <phil at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: rearnsha at arm dot com
- Date: Thu, 23 Oct 2003 19:21:28 -0400
- Subject: [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
[add/sub offset for 'this']
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.
RCS file: /home/pme/Repositories/GCC/gcc/gcc/config/arm/arm.c,v
retrieving revision 1.301
diff -u -p -r1.301 arm.c
--- gcc/config/arm/arm.c 21 Oct 2003 01:56:49 -0000 1.301
+++ gcc/config/arm/arm.c 23 Oct 2003 23:19:40 -0000
@@ -13043,7 +13043,10 @@ arm_output_mi_thunk (FILE *file, tree th
shift += 8;
- fputs ("\tb\t", file);
+ if (TARGET_THUMB)
+ fputs ("\tbl\t", file);
+ fputs ("\tb\t", file);
assemble_name (file, XSTR (XEXP (DECL_RTL (function), 0), 0));
fputs ("(PLT)", file);