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

[Bug target/14202] New: [arm] Thumb __builtin_setjmp not interworking safe


There are two problems.  The first is simple, indirect jumps don't use bx.
arm_indirect_jump and thumb_indirect_jump are the only affected patterns,
the "fix" is obvious.

The second is triggered by that fix.  __builtin_setjmp works by saving
the address of a label, and later jumping to it in __builtin_longjmp.
The label has its low bit clear; if I fix the arm_indirect_jump to use bx, then
the bx will set us back into ARM mode.

So if the exception is thrown from ARM code and caught in Thumb code, we'll get
illegal instructions all over the place when we return to the Thumb code.  With
the use of bx this is probably true for exceptions within Thumb code also.

The obvious thing to do would be to mark the low bit of the label.  I couldn't
make gas do it; it explicitly rejects .thumb_func for local labels.  If I use
.thumb_set then it looks like the result will work, but the label becomes a symbol
and clutters up disassembly.

An alternative would be to explicitly or the lower bit of the label.  It could be
done at runtime in builtin_setjmp_setup or at compiletime by emitting
  .word L12 + 1
instead of
  .word L12
which would require a change to expand_builtin_setjmp.

Here's the trivial testcase I've been using.

int main ()
{
  try {
    throw 1;
  }
  catch (int)
    { return 0; }
  catch (...)
    { return 0; }
  return 1;
}

-- 
           Summary: [arm] Thumb __builtin_setjmp not interworking safe
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: drow at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: arm-elf


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14202


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