rhboot / shim

UEFI shim loader
Other
819 stars 289 forks source link

pe: Add IS_PAGE_ALIGNED macro #541

Closed nicholasbishop closed 1 year ago

nicholasbishop commented 1 year ago

This makes some checks in get_mem_attrs and update_mem_attrs clearer.

Also add test-pe-util.c with a test for the new macro. The file is named that way instead of test-pe.c to avoid having to get pe.c building in the unit test environment.

Signed-off-by: Nicholas Bishop nicholasbishop@google.com

dennis-tseng99 commented 1 year ago

@Nicholasbishop Actually, there already has a definition #define EFI_PAGE_MASK 0xFFF in gnu-efi/inc/efidef.h. For example, you could use: if (physaddr & EFI_PAGE_MASK || size & EFI_PAGE_MASK || ...

vathpela commented 1 year ago

I've pushed this (with @dennis-tseng99's suggestion) as e4f40ae862b5389c8cc7d4f938a34238421456a1