mirror of
https://github.com/reactos/reactos.git
synced 2024-11-18 21:13:52 +00:00
[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? svn path=/trunk/; revision=70687
This commit is contained in:
parent
3f9bbc9a01
commit
bc01b35fdf
3 changed files with 13 additions and 14 deletions
|
@ -10,7 +10,7 @@ if(MSVC)
|
||||||
replace_compile_flags("/hotpatch" " ")
|
replace_compile_flags("/hotpatch" " ")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
spec2def(freeldr.sys freeldr.spec)
|
spec2def(freeldr_pe.exe freeldr.spec)
|
||||||
|
|
||||||
if(ARCH STREQUAL "i386")
|
if(ARCH STREQUAL "i386")
|
||||||
CreateBootSectorTarget(frldr16
|
CreateBootSectorTarget(frldr16
|
||||||
|
@ -177,12 +177,14 @@ list(APPEND FREELDR_BASE_SOURCE
|
||||||
lib/inffile/inffile.c
|
lib/inffile/inffile.c
|
||||||
lib/rtl/libsupp.c)
|
lib/rtl/libsupp.c)
|
||||||
|
|
||||||
if(NOT MSVC)
|
if(ARCH STREQUAL "i386")
|
||||||
list(APPEND FREELDR_BASE_SOURCE ${CMAKE_CURRENT_BINARY_DIR}/freeldr.def)
|
# Must be included together with disk/scsiport.c
|
||||||
|
list(APPEND FREELDR_BASE_SOURCE
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/freeldr_pe.def)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_library(freeldr_pe SHARED ${FREELDR_BASE_SOURCE})
|
add_executable(freeldr_pe ${FREELDR_BASE_SOURCE})
|
||||||
add_library(freeldr_pe_dbg SHARED EXCLUDE_FROM_ALL ${FREELDR_BASE_SOURCE})
|
add_executable(freeldr_pe_dbg EXCLUDE_FROM_ALL ${FREELDR_BASE_SOURCE})
|
||||||
|
|
||||||
if(NOT MSVC AND SEPARATE_DBG)
|
if(NOT MSVC AND SEPARATE_DBG)
|
||||||
set_target_properties(freeldr_pe PROPERTIES LINKER_LANGUAGE LDR_PE_HELPER)
|
set_target_properties(freeldr_pe PROPERTIES LINKER_LANGUAGE LDR_PE_HELPER)
|
||||||
|
@ -234,12 +236,10 @@ add_dependencies(freeldr_pe_dbg asm)
|
||||||
get_target_property(_freeldr_pe_output_file freeldr_pe LOCATION)
|
get_target_property(_freeldr_pe_output_file freeldr_pe LOCATION)
|
||||||
|
|
||||||
if(NOT ARCH STREQUAL "arm")
|
if(NOT ARCH STREQUAL "arm")
|
||||||
|
|
||||||
concatenate_files(
|
concatenate_files(
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/freeldr.sys
|
${CMAKE_CURRENT_BINARY_DIR}/freeldr.sys
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/frldr16.bin
|
${CMAKE_CURRENT_BINARY_DIR}/frldr16.bin
|
||||||
${_freeldr_pe_output_file})
|
${_freeldr_pe_output_file})
|
||||||
|
|
||||||
add_custom_target(freeldr ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/freeldr.sys)
|
add_custom_target(freeldr ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/freeldr.sys)
|
||||||
else()
|
else()
|
||||||
add_custom_target(freeldr ALL DEPENDS ${_freeldr_pe_output_file})
|
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 DESTINAT
|
||||||
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)
|
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")
|
if(NOT ARCH STREQUAL "arm")
|
||||||
|
|
||||||
concatenate_files(
|
concatenate_files(
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/setupldr.sys
|
${CMAKE_CURRENT_BINARY_DIR}/setupldr.sys
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/frldr16.bin
|
${CMAKE_CURRENT_BINARY_DIR}/frldr16.bin
|
||||||
${_freeldr_pe_output_file})
|
${_freeldr_pe_output_file})
|
||||||
|
|
||||||
add_custom_target(setupldr ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/setupldr.sys)
|
add_custom_target(setupldr ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/setupldr.sys)
|
||||||
else()
|
else()
|
||||||
add_custom_target(setupldr ALL DEPENDS ${_freeldr_pe_output_file})
|
add_custom_target(setupldr ALL DEPENDS ${_freeldr_pe_output_file})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_cd_file(TARGET setupldr FILE ${CMAKE_CURRENT_BINARY_DIR}/setupldr.sys DESTINATION loader NO_CAB FOR bootcd regtest)
|
add_cd_file(TARGET setupldr FILE ${CMAKE_CURRENT_BINARY_DIR}/setupldr.sys DESTINATION loader NO_CAB FOR bootcd regtest)
|
||||||
|
|
||||||
|
|
|
@ -21,13 +21,15 @@
|
||||||
|
|
||||||
extern char __ImageBase;
|
extern char __ImageBase;
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
|
/* .text, .edata and .bss */
|
||||||
#define FREELDR_SECTION_COUNT 3
|
#define FREELDR_SECTION_COUNT 3
|
||||||
#else
|
#else
|
||||||
#ifdef _M_AMD64
|
#ifdef _M_AMD64
|
||||||
/* .text and .pdata */
|
/* .text and .pdata */
|
||||||
#define FREELDR_SECTION_COUNT 2
|
#define FREELDR_SECTION_COUNT 2
|
||||||
#else
|
#else
|
||||||
#define FREELDR_SECTION_COUNT 1
|
/* .text and .edata */
|
||||||
|
#define FREELDR_SECTION_COUNT 2
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -258,8 +258,8 @@ MmCheckFreeldrImageFile(VOID)
|
||||||
FileHeader = &NtHeaders->FileHeader;
|
FileHeader = &NtHeaders->FileHeader;
|
||||||
if ((FileHeader->Machine != IMAGE_FILE_MACHINE_NATIVE) ||
|
if ((FileHeader->Machine != IMAGE_FILE_MACHINE_NATIVE) ||
|
||||||
(FileHeader->NumberOfSections != FREELDR_SECTION_COUNT) ||
|
(FileHeader->NumberOfSections != FREELDR_SECTION_COUNT) ||
|
||||||
(FileHeader->PointerToSymbolTable != 0) ||
|
(FileHeader->PointerToSymbolTable != 0) || // Symbols stripped
|
||||||
(FileHeader->NumberOfSymbols != 0) ||
|
(FileHeader->NumberOfSymbols != 0) || // "" ""
|
||||||
(FileHeader->SizeOfOptionalHeader != sizeof(IMAGE_OPTIONAL_HEADER)))
|
(FileHeader->SizeOfOptionalHeader != sizeof(IMAGE_OPTIONAL_HEADER)))
|
||||||
{
|
{
|
||||||
ERR("FreeLdr FileHeader is invalid.\n");
|
ERR("FreeLdr FileHeader is invalid.\n");
|
||||||
|
@ -283,7 +283,7 @@ MmCheckFreeldrImageFile(VOID)
|
||||||
/* Check the optional header */
|
/* Check the optional header */
|
||||||
OptionalHeader = &NtHeaders->OptionalHeader;
|
OptionalHeader = &NtHeaders->OptionalHeader;
|
||||||
if ((OptionalHeader->Magic != IMAGE_NT_OPTIONAL_HDR_MAGIC) ||
|
if ((OptionalHeader->Magic != IMAGE_NT_OPTIONAL_HDR_MAGIC) ||
|
||||||
(OptionalHeader->Subsystem != 1) || // native
|
(OptionalHeader->Subsystem != IMAGE_SUBSYSTEM_NATIVE) ||
|
||||||
(OptionalHeader->ImageBase != FREELDR_PE_BASE) ||
|
(OptionalHeader->ImageBase != FREELDR_PE_BASE) ||
|
||||||
(OptionalHeader->SizeOfImage > MAX_FREELDR_PE_SIZE) ||
|
(OptionalHeader->SizeOfImage > MAX_FREELDR_PE_SIZE) ||
|
||||||
(OptionalHeader->SectionAlignment != OptionalHeader->FileAlignment))
|
(OptionalHeader->SectionAlignment != OptionalHeader->FileAlignment))
|
||||||
|
|
Loading…
Reference in a new issue