mirror of
https://github.com/reactos/reactos.git
synced 2025-01-01 03:54:02 +00:00
[BOOTLIB]: Fuck you binutils.
svn path=/trunk/; revision=70636
This commit is contained in:
parent
125060988e
commit
a68573d0c5
2 changed files with 24 additions and 6 deletions
|
@ -113,9 +113,9 @@ add_executable(rosload ${ROSLOAD_BASE_SOURCE})
|
||||||
set_target_properties(rosload PROPERTIES SUFFIX ".efi")
|
set_target_properties(rosload PROPERTIES SUFFIX ".efi")
|
||||||
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
add_target_link_flags(rosload "/ignore:4078 /ignore:4254 /DRIVER /FIXED")
|
add_target_link_flags(rosload "/ignore:4078 /ignore:4254 /DRIVER")
|
||||||
else()
|
else()
|
||||||
add_target_link_flags(rosload "-Wl,--strip-all,--exclude-all-symbols")
|
add_target_link_flags(rosload "-Wl,--strip-all,--exclude-all-symbols,--dynamicbase,--pic-executable")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set_image_base(rosload 0x10000)
|
set_image_base(rosload 0x10000)
|
||||||
|
|
|
@ -677,8 +677,10 @@ ImgpLoadPEImage (
|
||||||
BOOLEAN First, ImageHashValid;
|
BOOLEAN First, ImageHashValid;
|
||||||
UCHAR LocalBuffer[1024];
|
UCHAR LocalBuffer[1024];
|
||||||
UCHAR TrustedBootInformation[52];
|
UCHAR TrustedBootInformation[52];
|
||||||
|
ULONG WorkaroundForBinutils;
|
||||||
|
|
||||||
/* Initialize locals */
|
/* Initialize locals */
|
||||||
|
WorkaroundForBinutils = 0;
|
||||||
LocalFile = NULL;
|
LocalFile = NULL;
|
||||||
ImageBuffer = NULL;
|
ImageBuffer = NULL;
|
||||||
FileSize = 0;
|
FileSize = 0;
|
||||||
|
@ -881,6 +883,7 @@ ImgpLoadPEImage (
|
||||||
|
|
||||||
/* Record our current position (right after the headers) */
|
/* Record our current position (right after the headers) */
|
||||||
EndOfHeaders = (ULONG_PTR)VirtualAddress + HeaderSize;
|
EndOfHeaders = (ULONG_PTR)VirtualAddress + HeaderSize;
|
||||||
|
EfiPrintf(L"here\r\n");
|
||||||
|
|
||||||
/* Get the first section and iterate through each one */
|
/* Get the first section and iterate through each one */
|
||||||
Section = IMAGE_FIRST_SECTION(NtHeaders);
|
Section = IMAGE_FIRST_SECTION(NtHeaders);
|
||||||
|
@ -893,6 +896,7 @@ ImgpLoadPEImage (
|
||||||
if ((VirtualSize < Section->VirtualAddress) ||
|
if ((VirtualSize < Section->VirtualAddress) ||
|
||||||
((PVOID)SectionStart < VirtualAddress))
|
((PVOID)SectionStart < VirtualAddress))
|
||||||
{
|
{
|
||||||
|
EfiPrintf(L"fail 1\r\n");
|
||||||
Status = STATUS_INVALID_IMAGE_FORMAT;
|
Status = STATUS_INVALID_IMAGE_FORMAT;
|
||||||
goto Quickie;
|
goto Quickie;
|
||||||
}
|
}
|
||||||
|
@ -940,6 +944,7 @@ ImgpLoadPEImage (
|
||||||
&SectionEnd);
|
&SectionEnd);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
|
EfiPrintf(L"fail 21\r\n");
|
||||||
Status = STATUS_INVALID_IMAGE_FORMAT;
|
Status = STATUS_INVALID_IMAGE_FORMAT;
|
||||||
goto Quickie;
|
goto Quickie;
|
||||||
}
|
}
|
||||||
|
@ -957,6 +962,7 @@ ImgpLoadPEImage (
|
||||||
&SectionEnd);
|
&SectionEnd);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
|
EfiPrintf(L"fail 31\r\n");
|
||||||
Status = STATUS_INVALID_IMAGE_FORMAT;
|
Status = STATUS_INVALID_IMAGE_FORMAT;
|
||||||
goto Quickie;
|
goto Quickie;
|
||||||
}
|
}
|
||||||
|
@ -974,6 +980,20 @@ ImgpLoadPEImage (
|
||||||
/* Are we in the first iteration? */
|
/* Are we in the first iteration? */
|
||||||
if (!First)
|
if (!First)
|
||||||
{
|
{
|
||||||
|
/* FUCK YOU BINUTILS */
|
||||||
|
if ((*(PULONG)&Section->Name == 'ler.') && (RawSize < AlignSize))
|
||||||
|
{
|
||||||
|
/* Piece of shit won't build relocations when you tell it to,
|
||||||
|
* either by using --emit-relocs or --dynamicbase. People online
|
||||||
|
* have found out that by using -pie-executable you can get this
|
||||||
|
* to happen, but then it turns out that the .reloc section is
|
||||||
|
* incorrectly sized, and results in a corrupt PE. However, they
|
||||||
|
* still compute the checksum using the correct value. What idiots.
|
||||||
|
*/
|
||||||
|
WorkaroundForBinutils = AlignSize - RawSize;
|
||||||
|
AlignSize -= WorkaroundForBinutils;
|
||||||
|
}
|
||||||
|
|
||||||
/* Yes, read the section data */
|
/* Yes, read the section data */
|
||||||
Status = ImgpReadAtFileOffset(LocalFile,
|
Status = ImgpReadAtFileOffset(LocalFile,
|
||||||
AlignSize,
|
AlignSize,
|
||||||
|
@ -994,6 +1014,7 @@ ImgpLoadPEImage (
|
||||||
AlignSize,
|
AlignSize,
|
||||||
BL_UTL_CHECKSUM_COMPLEMENT |
|
BL_UTL_CHECKSUM_COMPLEMENT |
|
||||||
BL_UTL_CHECKSUM_USHORT_BUFFER);
|
BL_UTL_CHECKSUM_USHORT_BUFFER);
|
||||||
|
AlignSize += WorkaroundForBinutils;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1075,7 +1096,7 @@ ImgpLoadPEImage (
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Finally, calculate the final checksum and compare it */
|
/* Finally, calculate the final checksum and compare it */
|
||||||
FinalSum = FileSize + PartialSum;
|
FinalSum = FileSize + PartialSum + WorkaroundForBinutils;
|
||||||
if ((FinalSum != CheckSum) && (PartialSum == 0xFFFF))
|
if ((FinalSum != CheckSum) && (PartialSum == 0xFFFF))
|
||||||
{
|
{
|
||||||
/* It hit overflow, so set it to the file size */
|
/* It hit overflow, so set it to the file size */
|
||||||
|
@ -1148,9 +1169,6 @@ ImgpLoadPEImage (
|
||||||
*ImageSize = VirtualSize;
|
*ImageSize = VirtualSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
EfiPrintf(L"MORE PE TODO: %lx\r\n", NtHeaders->OptionalHeader.AddressOfEntryPoint);
|
|
||||||
EfiStall(100000000);
|
|
||||||
|
|
||||||
Quickie:
|
Quickie:
|
||||||
/* Check if we computed the image hash OK */
|
/* Check if we computed the image hash OK */
|
||||||
if (ImageHashValid)
|
if (ImageHashValid)
|
||||||
|
|
Loading…
Reference in a new issue