You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On the IA32 target, this doesn't work properly because the ImageSize field is not correctly aligned. ImageSize is a UINT64. Fields are supposed to be "naturally aligned". Naturally the spec doesn't bother to specify exactly what "naturally aligned" means, but other toolchains such as EDK2 seem to think it means a UINT64 should be 8-byte aligned.
In other words, offsetof(EFI_LOADED_IMAGE, ImageSize) on IA32 is 40 in EDK2, but 36 in shim due to the missing padding.
This changes the alignment of UINT64 data to 8 bytes on IA32, which
matches EDK2's understanding of alignment. In particular this change
affects the offset where shim writes `EFI_LOADED_IMAGE.ImageSize`.
Fixesrhboot#515
Signed-off-by: Nicholas Bishop <[email protected]>
This changes the alignment of UINT64 data to 8 bytes on IA32, which
matches EDK2's understanding of alignment. In particular this change
affects the offset where shim writes `EFI_LOADED_IMAGE.ImageSize`.
Fixes#515
Signed-off-by: Nicholas Bishop <[email protected]>
brianredbeard
pushed a commit
to brianredbeard/redhat-efi-boot-shim
that referenced
this issue
Feb 22, 2024
This changes the alignment of UINT64 data to 8 bytes on IA32, which
matches EDK2's understanding of alignment. In particular this change
affects the offset where shim writes `EFI_LOADED_IMAGE.ImageSize`.
Fixesrhboot#515
Signed-off-by: Nicholas Bishop <[email protected]>
In pe.c, it sets the
ImageBase
andImageSize
inEFI_LOADED_IMAGE
for the second stage: https://github.com/rhboot/shim/blob/main/pe.c#L1394On the IA32 target, this doesn't work properly because the
ImageSize
field is not correctly aligned.ImageSize
is aUINT64
. Fields are supposed to be "naturally aligned". Naturally the spec doesn't bother to specify exactly what "naturally aligned" means, but other toolchains such as EDK2 seem to think it means aUINT64
should be 8-byte aligned.In other words,
offsetof(EFI_LOADED_IMAGE, ImageSize)
on IA32 is 40 in EDK2, but 36 in shim due to the missing padding.I think a straightforward fix would be to add
-malign-double
on IA32 (as EDK2 does), which will align "double, long double, and long long variables on a two-word boundary".The text was updated successfully, but these errors were encountered: