-
Notifications
You must be signed in to change notification settings - Fork 12.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[compiler-rt] Fixed Android 8.1 getauxval(AT_PAGESZ)
crashes if called from .preinit_array
. (#113427)
#116121
base: main
Are you sure you want to change the base?
Conversation
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
getauxval(AT_PAGESZ)
crashes if called from .preinit_array
. #113427 getauxval(AT_PAGESZ)
crashes if called from .preinit_array
. (#113427)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change status of PR from "Draft"
@@ -1237,6 +1242,12 @@ uptr GetPageSize() { | |||
CHECK_EQ(rv, 0); | |||
return (uptr)pz; | |||
# elif SANITIZER_USE_GETAUXVAL | |||
|
|||
# if SANITIZER_ANDROID && __ANDROID_API__ < 35 | |||
if (!strerrorname_np) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leave comment about the API level this was introduced by, and also add the fact that before that API level, the page size was always 4096
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is missing that strerrorname_np
was also introduced in Android 15 (reference is https://cs.android.com/android/platform/superproject/main/+/main:bionic/libc/libc.map.txt?q=strerrorname_np%20f:bionic%2Flibc%2Flibc.map.txt)
✅ With the latest revision this PR passed the C/C++ code formatter. |
@@ -1237,6 +1242,12 @@ uptr GetPageSize() { | |||
CHECK_EQ(rv, 0); | |||
return (uptr)pz; | |||
# elif SANITIZER_USE_GETAUXVAL | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: drop the blank line
@DanAlbert does this LGTY from NDK perspective to use a weak symbol to runtime detect API level? |
@llvm/pr-subscribers-compiler-rt-sanitizer Author: None (funsafe-ptr) ChangesFull diff: https://github.com/llvm/llvm-project/pull/116121.diff 1 Files Affected:
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
index 04b095dca904ab..344b16be4a96e0 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
@@ -82,6 +82,12 @@
# include <sys/personality.h>
# endif
+# if SANITIZER_ANDROID && __ANDROID_API__ < 35
+// The weak strerrorname_np definition allows to check for the API level at
+// runtime.
+extern "C" SANITIZER_WEAK_ATTRIBUTE const char* strerrorname_np(int);
+# endif
+
# if SANITIZER_LINUX && defined(__loongarch__)
# include <sys/sysmacros.h>
# endif
@@ -1237,6 +1243,13 @@ uptr GetPageSize() {
CHECK_EQ(rv, 0);
return (uptr)pz;
# elif SANITIZER_USE_GETAUXVAL
+# if SANITIZER_ANDROID && __ANDROID_API__ < 35
+ // The 16 KB page size was introduced in Android 15, while earlier versions
+ // of Android used a 4 KB page size.
+ if (!strerrorname_np)
+ return 4096;
+# endif
+
return getauxval(AT_PAGESZ);
# else
return sysconf(_SC_PAGESIZE); // EXEC_PAGESIZE may not be trustworthy.
|
FYI: "This commit is not signed, but one or more authors requires that any commit attributed to them is signed." |
75d2845
to
d7ce33f
Compare
…led from `.preinit_array`. (llvm#113427)
Signed-off-by: funsafe-ptr <[email protected]>
d7ce33f
to
8997cc5
Compare
I tested it on Termux using Android 8.1. termux/termux-packages#22369 (comment) |
No description provided.