mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-23 13:56:20 +00:00
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>
This commit is contained in:
parent
84b40b40ad
commit
82786754b9
1 changed files with 2 additions and 0 deletions
|
@ -175,6 +175,7 @@ void *efi_load_pe(void *efi, struct efi_loaded_image *loaded_image_info)
|
||||||
entry = efi_reloc + opt->AddressOfEntryPoint;
|
entry = efi_reloc + opt->AddressOfEntryPoint;
|
||||||
rel_size = opt->DataDirectory[rel_idx].Size;
|
rel_size = opt->DataDirectory[rel_idx].Size;
|
||||||
rel = efi_reloc + opt->DataDirectory[rel_idx].VirtualAddress;
|
rel = efi_reloc + opt->DataDirectory[rel_idx].VirtualAddress;
|
||||||
|
virt_size = ALIGN(virt_size, opt->SectionAlignment);
|
||||||
} else if (can_run_nt32 &&
|
} else if (can_run_nt32 &&
|
||||||
(nt->OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC)) {
|
(nt->OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC)) {
|
||||||
IMAGE_OPTIONAL_HEADER32 *opt = &nt->OptionalHeader;
|
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;
|
entry = efi_reloc + opt->AddressOfEntryPoint;
|
||||||
rel_size = opt->DataDirectory[rel_idx].Size;
|
rel_size = opt->DataDirectory[rel_idx].Size;
|
||||||
rel = efi_reloc + opt->DataDirectory[rel_idx].VirtualAddress;
|
rel = efi_reloc + opt->DataDirectory[rel_idx].VirtualAddress;
|
||||||
|
virt_size = ALIGN(virt_size, opt->SectionAlignment);
|
||||||
} else {
|
} else {
|
||||||
printf("%s: Invalid optional header magic %x\n", __func__,
|
printf("%s: Invalid optional header magic %x\n", __func__,
|
||||||
nt->OptionalHeader.Magic);
|
nt->OptionalHeader.Magic);
|
||||||
|
|
Loading…
Add table
Reference in a new issue