Skip to content

Commit da104df

Browse files
committed
[compiler-rt] Fixed Android 8.1 getauxval(AT_PAGESZ) crashes if called from .preinit_array. (#113427)
1 parent 5ac624c commit da104df

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@
8282
# include <sys/personality.h>
8383
# endif
8484

85+
# if SANITIZER_ANDROID && __ANDROID_API__ < 35
86+
// The weak strerrorname_np definition allows to check for the API level at runtime.
87+
extern "C" SANITIZER_WEAK_ATTRIBUTE const char* strerrorname_np(int);
88+
# endif
89+
8590
# if SANITIZER_LINUX && defined(__loongarch__)
8691
# include <sys/sysmacros.h>
8792
# endif
@@ -1214,6 +1219,12 @@ uptr GetPageSize() {
12141219
CHECK_EQ(rv, 0);
12151220
return (uptr)pz;
12161221
# elif SANITIZER_USE_GETAUXVAL
1222+
1223+
# if SANITIZER_ANDROID && __ANDROID_API__ < 35
1224+
if (!strerrorname_np)
1225+
return 4096;
1226+
# endif
1227+
12171228
return getauxval(AT_PAGESZ);
12181229
# else
12191230
return sysconf(_SC_PAGESIZE); // EXEC_PAGESIZE may not be trustworthy.

0 commit comments

Comments
 (0)