public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: "J.W. Jagersma" <jwjagersma@gmail.com>
To: gcc-help <gcc-help@gcc.gnu.org>
Subject: unwind tables for asm blocks
Date: Fri, 28 Feb 2020 10:56:00 -0000	[thread overview]
Message-ID: <102f4894-2d4f-6a26-2055-eea2f9473fb2@gmail.com> (raw)

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.

             reply	other threads:[~2020-02-27 22:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-28 10:56 J.W. Jagersma [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=102f4894-2d4f-6a26-2055-eea2f9473fb2@gmail.com \
    --to=jwjagersma@gmail.com \
    --cc=gcc-help@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).