From 9b44451682caa17361b68b25be2a85135bb79652 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 5 Apr 2010 14:49:32 -0500 Subject: [PATCH] Safe SEH is better than abstinence --- Nmakefile | 8 +++++++- vm/os-windows-nt.cpp | 2 +- vm/os-windows-nt.hpp | 2 +- vm/safeseh.asm | 5 +++++ 4 files changed, 14 insertions(+), 3 deletions(-) create mode 100755 vm/safeseh.asm diff --git a/Nmakefile b/Nmakefile index 9df7a6a1ee..dc28e1884c 100755 --- a/Nmakefile +++ b/Nmakefile @@ -2,10 +2,12 @@ LINK_FLAGS = /nologo /DEBUG shell32.lib CL_FLAGS = /nologo /Zi /O2 /W3 /DFACTOR_DEBUG !ELSE -LINK_FLAGS = /nologo /safeseh:no shell32.lib +LINK_FLAGS = /nologo /safeseh shell32.lib CL_FLAGS = /nologo /O2 /W3 !ENDIF +ML_FLAGS = /nologo /safeseh + EXE_OBJS = vm\main-windows-nt.obj vm\factor.res DLL_OBJS = vm\os-windows-nt.obj \ @@ -47,6 +49,7 @@ DLL_OBJS = vm\os-windows-nt.obj \ vm\profiler.obj \ vm\quotations.obj \ vm\run.obj \ + vm\safeseh.obj \ vm\strings.obj \ vm\to_tenured_collector.obj \ vm\tuples.obj \ @@ -60,6 +63,9 @@ DLL_OBJS = vm\os-windows-nt.obj \ .c.obj: cl $(CL_FLAGS) /Fo$@ /c $< +.asm.obj: + ml $(ML_FLAGS) /Fo$@ /c $< + .rs.res: rc $< diff --git a/vm/os-windows-nt.cpp b/vm/os-windows-nt.cpp index 4f90d7f641..711b2a8445 100755 --- a/vm/os-windows-nt.cpp +++ b/vm/os-windows-nt.cpp @@ -87,7 +87,7 @@ LONG factor_vm::exception_handler(PEXCEPTION_RECORD e, void *frame, PCONTEXT c, return ExceptionContinueExecution; } -LONG exception_handler(PEXCEPTION_RECORD e, void *frame, PCONTEXT c, void *dispatch) +extern "C" LONG exception_handler(PEXCEPTION_RECORD e, void *frame, PCONTEXT c, void *dispatch) { return current_vm()->exception_handler(e,frame,c,dispatch); } diff --git a/vm/os-windows-nt.hpp b/vm/os-windows-nt.hpp index d84ac97298..2ba75ccf54 100755 --- a/vm/os-windows-nt.hpp +++ b/vm/os-windows-nt.hpp @@ -22,7 +22,7 @@ typedef char symbol_char; #define FACTOR_DLL NULL -LONG exception_handler(PEXCEPTION_RECORD e, void *frame, PCONTEXT c, void *dispatch); +extern "C" LONG exception_handler(PEXCEPTION_RECORD e, void *frame, PCONTEXT c, void *dispatch); // SSE traps raise these exception codes, which are defined in internal NT headers // but not winbase.h diff --git a/vm/safeseh.asm b/vm/safeseh.asm new file mode 100755 index 0000000000..fb706c1331 --- /dev/null +++ b/vm/safeseh.asm @@ -0,0 +1,5 @@ +.386 +.model flat +exception_handler proto +.safeseh exception_handler +end -- 2.34.1