summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorNicholas Bishop <nicholasbishop@google.com>2022-12-20 14:40:39 -0500
committerPeter Jones <pjones@redhat.com>2023-01-27 14:18:13 -0500
commite4f40ae862b5389c8cc7d4f938a34238421456a1 (patch)
treed42b5fcfc543a5f89a7790e7575c4b0319b5e876 /include
parentc7b305152802c8db688605654f75e1195def9fd6 (diff)
downloadefi-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.h3
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
//