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; 11+ 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] 11+ messages in thread
* [Bug target/14202] [arm] Thumb __builtin_setjmp not interworking safe
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 ` drow at gcc dot gnu dot org
2004-02-19 1:23 ` pinskia at gcc dot gnu dot org
` (7 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: drow at gcc dot gnu dot org @ 2004-02-19 0:15 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From drow at gcc dot gnu dot org 2004-02-19 00:15 -------
Created an attachment (id=5768)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=5768&action=view)
Ugly patch for Thumb interworking exceptions
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14202
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/14202] [arm] Thumb __builtin_setjmp not interworking safe
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
` (6 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-02-19 1:23 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
GCC build triplet|i686-pc-linux-gnu |
GCC host triplet|i686-pc-linux-gnu |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14202
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/14202] [arm] Thumb __builtin_setjmp not interworking safe
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
` (5 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: rearnsha at gcc dot gnu dot org @ 2004-02-19 12:01 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From rearnsha at gcc dot gnu dot org 2004-02-19 12:01 -------
I wonder whether it might be better to build unwind-sjlj.c with
DONT_USE_BUILTIN_SETJMP defined. Not only should this fix the second problem
you are seeing, but it also fits in with the EABI philosopy, where only the
system library needs to know exactly which registers are available on the
machine at run time.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14202
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/14202] [arm] Thumb __builtin_setjmp not interworking safe
2004-02-18 23:05 [Bug target/14202] New: [arm] Thumb __builtin_setjmp not interworking safe drow at gcc dot gnu dot org
` (2 preceding siblings ...)
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
` (4 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: rearnsha at gcc dot gnu dot org @ 2004-02-19 12:02 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |rearnsha at gcc dot gnu dot
| |org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14202
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/14202] [arm] Thumb __builtin_setjmp not interworking safe
2004-02-18 23:05 [Bug target/14202] New: [arm] Thumb __builtin_setjmp not interworking safe drow at gcc dot gnu dot org
` (3 preceding siblings ...)
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
` (3 subsequent siblings)
8 siblings, 1 reply; 11+ messages in thread
From: drow at gcc dot gnu dot org @ 2004-02-19 14:56 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From drow at gcc dot gnu dot org 2004-02-19 14:56 -------
Subject: Re: [arm] Thumb __builtin_setjmp not interworking safe
Won't that leave bits of GNAT broken? I think it uses __builtin_setjmp
explicitly.
Also, it has occured to me that my solution does not fix the whole
problem. Normally, emit_indirect_jump is used within a function (for
instance, TRY_FINALLY_EXPR, or computed goto). For those mov pc is
appropriate. But for __builtin_setjmp it isn't. keep_stack_depressed
even has the hideous:
jump_insn = emit_jump_insn (gen_indirect_jump (retaddr));
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14202
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Bug target/14202] [arm] Thumb __builtin_setjmp not interworking safe
2004-02-19 14:56 ` drow at gcc dot gnu dot org
@ 2004-02-19 15:30 ` Richard Earnshaw
0 siblings, 0 replies; 11+ messages in thread
From: Richard Earnshaw @ 2004-02-19 15:30 UTC (permalink / raw)
To: gcc-bugzilla; +Cc: gcc-bugs, Richard Earnshaw
>
> Won't that leave bits of GNAT broken? I think it uses __builtin_setjmp
> explicitly.
>
Possibly, but probably no more broken than it already is if it uses that
routine. How can the compiler know to restore registers it doesn't even
know about? The EABI has been carefully constructed to ensure that it
needed care; but builtin_setjmp breaks that assumption.
The ultimate solution will be to convert the ARM port to use the EABI
exception unwinding model, then most of this should be irrelevant from
that point of view.
R.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/14202] [arm] Thumb __builtin_setjmp not interworking safe
2004-02-18 23:05 [Bug target/14202] New: [arm] Thumb __builtin_setjmp not interworking safe drow at gcc dot gnu dot org
` (4 preceding siblings ...)
2004-02-19 14:56 ` drow at gcc dot gnu dot org
@ 2004-02-19 15:30 ` rearnsha at arm dot com
2004-02-19 17:51 ` drow at gcc dot gnu dot org
` (2 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: rearnsha at arm dot com @ 2004-02-19 15:30 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From rearnsha at arm dot com 2004-02-19 15:30 -------
Subject: Re: [arm] Thumb __builtin_setjmp not
interworking safe
>
> Won't that leave bits of GNAT broken? I think it uses __builtin_setjmp
> explicitly.
>
Possibly, but probably no more broken than it already is if it uses that
routine. How can the compiler know to restore registers it doesn't even
know about? The EABI has been carefully constructed to ensure that it
needed care; but builtin_setjmp breaks that assumption.
The ultimate solution will be to convert the ARM port to use the EABI
exception unwinding model, then most of this should be irrelevant from
that point of view.
R.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14202
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/14202] [arm] Thumb __builtin_setjmp not interworking safe
2004-02-18 23:05 [Bug target/14202] New: [arm] Thumb __builtin_setjmp not interworking safe drow at gcc dot gnu dot org
` (5 preceding siblings ...)
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
8 siblings, 0 replies; 11+ messages in thread
From: drow at gcc dot gnu dot org @ 2004-02-19 17:51 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From drow at gcc dot gnu dot org 2004-02-19 17:51 -------
There are probably other affected bits of code. As an alternate approach, I tried
emitting a +1 after all thumb-mode code labels output using arm_assemble_integer;
this results in working exceptions and working computed goto, and it even manages
not to mess up dwarf2 debug info (but only because dwarf2 bypasses
assemble_integer).
My assumption is that all such labels are being used to move into the PC
(in which case bx needs the bit and mov will ignore it); things in need of code
addresses
appear to go elsewhere.
I didn't test profiling, which may be broken by this approach. I'd be amazed if
nothing
was.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14202
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/14202] [arm] Thumb __builtin_setjmp not interworking safe
2004-02-18 23:05 [Bug target/14202] New: [arm] Thumb __builtin_setjmp not interworking safe drow at gcc dot gnu dot org
` (6 preceding siblings ...)
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
8 siblings, 0 replies; 11+ messages in thread
From: giovannibajo at libero dot it @ 2004-10-11 10:57 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From giovannibajo at libero dot it 2004-10-11 10:57 -------
Daniel, Richard, is still bug still actual? Can we move this to confirmed
status if you agree on the bug? Thanks.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14202
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/14202] [arm] Thumb __builtin_setjmp not interworking safe
2004-02-18 23:05 [Bug target/14202] New: [arm] Thumb __builtin_setjmp not interworking safe drow at gcc dot gnu dot org
` (7 preceding siblings ...)
2004-10-11 10:57 ` giovannibajo at libero dot it
@ 2005-07-02 1:31 ` pinskia at gcc dot gnu dot org
8 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-07-02 1:31 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-07-02 01:31 -------
Confirmed.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Last reconfirmed|0000-00-00 00:00:00 |2005-07-02 01:31:50
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14202
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2005-07-02 1:31 UTC | newest]
Thread overview: 11+ 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
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).