diff options
| author | Nicholas Bishop <nicholasbishop@google.com> | 2022-12-20 14:40:39 -0500 |
|---|---|---|
| committer | Peter Jones <pjones@redhat.com> | 2023-01-27 14:18:13 -0500 |
| commit | e4f40ae862b5389c8cc7d4f938a34238421456a1 (patch) | |
| tree | d42b5fcfc543a5f89a7790e7575c4b0319b5e876 /include | |
| parent | c7b305152802c8db688605654f75e1195def9fd6 (diff) | |
| download | efi-boot-shim-e4f40ae862b5389c8cc7d4f938a34238421456a1.tar.gz efi-boot-shim-e4f40ae862b5389c8cc7d4f938a34238421456a1.zip | |
pe: Add IS_PAGE_ALIGNED macro
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>
Diffstat (limited to 'include')
| -rw-r--r-- | include/peimage.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/include/peimage.h b/include/peimage.h index e97b29c4..6eef1051 100644 --- a/include/peimage.h +++ b/include/peimage.h @@ -29,6 +29,9 @@ #define ALIGN_VALUE(Value, Alignment) ((Value) + (((Alignment) - (Value)) & ((Alignment) - 1)))
#define ALIGN_POINTER(Pointer, Alignment) ((VOID *) (ALIGN_VALUE ((UINTN)(Pointer), (Alignment))))
+// Check if `val` is evenly aligned to the page size.
+#define IS_PAGE_ALIGNED(val) (!((val) & EFI_PAGE_MASK))
+
//
// PE32+ Subsystem type for EFI images
//
|
