summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorHeinrich Schuchardt <xypron.glpk@gmx.de>2018-04-03 23:29:32 +0300
committerAlexander Graf <agraf@suse.de>2018-04-04 12:37:40 +0300
commit82786754b9d21a05a70c45ff7e9e48c91745f837 (patch)
tree1f9299cd02e0bf640a86e2ba20922d48be9fa0e8 /lib
parent84b40b40ad9b95b4680766597c866b604147144c (diff)
downloadu-boot-82786754b9d21a05a70c45ff7e9e48c91745f837.tar.xz
efi_loader: ImageSize must be multiple of SectionAlignment
According to the Portable Executable and Common Object File Format Specification the image size must be a multiple of the alignment of sections. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'lib')
-rw-r--r--lib/efi_loader/efi_image_loader.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/efi_loader/efi_image_loader.c b/lib/efi_loader/efi_image_loader.c
index 701387b95f..74c6a9f921 100644
--- a/lib/efi_loader/efi_image_loader.c
+++ b/lib/efi_loader/efi_image_loader.c
@@ -175,6 +175,7 @@ void *efi_load_pe(void *efi, struct efi_loaded_image *loaded_image_info)
entry = efi_reloc + opt->AddressOfEntryPoint;
rel_size = opt->DataDirectory[rel_idx].Size;
rel = efi_reloc + opt->DataDirectory[rel_idx].VirtualAddress;
+ virt_size = ALIGN(virt_size, opt->SectionAlignment);
} else if (can_run_nt32 &&
(nt->OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC)) {
IMAGE_OPTIONAL_HEADER32 *opt = &nt->OptionalHeader;
@@ -190,6 +191,7 @@ void *efi_load_pe(void *efi, struct efi_loaded_image *loaded_image_info)
entry = efi_reloc + opt->AddressOfEntryPoint;
rel_size = opt->DataDirectory[rel_idx].Size;
rel = efi_reloc + opt->DataDirectory[rel_idx].VirtualAddress;
+ virt_size = ALIGN(virt_size, opt->SectionAlignment);
} else {
printf("%s: Invalid optional header magic %x\n", __func__,
nt->OptionalHeader.Magic);