From 461c64db9e1e8a035b2ab3663e8305e1a8268fe9 Mon Sep 17 00:00:00 2001 From: Kalesh Singh Date: Thu, 24 Aug 2023 23:36:30 -0700 Subject: [PATCH] bionic: libdl_cfi: Remove PAGE_SIZE usage Use max_page_size() for build time variable alignments instead of PAGE_SIZE. In the 4k targets there is no functional difference since max_page_size() == page_size() == 4096. On a 16kb device max_page_size() == 65536 and page_size() == 16384. However, aligning up does not incur any memory regressions since the .bss/.data sections are still be backed in PAGE_SIZE'ed chunks. See: go/16k-page-aligned-variables Bug: 296275298 Test: mma Change-Id: Ic944235d8a5742a51a8fb0f2a0b75e532f404110 Signed-off-by: Kalesh Singh --- libdl/libdl_cfi.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libdl/libdl_cfi.cpp b/libdl/libdl_cfi.cpp index 3b68fc7d3..23cd7f53a 100644 --- a/libdl/libdl_cfi.cpp +++ b/libdl/libdl_cfi.cpp @@ -26,15 +26,15 @@ __attribute__((__weak__, visibility("default"))) extern "C" void __loader_cfi_fa // dlopen/dlclose. static struct { uintptr_t v; - char padding[PAGE_SIZE - sizeof(v)]; -} shadow_base_storage alignas(PAGE_SIZE); + char padding[max_page_size() - sizeof(v)]; +} shadow_base_storage alignas(max_page_size()); // __cfi_init is called by the loader as soon as the shadow is mapped. This may happen very early // during startup, before libdl.so global constructors, and, on i386, even before __libc_sysinfo is // initialized. This function should not do any system calls. extern "C" uintptr_t* __cfi_init(uintptr_t shadow_base) { shadow_base_storage.v = shadow_base; - static_assert(sizeof(shadow_base_storage) == PAGE_SIZE, ""); + static_assert(sizeof(shadow_base_storage) == max_page_size(), ""); return &shadow_base_storage.v; }