From 81ddcd09c3a742851e9974529cf20df700741df3 Mon Sep 17 00:00:00 2001 From: Alex Ionescu Date: Sat, 4 Feb 2017 19:45:38 +0000 Subject: [PATCH] [BOOTMGR]: ThFabba making me jealous. Fix a logic bug that Coverity *didn't* find. Ha. I'm better. [BOOTLIB]: Apply the "Fuck You Binutils" hack only for ld-generated files, to unbreak MSVC UEFI boot. svn path=/trunk/; revision=73684 --- reactos/boot/environ/app/bootmgr/bootmgr.c | 2 +- reactos/boot/environ/lib/misc/image.c | 24 ++++++++++++---------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/reactos/boot/environ/app/bootmgr/bootmgr.c b/reactos/boot/environ/app/bootmgr/bootmgr.c index bbd9577da30..0fb3c6b6d8e 100644 --- a/reactos/boot/environ/app/bootmgr/bootmgr.c +++ b/reactos/boot/environ/app/bootmgr/bootmgr.c @@ -2276,7 +2276,7 @@ BmpTransferExecution ( BcdLibraryDevice_ApplicationDevice, &AppDevice, NULL); - if (NT_SUCCESS(Status)) + if (!NT_SUCCESS(Status)) { /* Force re-enumeration */ Status = BlFwEnumerateDevice(AppDevice); diff --git a/reactos/boot/environ/lib/misc/image.c b/reactos/boot/environ/lib/misc/image.c index 3889f3e6f2c..55d9bd858df 100644 --- a/reactos/boot/environ/lib/misc/image.c +++ b/reactos/boot/environ/lib/misc/image.c @@ -883,7 +883,6 @@ ImgpLoadPEImage ( /* Record our current position (right after the headers) */ EndOfHeaders = (ULONG_PTR)VirtualAddress + HeaderSize; - EfiPrintf(L"here\r\n"); /* Get the first section and iterate through each one */ Section = IMAGE_FIRST_SECTION(NtHeaders); @@ -981,17 +980,20 @@ ImgpLoadPEImage ( if (!First) { /* FUCK YOU BINUTILS */ - if ((*(PULONG)&Section->Name == 'ler.') && (RawSize < AlignSize)) + if (NtHeaders->OptionalHeader.MajorLinkerVersion < 7) { - /* 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; + 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 */ -- 2.17.1