Skip to content

Commit 771698b

Browse files
authored
[compiler-rt] Use getpagesize for Android.
1 parent 08d3387 commit 771698b

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp

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

85-
# if SANITIZER_ANDROID && __ANDROID_API__ < 35
86-
// The weak `strerrorname_np` (introduced in API level 35) definition,
87-
// allows for checking the API level at runtime.
88-
extern "C" SANITIZER_WEAK_ATTRIBUTE const char *strerrorname_np(int);
89-
# endif
90-
9185
# if SANITIZER_LINUX && defined(__loongarch__)
9286
# include <sys/sysmacros.h>
9387
# endif
@@ -1219,17 +1213,11 @@ uptr GetPageSize() {
12191213
int rv = internal_sysctl(mib, 2, &pz, &pzl, nullptr, 0);
12201214
CHECK_EQ(rv, 0);
12211215
return (uptr)pz;
1216+
# elif SANITIZER_ANDROID
1217+
// Using `getpagesize` because calling `getauxval` or `sysconf` from the
1218+
// `.preinit_array` can cause crashes on some older API levels.
1219+
return getpagesize();
12221220
# elif SANITIZER_USE_GETAUXVAL
1223-
# if SANITIZER_ANDROID && __ANDROID_API__ < 35
1224-
// The 16 KB page size was introduced in Android 15 (API level 35), while
1225-
// earlier versions of Android always used a 4 KB page size.
1226-
// We are checking the weak definition of `strerrorname_np` (introduced in API
1227-
// level 35) because some earlier API levels crashed when
1228-
// `getauxval(AT_PAGESZ)` was called from the `.preinit_array`.
1229-
if (!strerrorname_np)
1230-
return 4096;
1231-
# endif
1232-
12331221
return getauxval(AT_PAGESZ);
12341222
# else
12351223
return sysconf(_SC_PAGESIZE); // EXEC_PAGESIZE may not be trustworthy.

0 commit comments

Comments
 (0)