Skip to content

Conversation

@funsafe-ptr
Copy link
Contributor

No description provided.

@github-actions
Copy link

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 @ followed by their GitHub username.

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.

@funsafe-ptr funsafe-ptr changed the title [compiler-rt] Fixed Android 8.1 getauxval(AT_PAGESZ) crashes if called from .preinit_array. #113427 [compiler-rt] Fixed Android 8.1 getauxval(AT_PAGESZ) crashes if called from .preinit_array. (#113427) Nov 13, 2024
@funsafe-ptr
Copy link
Contributor Author

@fmayer

Copy link
Contributor

@fmayer fmayer left a 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"

@github-actions
Copy link

github-actions bot commented Nov 22, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

@fmayer fmayer requested a review from DanAlbert November 23, 2024 00:08
@fmayer
Copy link
Contributor

fmayer commented Nov 23, 2024

@DanAlbert does this LGTY from NDK perspective to use a weak symbol to runtime detect API level?

@funsafe-ptr funsafe-ptr marked this pull request as ready for review November 23, 2024 00:08
@llvmbot
Copy link
Member

llvmbot commented Nov 23, 2024

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: None (funsafe-ptr)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/116121.diff

1 Files Affected:

  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp (+13)
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.

@fmayer
Copy link
Contributor

fmayer commented Nov 23, 2024

FYI: "This commit is not signed, but one or more authors requires that any commit attributed to them is signed."

@funsafe-ptr
Copy link
Contributor Author

I tested it on Termux using Android 8.1. termux/termux-packages#22369 (comment)

@funsafe-ptr
Copy link
Contributor Author

Ping

@fmayer
Copy link
Contributor

fmayer commented Jan 3, 2025

@DanAlbert please confirm this makes sense to you. thanks!

@funsafe-ptr
Copy link
Contributor Author

@DanAlbert Ping

1 similar comment
@funsafe-ptr
Copy link
Contributor Author

@DanAlbert Ping

@truboxl
Copy link

truboxl commented Feb 6, 2025

NDK r28 has been released. I am pretty sure this issue has been forgotten.

@fmayer fmayer merged commit 6575154 into llvm:main Feb 6, 2025
6 checks passed
@fmayer
Copy link
Contributor

fmayer commented Feb 6, 2025

@DanAlbert given so much time has passed, I merged this. Please let me know in case you have strong disagreements.

@github-actions
Copy link

github-actions bot commented Feb 6, 2025

@funsafe-ptr Congratulations on having your first Pull Request (PR) merged into the LLVM Project!

Your changes will be combined with recent changes from other authors, then tested by our build bots. If there is a problem with a build, you may receive a report in an email or a comment on this PR.

Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues.

How to do this, and the rest of the post-merge process, is covered in detail here.

If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again.

If you don't get any reports, no action is required from you. Your changes are working as expected, well done!

Icohedron pushed a commit to Icohedron/llvm-project that referenced this pull request Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants