mirror of
https://github.com/reactos/reactos.git
synced 2024-12-04 00:43:32 +08:00
[CMAKE] Ensure the INIT section is placed at the end of a module. CORE-14683
For MSVC, marking the section as discardable will do this automatically. For GCC, we use a linker script that places it after the .reloc section (which should be the last "real" section, check ld --verbose output for the default linker script). This fixes what seems to be a regression from r55835 (!).
This commit is contained in:
parent
c17a8770a3
commit
c4d8e2a6e9
@ -31,12 +31,14 @@ set_subsystem(ntoskrnl native)
|
||||
if(MSVC)
|
||||
set_image_base(ntoskrnl 0x00400000)
|
||||
add_target_link_flags(ntoskrnl "/SECTION:.rsrc,!DP") #Accessed from bugcheck code
|
||||
add_target_link_flags(ntoskrnl "/SECTION:INIT,D")
|
||||
else()
|
||||
if(GDB)
|
||||
set_image_base(ntoskrnl 0x00800000)
|
||||
else()
|
||||
set_image_base(ntoskrnl 0x80800000)
|
||||
endif()
|
||||
add_linker_script(ntoskrnl ${REACTOS_SOURCE_DIR}/sdk/cmake/init-section.lds)
|
||||
endif()
|
||||
|
||||
target_link_libraries(ntoskrnl cportlib csq ${PSEH_LIB} cmlib ntlsalib rtl ${ROSSYM_LIB} libcntpr wdmguid ioevent)
|
||||
|
@ -318,6 +318,7 @@ function(set_module_type_toolchain MODULE TYPE)
|
||||
if(${TYPE} STREQUAL "wdmdriver")
|
||||
add_target_link_flags(${MODULE} "-Wl,--wdmdriver")
|
||||
endif()
|
||||
add_linker_script(${MODULE} ${REACTOS_SOURCE_DIR}/sdk/cmake/init-section.lds)
|
||||
endif()
|
||||
|
||||
if(STACK_PROTECTOR)
|
||||
|
11
sdk/cmake/init-section.lds
Normal file
11
sdk/cmake/init-section.lds
Normal file
@ -0,0 +1,11 @@
|
||||
/* Make sure the INIT section is at the end of the module so we can reclaim the space */
|
||||
SECTIONS
|
||||
{
|
||||
INIT BLOCK(__section_alignment__) :
|
||||
{
|
||||
__init_start__ = . ;
|
||||
*(INIT)
|
||||
__init_end__ = . ;
|
||||
}
|
||||
}
|
||||
INSERT AFTER .reloc;
|
@ -327,9 +327,9 @@ function(set_module_type_toolchain MODULE TYPE)
|
||||
add_target_link_flags(${MODULE} "/DLL")
|
||||
elseif(${TYPE} STREQUAL "kernelmodedriver")
|
||||
# Disable linker warning 4078 (multiple sections found with different attributes) for INIT section use
|
||||
add_target_link_flags(${MODULE} "/DRIVER /IGNORE:4078")
|
||||
add_target_link_flags(${MODULE} "/DRIVER /IGNORE:4078 /SECTION:INIT,D")
|
||||
elseif(${TYPE} STREQUAL "wdmdriver")
|
||||
add_target_link_flags(${MODULE} "/DRIVER:WDM /IGNORE:4078")
|
||||
add_target_link_flags(${MODULE} "/DRIVER:WDM /IGNORE:4078 /SECTION:INIT,D")
|
||||
endif()
|
||||
|
||||
if(RUNTIME_CHECKS)
|
||||
|
Loading…
Reference in New Issue
Block a user