[0.4.12][NTOSKRNL] Restore section layout for NTOSKRNL to fix BSOD regression CORE...
authorJoachim Henze <Joachim.Henze@reactos.org>
Sat, 31 Oct 2020 15:28:44 +0000 (16:28 +0100)
committerJoachim Henze <Joachim.Henze@reactos.org>
Sat, 31 Oct 2020 15:28:44 +0000 (16:28 +0100)
Although I fixed the DvDWriteNow-BSOD already in 0.4.12-RC-41-g1a9f0bc, I do switch to
the most advanced state of master for the sake of sync (different location of the ld script)
and because Thomas Faber thinks that it's a bit more
safe to just move "after .rsrc" instead of the proper "after .reloc".
A temporary tribute until ROSBE-154 will be fixed properly.

For now we use this just for NTOSKRNL, but not for drivers yet, see
MODULE TYPE sdk/cmake/gcc.cmake
As using also for drivers would immediately lead to BSODs like CORE-16183.
To allow installing DVDWritenow without BSOD,
we need the script at least for ntoskrnl!

The regression was introduced by SVN r55835 == git
6ebf8c253770af0c029f1d7937a33235108d59e3

This patch (after .rsrc) was already committed into 0.4.13RC and 0.4.14RC and
0.4.15-dev-220-g
d28677795e98cdd4fdf0f4aff2773197a6b39718

ntoskrnl/CMakeLists.txt
sdk/cmake/gcc.cmake
sdk/cmake/init-section.lds [moved from ntoskrnl/ntoskrnl_i386.lds with 52% similarity]
sdk/cmake/msvc.cmake

index a6442e9..5f2ac87 100644 (file)
@@ -30,14 +30,15 @@ set_subsystem(ntoskrnl native)
 
 if(MSVC)
     set_image_base(ntoskrnl 0x00400000)
-    add_target_link_flags(ntoskrnl "/SECTION:.rsrc,!DP /SECTION:INIT,D") #Accessed from bugcheck code
+    add_target_link_flags(ntoskrnl "/SECTION:.rsrc,!DP") #Accessed from bugcheck code
+    add_target_link_flags(ntoskrnl "/SECTION:INIT,D")
 else()
-    add_linker_script(ntoskrnl ntoskrnl_i386.lds)
     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)
index 8ecc06b..e5629a0 100644 (file)
@@ -479,8 +479,5 @@ endmacro()
 function(add_linker_script _target _linker_script_file)
     get_filename_component(_file_full_path ${_linker_script_file} ABSOLUTE)
     add_target_link_flags(${_target} "-Wl,-T,${_file_full_path}")
-
-    # Unfortunately LINK_DEPENDS is ignored in non-Makefile generators (for now...)
-    # See also http://www.cmake.org/pipermail/cmake/2010-May/037206.html
     add_target_property(${_target} LINK_DEPENDS ${_file_full_path})
 endfunction()
similarity index 52%
rename from ntoskrnl/ntoskrnl_i386.lds
rename to sdk/cmake/init-section.lds
index 77fd076..7cf5a2b 100644 (file)
@@ -1,3 +1,4 @@
+/* Make sure the INIT section is at the end of the module so we can reclaim the space */
 SECTIONS
 {
   INIT BLOCK(__section_alignment__) :
@@ -7,4 +8,4 @@ SECTIONS
     __init_end__ = . ;
   }
 }
-INSERT AFTER .reloc;
\ No newline at end of file
+INSERT AFTER .rsrc;
index 6eec2b1..9499730 100644 (file)
@@ -614,9 +614,6 @@ function(add_linker_script _target _linker_script_file)
         # add_custom_target("${_target}_${_file_name}" ALL DEPENDS ${_generated_file})
         # add_dependencies(${_target} "${_target}_${_file_name}")
         add_target_link_flags(${_target} "@${_generated_file}")
-
-        # Unfortunately LINK_DEPENDS is ignored in non-Makefile generators (for now...)
-        # See also http://www.cmake.org/pipermail/cmake/2010-May/037206.html
-        add_target_property(${_target} LINK_DEPENDS ${_generated_file})
+        add_target_property(${_target} LINK_DEPENDS ${_file_full_path})
     endif()
 endfunction()