Author: hbelusca
Date: Wed Feb 3 22:18:05 2016
New Revision: 70687
URL:
http://svn.reactos.org/svn/reactos?rev=70687&view=rev
Log:
[FREELDR]
- The PE code can be built as an executable, it works as expected and nothing changes (the
size of the generated code doesn't change).
- Export the Scsi functions also on x86 MSVC builds. Because of that, increase the number
of expected PE sections in the FreeLdr image check function. Note that x64 MSVC build do
not have the Scsi code ready yet, hence it doesn't export the corresponding
functions.
- The spec2def command should have the name of the generated PE file.
- Remove one hardcoded value.
During my investigations I noticed that using a section alignment of 0x400 for freeldr
MSVC builds (instead of the default 0x1000) made the MSVC builds *bigger*. Furthermore,
using the default alignment of 0x1000 makes the freeldr MSVC builds unbootable. I
don't understand why. Maybe a freeldr guru knows that?
Modified:
trunk/reactos/boot/freeldr/freeldr/CMakeLists.txt
trunk/reactos/boot/freeldr/freeldr/include/mm.h
trunk/reactos/boot/freeldr/freeldr/mm/meminit.c
Modified: trunk/reactos/boot/freeldr/freeldr/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/CMake…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/CMakeLists.txt [iso-8859-1] Wed Feb 3 22:18:05
2016
@@ -10,7 +10,7 @@
replace_compile_flags("/hotpatch" " ")
endif()
-spec2def(freeldr.sys freeldr.spec)
+spec2def(freeldr_pe.exe freeldr.spec)
if(ARCH STREQUAL "i386")
CreateBootSectorTarget(frldr16
@@ -177,12 +177,14 @@
lib/inffile/inffile.c
lib/rtl/libsupp.c)
-if(NOT MSVC)
- list(APPEND FREELDR_BASE_SOURCE ${CMAKE_CURRENT_BINARY_DIR}/freeldr.def)
-endif()
-
-add_library(freeldr_pe SHARED ${FREELDR_BASE_SOURCE})
-add_library(freeldr_pe_dbg SHARED EXCLUDE_FROM_ALL ${FREELDR_BASE_SOURCE})
+if(ARCH STREQUAL "i386")
+ # Must be included together with disk/scsiport.c
+ list(APPEND FREELDR_BASE_SOURCE
+ ${CMAKE_CURRENT_BINARY_DIR}/freeldr_pe.def)
+endif()
+
+add_executable(freeldr_pe ${FREELDR_BASE_SOURCE})
+add_executable(freeldr_pe_dbg EXCLUDE_FROM_ALL ${FREELDR_BASE_SOURCE})
if(NOT MSVC AND SEPARATE_DBG)
set_target_properties(freeldr_pe PROPERTIES LINKER_LANGUAGE LDR_PE_HELPER)
@@ -234,12 +236,10 @@
get_target_property(_freeldr_pe_output_file freeldr_pe LOCATION)
if(NOT ARCH STREQUAL "arm")
-
concatenate_files(
${CMAKE_CURRENT_BINARY_DIR}/freeldr.sys
${CMAKE_CURRENT_BINARY_DIR}/frldr16.bin
${_freeldr_pe_output_file})
-
add_custom_target(freeldr ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/freeldr.sys)
else()
add_custom_target(freeldr ALL DEPENDS ${_freeldr_pe_output_file})
@@ -250,16 +250,13 @@
add_cd_file(TARGET freeldr FILE ${CMAKE_CURRENT_BINARY_DIR}/freeldr.sys DESTINATION
loader NO_CAB NOT_IN_HYBRIDCD FOR livecd hybridcd NAME_ON_CD setupldr.sys)
if(NOT ARCH STREQUAL "arm")
-
concatenate_files(
${CMAKE_CURRENT_BINARY_DIR}/setupldr.sys
${CMAKE_CURRENT_BINARY_DIR}/frldr16.bin
${_freeldr_pe_output_file})
-
add_custom_target(setupldr ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/setupldr.sys)
else()
add_custom_target(setupldr ALL DEPENDS ${_freeldr_pe_output_file})
endif()
add_cd_file(TARGET setupldr FILE ${CMAKE_CURRENT_BINARY_DIR}/setupldr.sys DESTINATION
loader NO_CAB FOR bootcd regtest)
-
Modified: trunk/reactos/boot/freeldr/freeldr/include/mm.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/inclu…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/include/mm.h [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/include/mm.h [iso-8859-1] Wed Feb 3 22:18:05 2016
@@ -21,13 +21,15 @@
extern char __ImageBase;
#ifdef __GNUC__
+/* .text, .edata and .bss */
#define FREELDR_SECTION_COUNT 3
#else
#ifdef _M_AMD64
/* .text and .pdata */
#define FREELDR_SECTION_COUNT 2
#else
-#define FREELDR_SECTION_COUNT 1
+/* .text and .edata */
+#define FREELDR_SECTION_COUNT 2
#endif
#endif
Modified: trunk/reactos/boot/freeldr/freeldr/mm/meminit.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/mm/me…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/mm/meminit.c [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/mm/meminit.c [iso-8859-1] Wed Feb 3 22:18:05 2016
@@ -258,8 +258,8 @@
FileHeader = &NtHeaders->FileHeader;
if ((FileHeader->Machine != IMAGE_FILE_MACHINE_NATIVE) ||
(FileHeader->NumberOfSections != FREELDR_SECTION_COUNT) ||
- (FileHeader->PointerToSymbolTable != 0) ||
- (FileHeader->NumberOfSymbols != 0) ||
+ (FileHeader->PointerToSymbolTable != 0) || // Symbols stripped
+ (FileHeader->NumberOfSymbols != 0) || // ""
""
(FileHeader->SizeOfOptionalHeader != sizeof(IMAGE_OPTIONAL_HEADER)))
{
ERR("FreeLdr FileHeader is invalid.\n");
@@ -283,7 +283,7 @@
/* Check the optional header */
OptionalHeader = &NtHeaders->OptionalHeader;
if ((OptionalHeader->Magic != IMAGE_NT_OPTIONAL_HDR_MAGIC) ||
- (OptionalHeader->Subsystem != 1) || // native
+ (OptionalHeader->Subsystem != IMAGE_SUBSYSTEM_NATIVE) ||
(OptionalHeader->ImageBase != FREELDR_PE_BASE) ||
(OptionalHeader->SizeOfImage > MAX_FREELDR_PE_SIZE) ||
(OptionalHeader->SectionAlignment != OptionalHeader->FileAlignment))