From df4c0892f3fb5170042652cd648a29c94c3a2eca Mon Sep 17 00:00:00 2001 From: grischka Date: Thu, 14 Jul 2011 19:09:49 +0200 Subject: 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. --- tccrun.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'tccrun.c') diff --git a/tccrun.c b/tccrun.c index 0423a1d..e45c218 100644 --- a/tccrun.c +++ b/tccrun.c @@ -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 -- cgit v1.3.1