-
Notifications
You must be signed in to change notification settings - Fork 332
Closed
Description
Seen mokmanager image load failure "2 sections contain entry point" for shim built on Oracle Linux 9 aarch64:
pe.c:574:generate_hash() 00000010 08 56 85 05 fa 24 3b 9f 9f f0 51 ed 20 fc c6 fc |.V...$;...Q. ...|
pe.c:1192:handle_image() Loading 0xC3000 bytes at 0x238237000
2 sections contain entry point
Failed to load image: Unsupported
Root cause of this failure is supposedly incorrect entry points detection.
In pe.c:handle_image() found_entry_point counter uses SizeOfRawData to calculate image section boundary:
| if (Section->VirtualAddress <= context.EntryPoint && | |
| (Section->VirtualAddress + Section->SizeOfRawData - 1) | |
| > context.EntryPoint) | |
| found_entry_point++; |
According to PE spec:
VirtualSize
The total size of the section when loaded into memory. If this value is greater than SizeOfRawData,
the section is zero-padded. This field is valid only for executable images and should be set to zero for object files.
SizeOfRawData
The size of the section (for object files) or the size of the initialized data on disk (for image files). For executable
images, this must be a multiple of FileAlignment from the optional header. If this is less than VirtualSize, the remainder
of the section is zero-filled. Because the SizeOfRawData field is rounded but the VirtualSize field is not, it is possible
for SizeOfRawData to be greater than VirtualSize as well. When a section contains only uninitialized data, this field should be zero.
Proposed replacing Section->SizeOfRawData to Section->Misc.VirtualSize as it should define actual size of the section loaded in memory.
Metadata
Metadata
Assignees
Labels
No labels