Reactos

[NDK][CMAKE] Introduce DATA_SEG and CODE_SEG macro These are for putting code and data to non-default sections At the same time, move INIT section attributes declaration to cmake files

+9 -15
+1 -1
hal/halx86/CMakeLists.txt
··· 52 52 set_module_type(${_halname} kerneldll ENTRYPOINT HalInitSystem 8) 53 53 add_cd_file(TARGET ${_halname} DESTINATION reactos/system32 NO_CAB FOR all) 54 54 if(MSVC) 55 - add_target_link_flags(${_halname} "/ignore:4216 /ignore:4078") 55 + add_target_link_flags(${_halname} "/ignore:4216 /SECTION:INIT,ERWD") 56 56 else() 57 57 target_link_libraries(${_halname} -lgcc) 58 58 endif()
+1 -1
ntoskrnl/CMakeLists.txt
··· 36 36 if(MSVC) 37 37 set_image_base(ntoskrnl 0x00400000) 38 38 add_target_link_flags(ntoskrnl "/SECTION:.rsrc,!DP") #Accessed from bugcheck code 39 - add_target_link_flags(ntoskrnl "/SECTION:INIT,D") 39 + add_target_link_flags(ntoskrnl "/SECTION:INIT,ERWD") 40 40 else() 41 41 if(GDB) 42 42 # Completely disable optimizations when debugging the kernel
+2 -2
sdk/cmake/msvc.cmake
··· 248 248 add_target_link_flags(${MODULE} "/DLL") 249 249 elseif(${TYPE} STREQUAL "kernelmodedriver") 250 250 # Disable linker warning 4078 (multiple sections found with different attributes) for INIT section use 251 - add_target_link_flags(${MODULE} "/DRIVER /IGNORE:4078 /SECTION:INIT,D") 251 + add_target_link_flags(${MODULE} "/DRIVER /SECTION:INIT,ERWD") 252 252 elseif(${TYPE} STREQUAL "wdmdriver") 253 - add_target_link_flags(${MODULE} "/DRIVER:WDM /IGNORE:4078 /SECTION:INIT,D") 253 + add_target_link_flags(${MODULE} "/DRIVER:WDM /SECTION:INIT,ERWD") 254 254 endif() 255 255 256 256 if(RUNTIME_CHECKS)
+5 -11
sdk/include/ndk/section_attribs.h
··· 8 8 9 9 Abstract: 10 10 11 - Preprocessor definitions to put code and data into the INIT section. 11 + Preprocessor definitions to put code and data into specific sections. 12 12 13 13 Author: 14 14 ··· 20 20 21 21 #if defined(__GNUC__) || defined(__clang__) 22 22 23 - #define INIT_SECTION __attribute__((section ("INIT"))) 24 - #define INIT_FUNCTION __attribute__((section ("INIT"))) 23 + #define DATA_SEG(segment) __attribute__((section(segment))) 24 + #define CODE_SEG(segment) __attribute__((section(segment))) 25 25 26 26 #elif defined(_MSC_VER) 27 27 28 - #pragma comment(linker, "/SECTION:INIT,ERW") 29 - #define INIT_SECTION __declspec(allocate("INIT")) 30 - #if (_MSC_VER >= 1800) // Visual Studio 2013 / version 12.0 31 - #define INIT_FUNCTION __declspec(code_seg("INIT")) 32 - #else 33 - #pragma section("INIT", read,execute,discard) 34 - #define INIT_FUNCTION 35 - #endif 28 + #define DATA_SEG(segment) __declspec(allocate(segment)) 29 + #define CODE_SEG(segment) __declspec(code_seg(segment)) 36 30 37 31 #else 38 32