diff --git a/compiler-rt/lib/fuzzer/FuzzerUtil.h b/compiler-rt/lib/fuzzer/FuzzerUtil.h --- a/compiler-rt/lib/fuzzer/FuzzerUtil.h +++ b/compiler-rt/lib/fuzzer/FuzzerUtil.h @@ -16,6 +16,10 @@ #include "FuzzerCommand.h" #include "FuzzerDefs.h" +#if SANITIZER_USE_GETAUXVAL +#include +#endif + namespace fuzzer { void PrintHexArray(const Unit &U, const char *PrintAfter = ""); @@ -94,7 +98,14 @@ return static_cast((sizeof(unsigned long long) * 8) - Clzll(X) - 1); } -inline size_t PageSize() { return 4096; } +inline size_t PageSize() { +#if SANITIZER_USE_GETAUXVAL + return getauxval(AT_PAGESZ); +#else + return 4096; +#endif +} + inline uint8_t *RoundUpByPage(uint8_t *P) { uintptr_t X = reinterpret_cast(P); size_t Mask = PageSize() - 1;