From 09c70d9edf7c0302bd56c7ecebad5a3bf6f98aae Mon Sep 17 00:00:00 2001 From: Walter Bright Date: Sat, 22 Sep 2012 12:13:44 -0700 Subject: [PATCH] fix Win64 eh --- src/rt/deh2.d | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/rt/deh2.d b/src/rt/deh2.d index 94927933f4e..1b19362b68a 100644 --- a/src/rt/deh2.d +++ b/src/rt/deh2.d @@ -248,6 +248,17 @@ extern (C) void _d_throwc(Object *h) continue; } auto funcoffset = cast(size_t)func_table.fptr; + version (Win64) + { + /* If linked with /DEBUG, the linker rewrites it so the function pointer points + * to a JMP to the actual code. The address will be in the actual code, so we + * need to follow the JMP. + */ + if ((cast(ubyte*)funcoffset)[0] == 0xE9) + { // JMP target = RIP of next instruction + signed 32 bit displacement + funcoffset = funcoffset + 5 + *cast(int*)(funcoffset + 1); + } + } auto spoff = handler_table.espoffset; auto retoffset = handler_table.retoffset;