unwind tables for asm blocks

J.W. Jagersma jwjagersma@gmail.com
Fri Feb 28 10:56:00 GMT 2020


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.



More information about the Gcc-help mailing list