VDSOSupport: Use getauxval() on Android API >= 18 Previously ABSL_HAVE_GETAUXVAL was only enabled for glibc >= 2.16, so VDSOSupport::Init() on Android fell back to opening and reading /proc/self/auxv. Bionic has provided getauxval() in <sys/auxv.h> since Android API 18, returning 0 and setting errno to ENOENT when an entry is absent (matching glibc). Defining ABSL_HAVE_GETAUXVAL for Android API >= 18 avoids filesystem syscalls and works safely when VDSOSupport is initialized lazily inside a signal handler or restricted sandbox. See https://android.googlesource.com/platform/bionic/+/main/docs/status.md#libc PiperOrigin-RevId: 1033240465
diff --git a/absl/debugging/internal/address_is_readable.cc b/absl/debugging/internal/address_is_readable.cc index 88aa516..18c0170 100644 --- a/absl/debugging/internal/address_is_readable.cc +++ b/absl/debugging/internal/address_is_readable.cc
@@ -21,7 +21,7 @@ #include "absl/base/config.h" -#if !defined(__linux__) || defined(__ANDROID__) +#if !defined(__linux__) namespace absl { ABSL_NAMESPACE_BEGIN @@ -34,7 +34,7 @@ ABSL_NAMESPACE_END } // namespace absl -#else // __linux__ && !__ANDROID__ +#else // __linux__ #include <stdint.h> #include <syscall.h> @@ -99,4 +99,4 @@ ABSL_NAMESPACE_END } // namespace absl -#endif // __linux__ && !__ANDROID__ +#endif // __linux__
diff --git a/absl/debugging/internal/vdso_support.cc b/absl/debugging/internal/vdso_support.cc index fb9d359..74fd9ee 100644 --- a/absl/debugging/internal/vdso_support.cc +++ b/absl/debugging/internal/vdso_support.cc
@@ -35,8 +35,11 @@ #endif #include <unistd.h> -#if !defined(__UCLIBC__) && defined(__GLIBC__) && \ - (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 16)) +#if !defined(__UCLIBC__) && \ + ((defined(__GLIBC__) && \ + (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 16))) || \ + (defined(__ANDROID__) && defined(__ANDROID_API__) && \ + __ANDROID_API__ >= 18)) #define ABSL_HAVE_GETAUXVAL #endif