bionic: max_android_page_size to 16384
The maximum page size Android supports now is 16384, and Art only supports 16kB, so we can save a bit of space. Bug: 332556665 Test: N/A Change-Id: I23df607bcc5cf9e96d7b6a66169413cd1a883f7e
This commit is contained in:
parent
d06e2e7b29
commit
8401230be6
4 changed files with 13 additions and 11 deletions
|
@ -240,7 +240,7 @@ __LIBC_HIDDEN__ void pthread_key_clean_all(void);
|
|||
// On LP64, we could use more but there's no obvious advantage to doing
|
||||
// so, and the various media processes use RLIMIT_AS as a way to limit
|
||||
// the amount of allocation they'll do.
|
||||
#define PTHREAD_GUARD_SIZE max_page_size()
|
||||
#define PTHREAD_GUARD_SIZE max_android_page_size()
|
||||
|
||||
// SIGSTKSZ (8KiB) is not big enough.
|
||||
// An snprintf to a stack buffer of size PATH_MAX consumes ~7KiB of stack.
|
||||
|
|
|
@ -32,11 +32,13 @@ inline size_t page_size() {
|
|||
#endif
|
||||
}
|
||||
|
||||
constexpr size_t max_page_size() {
|
||||
// The maximum page size supported on any Android device. As
|
||||
// of API level 35, this is limited by ART.
|
||||
constexpr size_t max_android_page_size() {
|
||||
#if defined(PAGE_SIZE)
|
||||
return PAGE_SIZE;
|
||||
#else
|
||||
return 65536;
|
||||
return 16384;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -30,11 +30,11 @@
|
|||
template <typename T>
|
||||
union WriteProtectedContents {
|
||||
T value;
|
||||
char padding[max_page_size()];
|
||||
char padding[max_android_page_size()];
|
||||
|
||||
WriteProtectedContents() = default;
|
||||
BIONIC_DISALLOW_COPY_AND_ASSIGN(WriteProtectedContents);
|
||||
} __attribute__((aligned(max_page_size())));
|
||||
} __attribute__((aligned(max_android_page_size())));
|
||||
|
||||
// Write protected wrapper class that aligns its contents to a page boundary,
|
||||
// and sets the memory protection to be non-writable, except when being modified
|
||||
|
@ -42,8 +42,8 @@ union WriteProtectedContents {
|
|||
template <typename T>
|
||||
class WriteProtected {
|
||||
public:
|
||||
static_assert(sizeof(T) < max_page_size(),
|
||||
"WriteProtected only supports contents up to max_page_size()");
|
||||
static_assert(sizeof(T) < max_android_page_size(),
|
||||
"WriteProtected only supports contents up to max_android_page_size()");
|
||||
|
||||
WriteProtected() = default;
|
||||
BIONIC_DISALLOW_COPY_AND_ASSIGN(WriteProtected);
|
||||
|
@ -89,7 +89,7 @@ class WriteProtected {
|
|||
// ourselves.
|
||||
addr = untag_address(addr);
|
||||
#endif
|
||||
if (mprotect(reinterpret_cast<void*>(addr), max_page_size(), prot) == -1) {
|
||||
if (mprotect(reinterpret_cast<void*>(addr), max_android_page_size(), prot) == -1) {
|
||||
async_safe_fatal("WriteProtected mprotect %x failed: %s", prot, strerror(errno));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,15 +26,15 @@ __attribute__((__weak__, visibility("default"))) extern "C" void __loader_cfi_fa
|
|||
// dlopen/dlclose.
|
||||
static struct {
|
||||
uintptr_t v;
|
||||
char padding[max_page_size() - sizeof(v)];
|
||||
} shadow_base_storage alignas(max_page_size());
|
||||
char padding[max_android_page_size() - sizeof(v)];
|
||||
} shadow_base_storage alignas(max_android_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) == max_page_size(), "");
|
||||
static_assert(sizeof(shadow_base_storage) == max_android_page_size(), "");
|
||||
return &shadow_base_storage.v;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue