[CMAKE] Fixup of driver sections in GCC builds

Also introduce a helper variable to list KMode modules
This commit is contained in:
Jérôme Gardou 2021-02-24 10:20:18 +01:00 committed by Jérôme Gardou
parent 5489efcb1a
commit 812c9e5a11
2 changed files with 10 additions and 3 deletions

View file

@ -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})

View file

@ -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()