Problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux