public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/14202] New: [arm] Thumb __builtin_setjmp not interworking safe
@ 2004-02-18 23:05 drow at gcc dot gnu dot org
  2004-02-19  0:15 ` [Bug target/14202] " drow at gcc dot gnu dot org
                   ` (8 more replies)
  0 siblings, 9 replies; 20+ messages in thread
From: drow at gcc dot gnu dot org @ 2004-02-18 23:05 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 20+ messages in thread
[parent not found: <bug-14202-3264@http.gcc.gnu.org/bugzilla/>]
[parent not found: <bug-14202-4@http.gcc.gnu.org/bugzilla/>]

end of thread, other threads:[~2012-09-24 16:12 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-02-18 23:05 [Bug target/14202] New: [arm] Thumb __builtin_setjmp not interworking safe drow at gcc dot gnu dot org
2004-02-19  0:15 ` [Bug target/14202] " drow at gcc dot gnu dot org
2004-02-19  1:23 ` pinskia at gcc dot gnu dot org
2004-02-19 12:01 ` rearnsha at gcc dot gnu dot org
2004-02-19 12:02 ` rearnsha at gcc dot gnu dot org
2004-02-19 14:56 ` drow at gcc dot gnu dot org
2004-02-19 15:30   ` Richard Earnshaw
2004-02-19 15:30 ` rearnsha at arm dot com
2004-02-19 17:51 ` drow at gcc dot gnu dot org
2004-10-11 10:57 ` giovannibajo at libero dot it
2005-07-02  1:31 ` pinskia at gcc dot gnu dot org
     [not found] <bug-14202-3264@http.gcc.gnu.org/bugzilla/>
2009-01-02 12:26 ` laurent at guerby dot net
2009-01-05 17:52 ` rearnsha at gcc dot gnu dot org
2009-01-05 18:34 ` drow at gcc dot gnu dot org
2009-04-03 23:27 ` ramana at gcc dot gnu dot org
2009-04-09 11:31 ` ramana at gcc dot gnu dot org
2009-04-17 11:08 ` ramana at gcc dot gnu dot org
2009-10-26 11:37 ` ramana at gcc dot gnu dot org
     [not found] <bug-14202-4@http.gcc.gnu.org/bugzilla/>
2012-09-23 22:00 ` pinskia at gcc dot gnu.org
2012-09-24 16:12 ` drow at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).