mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-27 16:01:27 +00:00
efi_loader: rounding of image size
We should not first allocate memory and then report a rounded up value as
image size. Instead first round up according to section allocation and then
allocate the memory.
Fixes: 82786754b9
("efi_loader: ImageSize must be multiple of SectionAlignment")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
This commit is contained in:
parent
1ea133acd6
commit
f3a343d733
1 changed files with 2 additions and 2 deletions
|
@ -898,6 +898,7 @@ efi_status_t efi_load_pe(struct efi_loaded_image_obj *handle,
|
||||||
image_base = opt->ImageBase;
|
image_base = opt->ImageBase;
|
||||||
efi_set_code_and_data_type(loaded_image_info, opt->Subsystem);
|
efi_set_code_and_data_type(loaded_image_info, opt->Subsystem);
|
||||||
handle->image_type = opt->Subsystem;
|
handle->image_type = opt->Subsystem;
|
||||||
|
virt_size = ALIGN(virt_size, opt->SectionAlignment);
|
||||||
efi_reloc = efi_alloc(virt_size,
|
efi_reloc = efi_alloc(virt_size,
|
||||||
loaded_image_info->image_code_type);
|
loaded_image_info->image_code_type);
|
||||||
if (!efi_reloc) {
|
if (!efi_reloc) {
|
||||||
|
@ -908,12 +909,12 @@ efi_status_t efi_load_pe(struct efi_loaded_image_obj *handle,
|
||||||
handle->entry = efi_reloc + opt->AddressOfEntryPoint;
|
handle->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 (nt->OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
|
} else if (nt->OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
|
||||||
IMAGE_OPTIONAL_HEADER32 *opt = &nt->OptionalHeader;
|
IMAGE_OPTIONAL_HEADER32 *opt = &nt->OptionalHeader;
|
||||||
image_base = opt->ImageBase;
|
image_base = opt->ImageBase;
|
||||||
efi_set_code_and_data_type(loaded_image_info, opt->Subsystem);
|
efi_set_code_and_data_type(loaded_image_info, opt->Subsystem);
|
||||||
handle->image_type = opt->Subsystem;
|
handle->image_type = opt->Subsystem;
|
||||||
|
virt_size = ALIGN(virt_size, opt->SectionAlignment);
|
||||||
efi_reloc = efi_alloc(virt_size,
|
efi_reloc = efi_alloc(virt_size,
|
||||||
loaded_image_info->image_code_type);
|
loaded_image_info->image_code_type);
|
||||||
if (!efi_reloc) {
|
if (!efi_reloc) {
|
||||||
|
@ -924,7 +925,6 @@ efi_status_t efi_load_pe(struct efi_loaded_image_obj *handle,
|
||||||
handle->entry = efi_reloc + opt->AddressOfEntryPoint;
|
handle->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 {
|
||||||
log_err("Invalid optional header magic %x\n",
|
log_err("Invalid optional header magic %x\n",
|
||||||
nt->OptionalHeader.Magic);
|
nt->OptionalHeader.Magic);
|
||||||
|
|
Loading…
Add table
Reference in a new issue