Problem

Timo Kreuzer timo.kreuzer@web.de
Wed Nov 19 17:22:00 GMT 2008


Hi,

I am working on x64 SEH for ReactOS. The idea is to use .cfi_escape
codes to mark the code positions where the try block starts / ends and
of the except landing pad. The emitted .eh_frame section is parsed after
linking and converted into Windows compatible unwind info / scope tables.
This works quite well so far.

Now the problem: The exception filter and the finally clause are being
created as nested functions. Now I need to know (in the parsing step
after linking) the addresses of these functions and that they belong to
the corresponding try / except statement. Best would be emitting the
address of the nested function as .cfi_escape, but that doesn't really
work. 1) .cfi_escape only takes bytes, not rvas and 2) the C compiler
doesn't want to give me the address of the nested function at compile time.

I ended up with a dirty hack, referencing the "parent code" from the
inline function with a lea opcode:

{
    __label__ label1;
label1:
    asm volatile (".cfi_escape 0x50, 0x01\n");
    int nested_function()
    {
        asm volatile ("lea %0, %%eax" : : "m"(*(volatile
int*)(&&label1)) : "eax" )
        asm volatile (".cfi_escape 0x50, 0x02\n");
    }
}

>From the escape code I know that there must be a lea instruction, that I
can read the rva from. Together with the position of the start of the
nested function and the position of the label (that would correspond to
the end of the try block for example), I have all the information.
But it's dirty.

Does anyone know a better solution for that?

Thanks in advance,
Timo





More information about the Gcc-help mailing list