Enable SAFESEH in the Windows x86 build
authorMike Danes <onemihaid@hotmail.com>
Sat, 5 Dec 2015 10:24:32 +0000 (12:24 +0200)
committerMike Danes <onemihaid@hotmail.com>
Sun, 6 Dec 2015 16:06:15 +0000 (18:06 +0200)
CMakeLists.txt
src/debug/ee/wks/CMakeLists.txt
src/dlls/mscoree/i386/.gitmirror [deleted file]
src/dlls/mscoree/i386/handlers.asm [deleted file]
src/dlls/mscoree/mscoree.settings.targets
src/vm/i386/asmhelpers.asm
src/vm/wks/CMakeLists.txt

index 90d5780..ce2a595 100644 (file)
@@ -381,9 +381,6 @@ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /MANIFEST:NO") #Do n
 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SUBSYSTEM:WINDOWS,6.00") #windows subsystem
 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /LARGEADDRESSAWARE") # can handle addresses larger than 2 gigabytes
 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /RELEASE") #sets the checksum in the header
-if (IS_64BIT_BUILD EQUAL 0)
-set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SAFESEH:NO") #Image does not have Safe Exception Handlers..valid only for x86
-endif (IS_64BIT_BUILD EQUAL 0)
 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /NXCOMPAT") #Compatible with Data Execution Prevention
 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /DYNAMICBASE") #Use address space layout randomization
 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /DEBUGTYPE:cv,fixup") #debugging format
index 835895c..2eea459 100644 (file)
@@ -5,10 +5,15 @@ add_precompiled_header(stdafx.h ../stdafx.cpp CORDBEE_SOURCES_WKS)
 
 get_include_directories(ASM_INCLUDE_DIRECTORIES)
 get_compile_definitions(ASM_DEFINITIONS)
+set(ASM_OPTIONS /c /Zi /W3 /errorReport:prompt)
+
+if (CLR_CMAKE_PLATFORM_ARCH_I386)
+  list (APPEND ASM_OPTIONS /safeseh)
+endif (CLR_CMAKE_PLATFORM_ARCH_I386)
 
 # Need to compile asm file using custom command as include directories are not provided to asm compiler
 add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/dbghelpers.obj
-                   COMMAND ${CMAKE_ASM_MASM_COMPILER} ${ASM_INCLUDE_DIRECTORIES} ${ASM_DEFINITIONS} /c /Zi /Fo${CMAKE_CURRENT_BINARY_DIR}/dbghelpers.obj /W3 /errorReport:prompt /Ta${CORDBEE_DIR}/${ARCH_SOURCES_DIR}/dbghelpers.asm
+                   COMMAND ${CMAKE_ASM_MASM_COMPILER} ${ASM_INCLUDE_DIRECTORIES} ${ASM_DEFINITIONS} ${ASM_OPTIONS} /Fo${CMAKE_CURRENT_BINARY_DIR}/dbghelpers.obj /Ta${CORDBEE_DIR}/${ARCH_SOURCES_DIR}/dbghelpers.asm
                    DEPENDS ${CORDBEE_DIR}/${ARCH_SOURCES_DIR}/dbghelpers.asm
                    COMMENT "Compiling dbghelpers.asm")
 
diff --git a/src/dlls/mscoree/i386/.gitmirror b/src/dlls/mscoree/i386/.gitmirror
deleted file mode 100644 (file)
index f507630..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Only contents of this folder, excluding subfolders, will be mirrored by the Git-TFS Mirror. 
\ No newline at end of file
diff --git a/src/dlls/mscoree/i386/handlers.asm b/src/dlls/mscoree/i386/handlers.asm
deleted file mode 100644 (file)
index a1f97f9..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-;
-; Copyright (c) Microsoft. All rights reserved.
-; Licensed under the MIT license. See LICENSE file in the project root for full license information. 
-;
-
-; ==++==
-; 
-
-; 
-; ==--==
-;
-;  This file contains definitions for each CLR exception handler.  
-;  The assembler marks all functions in this file as safe-exception
-;  handler.
-;
-
-.686
-.model  flat
-
-COMPlusFrameHandler proto c
-.safeseh COMPlusFrameHandler
-
-COMPlusNestedExceptionHandler proto c
-.safeseh COMPlusNestedExceptionHandler
-
-FastNExportExceptHandler proto c
-.safeseh FastNExportExceptHandler
-
-UMThunkPrestubHandler proto c
-.safeseh UMThunkPrestubHandler
-
-ifdef FEATURE_COMINTEROP
-COMPlusFrameHandlerRevCom proto c
-.safeseh COMPlusFrameHandlerRevCom
-endif
-
-end
-
index 538f39c..2931de5 100644 (file)
     <ItemGroup Condition="'$(FeatureCoreclr)'=='true'">
         <CppCompile Include="..\unixinterface.cpp" />
     </ItemGroup>
-
-    <ItemGroup>
-        <Assemble386 Condition="'$(BuildArchitecture)' == 'i386'" Include="..\i386\handlers.asm" />
-    </ItemGroup>
-  
 </Project>
index 93d10cd..5e1c059 100644 (file)
@@ -332,6 +332,27 @@ ___CxxFrameHandler3 ENDP
 endif ; _DEBUG
 endif ; FEATURE_CORECLR
 
+; Register CLR exception handlers defined on the C++ side with SAFESEH.
+; Note that these directives must be in a file that defines symbols that will be used during linking,
+; otherwise it's possible that the resulting .obj will completly be ignored by the linker and these
+; directives will have no effect.
+COMPlusFrameHandler proto c
+.safeseh COMPlusFrameHandler
+
+COMPlusNestedExceptionHandler proto c
+.safeseh COMPlusNestedExceptionHandler
+
+FastNExportExceptHandler proto c
+.safeseh FastNExportExceptHandler
+
+UMThunkPrestubHandler proto c
+.safeseh UMThunkPrestubHandler
+
+ifdef FEATURE_COMINTEROP
+COMPlusFrameHandlerRevCom proto c
+.safeseh COMPlusFrameHandlerRevCom
+endif
+
 ; Note that RtlUnwind trashes EBX, ESI and EDI, so this wrapper preserves them
 CallRtlUnwind PROC stdcall public USES ebx esi edi, pEstablisherFrame :DWORD, callback :DWORD, pExceptionRecord :DWORD, retVal :DWORD
 
index 06cf425..1b232b7 100644 (file)
@@ -36,7 +36,7 @@ foreach(CONFIG IN LISTS CMAKE_CONFIGURATION_TYPES)
 endforeach()
 
 if (CLR_CMAKE_PLATFORM_ARCH_I386)
-    set_source_files_properties(${VM_SOURCES_WKS_ARCH_ASM} PROPERTIES COMPILE_FLAGS "/Zm")
+    set_source_files_properties(${VM_SOURCES_WKS_ARCH_ASM} PROPERTIES COMPILE_FLAGS "/Zm /safeseh")
 endif (CLR_CMAKE_PLATFORM_ARCH_I386)
 
 # Convert AsmConstants.h into AsmConstants.inc