From 06a96d5805bef568f0dfe2a24e616b707df25e33 Mon Sep 17 00:00:00 2001 From: Amine Khaldi Date: Fri, 28 Feb 2014 16:18:41 +0000 Subject: [PATCH] [CMAKE] * Add support for marking an image as hotpatchable. [INCLUDES] * Introduce a way to allow us to mark pretty much any function in our codebase as DECLSPEC_HOTPATCH (not just in Wine modules). * Fix DECLSPEC_HOTPATCH define and enable this hot patching feature support. CORE-7959 svn path=/trunk/; revision=62354 --- reactos/cmake/CMakeMacros.cmake | 13 ++++++++++++- reactos/include/crt/_mingw.h | 9 +++++++++ reactos/include/reactos/wine/config.h | 6 ++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/reactos/cmake/CMakeMacros.cmake b/reactos/cmake/CMakeMacros.cmake index f6f4bcbfb2f..1229654bab5 100644 --- a/reactos/cmake/CMakeMacros.cmake +++ b/reactos/cmake/CMakeMacros.cmake @@ -417,7 +417,7 @@ function(add_importlibs _module) endfunction() function(set_module_type MODULE TYPE) - cmake_parse_arguments(__module "UNICODE" "IMAGEBASE" "ENTRYPOINT" ${ARGN}) + cmake_parse_arguments(__module "UNICODE;HOTPATCHABLE" "IMAGEBASE" "ENTRYPOINT" ${ARGN}) if(__module_UNPARSED_ARGUMENTS) message(STATUS "set_module_type : unparsed arguments ${__module_UNPARSED_ARGUMENTS}, module : ${MODULE}") @@ -457,6 +457,17 @@ function(set_module_type MODULE TYPE) add_target_compile_definitions(${MODULE} UNICODE _UNICODE) endif() + # Handle hotpatchable images. + # GCC has this as a function attribute so we're handling it using DECLSPEC_HOTPATCH + if(__module_HOTPATCHABLE AND MSVC) + set_property(TARGET ${_target} APPEND_STRING PROPERTY COMPILE_FLAGS " /hotpatch") + if(ARCH STREQUAL "i386") + set_property(TARGET ${_target} APPEND_STRING PROPERTY LINK_FLAGS " /FUNCTIONPADMIN:5") + elseif(ARCH STREQUAL "amd64") + set_property(TARGET ${_target} APPEND_STRING PROPERTY LINK_FLAGS " /FUNCTIONPADMIN:6") + endif() + endif() + # set entry point if(__module_ENTRYPOINT OR (__module_ENTRYPOINT STREQUAL "0")) list(GET __module_ENTRYPOINT 0 __entrypoint) diff --git a/reactos/include/crt/_mingw.h b/reactos/include/crt/_mingw.h index f63e7dac32e..40b8b11ed39 100644 --- a/reactos/include/crt/_mingw.h +++ b/reactos/include/crt/_mingw.h @@ -215,6 +215,15 @@ allow GCC to optimize away some EH unwind code, at least in DW2 case. */ #define _DECLSPEC_INTRIN_TYPE #endif +/* Define to a function attribute for Microsoft hotpatch assembly prefix. */ +#ifndef DECLSPEC_HOTPATCH +#ifdef _MSC_VER +#define DECLSPEC_HOTPATCH +#else +#define DECLSPEC_HOTPATCH __attribute__((__ms_hook_prologue__)) +#endif +#endif /* DECLSPEC_HOTPATCH */ + #include "_mingw_mac.h" #endif /* !_INC_MINGW */ diff --git a/reactos/include/reactos/wine/config.h b/reactos/include/reactos/wine/config.h index 6f1d8d632cb..36bb5c2a0a1 100644 --- a/reactos/include/reactos/wine/config.h +++ b/reactos/include/reactos/wine/config.h @@ -1,7 +1,13 @@ #define __WINE_CONFIG_H /* Define to a function attribute for Microsoft hotpatch assembly prefix. */ +#ifndef DECLSPEC_HOTPATCH +#ifdef _MSC_VER #define DECLSPEC_HOTPATCH +#else +#define DECLSPEC_HOTPATCH __attribute__((__ms_hook_prologue__)) +#endif +#endif /* DECLSPEC_HOTPATCH */ /* Define to the file extension for executables. */ #define EXEEXT ".exe" -- 2.17.1