https://git.reactos.org/?p=reactos.git;a=commitdiff;h=812c9e5a11a2d473fda994...
commit 812c9e5a11a2d473fda994ed843be914f546df38 Author: Jérôme Gardou jerome.gardou@reactos.org AuthorDate: Wed Feb 24 10:20:18 2021 +0100 Commit: Jérôme Gardou zefklop@users.noreply.github.com CommitDate: Tue Mar 23 11:18:43 2021 +0100
[CMAKE] Fixup of driver sections in GCC builds
Also introduce a helper variable to list KMode modules --- sdk/cmake/CMakeMacros.cmake | 2 ++ sdk/cmake/gcc.cmake | 11 ++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/sdk/cmake/CMakeMacros.cmake b/sdk/cmake/CMakeMacros.cmake index 1429580b2ac..2d5628f02a2 100644 --- a/sdk/cmake/CMakeMacros.cmake +++ b/sdk/cmake/CMakeMacros.cmake @@ -540,6 +540,8 @@ function(add_importlibs _module) endforeach() endfunction()
+# Some helper lists +list(APPEND KERNEL_MODULE_TYPES kerneldll kernelmodedriver wdmdriver) function(set_module_type MODULE TYPE) cmake_parse_arguments(__module "UNICODE" "IMAGEBASE" "ENTRYPOINT" ${ARGN})
diff --git a/sdk/cmake/gcc.cmake b/sdk/cmake/gcc.cmake index 9f38f811e4d..442422a74dc 100644 --- a/sdk/cmake/gcc.cmake +++ b/sdk/cmake/gcc.cmake @@ -280,13 +280,18 @@ function(set_image_base MODULE IMAGE_BASE) endfunction()
function(set_module_type_toolchain MODULE TYPE) - if((${TYPE} STREQUAL "kernelmodedriver") OR (${TYPE} STREQUAL "wdmdriver")) - add_target_link_flags(${MODULE} "-Wl,--exclude-all-symbols,-file-alignment=0x1000,-section-alignment=0x1000") + if (TYPE IN_LIST KERNEL_MODULE_TYPES) + target_link_options(${MODULE} PRIVATE -Wl,--exclude-all-symbols,-file-alignment=0x1000,-section-alignment=0x1000) if(${TYPE} STREQUAL "wdmdriver") - add_target_link_flags(${MODULE} "-Wl,--wdmdriver") + target_link_options(${MODULE} PRIVATE "-Wl,--wdmdriver") endif() # Place INIT section at the tail of the module add_linker_script(${MODULE} ${REACTOS_SOURCE_DIR}/sdk/cmake/init-section.lds) + # Fixup section characteristiscs + add_custom_command(TARGET ${MODULE} POST_BUILD + COMMAND native-pefixup --driver $<TARGET_FILE:${MODULE}>) + # Believe it or not, cmake doesn't do that + set_property(TARGET ${MODULE} APPEND PROPERTY LINK_DEPENDS $<TARGET_PROPERTY:native-pefixup,IMPORTED_LOCATION>) endif() endfunction()