summaryrefslogtreecommitdiff
path: root/shim.c
diff options
context:
space:
mode:
authorArd Biesheuvel <ard.biesheuvel@linaro.org>2014-08-13 13:35:38 +0200
committerPeter Jones <pjones@redhat.com>2014-08-27 11:49:39 -0400
commit94c9a77f6504170a6bd38b0aa29039208987650e (patch)
tree5d0aa843d82884f76197c805547ecbc4cf6278ec /shim.c
parent14acaa4a3361403e06b284bf8e1e32ad9cec5457 (diff)
downloadefi-boot-shim-94c9a77f6504170a6bd38b0aa29039208987650e.tar.gz
efi-boot-shim-94c9a77f6504170a6bd38b0aa29039208987650e.zip
Handle empty .reloc section in PE/COFF loader
On archs where no EFI aware objcopy is available, the generated PE/COFF header contains a .reloc section which is completely empty. Handle this by - returning early from relocate_coff() with EFI_SUCCESS, - ignoring discardable sections in the section loader. Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Diffstat (limited to 'shim.c')
-rw-r--r--shim.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/shim.c b/shim.c
index ea8eba81..1329212a 100644
--- a/shim.c
+++ b/shim.c
@@ -145,6 +145,9 @@ static EFI_STATUS relocate_coff (PE_COFF_LOADER_IMAGE_CONTEXT *context,
return EFI_UNSUPPORTED;
}
+ if (!context->RelocDir->Size)
+ return EFI_SUCCESS;
+
RelocBase = ImageAddress(data, size, context->RelocDir->VirtualAddress);
RelocBaseEnd = ImageAddress(data, size, context->RelocDir->VirtualAddress + context->RelocDir->Size - 1);
@@ -996,7 +999,11 @@ static EFI_STATUS handle_image (void *data, unsigned int datasize,
* Copy the executable's sections to their desired offsets
*/
Section = context.FirstSection;
- for (i = 0; i < context.NumberOfSections; i++) {
+ for (i = 0; i < context.NumberOfSections; i++, Section++) {
+ if (Section->Characteristics & 0x02000000)
+ /* section has EFI_IMAGE_SCN_MEM_DISCARDABLE attr set */
+ continue;
+
size = Section->Misc.VirtualSize;
if (size > Section->SizeOfRawData)
@@ -1021,8 +1028,6 @@ static EFI_STATUS handle_image (void *data, unsigned int datasize,
if (size < Section->Misc.VirtualSize)
ZeroMem (base + size, Section->Misc.VirtualSize - size);
-
- Section += 1;
}
/*