tccrun: win64: add unwind function table for dynamic code

This works only when tcc.exe is compiled using MSC.  MinGW does
something in the startup code that defeats it.
This commit is contained in:
grischka
2011-07-14 19:09:49 +02:00
parent 232650f8b3
commit df4c0892f3
6 changed files with 82 additions and 56 deletions

View File

@ -30,6 +30,10 @@ static int rt_get_caller_pc(uplong *paddr, ucontext_t *uc, int level);
static void rt_error(ucontext_t *uc, const char *fmt, ...);
static int tcc_relocate_ex(TCCState *s1, void *ptr);
#ifdef _WIN64
static void win64_add_function_table(TCCState *s1);
#endif
/* ------------------------------------------------------------- */
/* Do all relocations (needed before using tcc_get_symbol())
Returns -1 on error. */
@ -189,6 +193,10 @@ static int tcc_relocate_ex(TCCState *s1, void *ptr)
set_pages_executable(s1->runtime_plt_and_got,
s1->runtime_plt_and_got_offset);
#endif
#ifdef _WIN64
win64_add_function_table(s1);
#endif
return 0;
}
@ -578,6 +586,17 @@ static void set_exception_handler(void)
SetUnhandledExceptionFilter(cpu_exception_handler);
}
#ifdef _WIN64
static void win64_add_function_table(TCCState *s1)
{
RtlAddFunctionTable(
(RUNTIME_FUNCTION*)(uplong)s1->uw_pdata->sh_addr,
s1->uw_pdata->data_offset / sizeof (RUNTIME_FUNCTION),
(uplong)text_section->sh_addr
);
}
#endif
#ifdef _WIN64
#define Eip Rip
#define Ebp Rbp