[compiler-rt] [compiler-rt] Fixed Android 8.1 `getauxval(AT_PAGESZ)` crashes if called from `.preinit_array`. (#113427) (PR #116121)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 5 20:11:05 PST 2024
================
@@ -82,6 +82,12 @@
# include <sys/personality.h>
# endif
+# if SANITIZER_ANDROID && __ANDROID_API__ < 35
+// The weak `strerrorname_np` (introduced in API level 35) definition,
+// allows for checking the API level at runtime.
----------------
funsafe-ptr wrote:
Does not work in `.preinit_array`.
```fish
❯ echo '#include <android/api-level.h>'\n'static int api_level;static void preinit_fn() {api_level=android_get_device_api_level();} void (*preinit[])()__attribute((section(".preinit_array")))={&preinit_fn};int main(){__builtin_printf("api_level on preinit: %i. on main: %i", api_level, android_get_device_api_level());}' | cc -x c -;./a.out
api_level on preinit: -1. on main: 27⏎
```
https://github.com/llvm/llvm-project/pull/116121
More information about the llvm-commits
mailing list