public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* unwind tables for asm blocks
@ 2020-02-28 10:56 J.W. Jagersma
  2020-02-28 20:58 ` J.W. Jagersma
  2020-02-28 21:32 ` Florian Weimer
  0 siblings, 2 replies; 7+ messages in thread
From: J.W. Jagersma @ 2020-02-28 10:56 UTC (permalink / raw)
  To: gcc-help

Is there some way to convince gcc to generate unwind tables for asm
statements? As an example:

```
$ cat throw-asm.cpp
void throw_exc()
{
    throw 0;
}

int main()
{
    try
    {
        asm("call %0" :: "i" (throw_exc));
    }
    catch(...) { }
    return 0;
}

$ g++ -fnon-call-exceptions -fasynchronous-unwind-tables -masm=intel throw-asm.cpp -o throw-asm && ./throw-asm
terminate called after throwing an instance of 'int'
Aborted (core dumped)
```

Compiling with -S reveals that main() has no unwind table at all.
If you add something before and after the asm statement, eg. function
calls, then it generates unwind tables and it's sometimes possible to
catch the exception, but there's a lot of randomness involved (due to
instruction reordering).
Much of my code depends on non-call exceptions and I really need the
unwind tables to cover asm code too.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-02-29  4:49 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-28 10:56 unwind tables for asm blocks J.W. Jagersma
2020-02-28 20:58 ` J.W. Jagersma
2020-02-28 21:32 ` Florian Weimer
2020-02-28 22:03   ` J.W. Jagersma
2020-02-28 22:24     ` Florian Weimer
2020-02-28 22:32       ` J.W. Jagersma
2020-02-29 14:36         ` Florian Weimer

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).