This is the mail archive of the 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]

[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']
      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.

Index: gcc/config/arm/arm.c
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);
+    fputs ("\tbl\t", file);
+  else
+    fputs ("\tb\t", file);
   assemble_name (file, XSTR (XEXP (DECL_RTL (function), 0), 0));
     fputs ("(PLT)", file);

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