[PATCH] D54160: [sanitizer] Expose getauxval as weak declaration to fix TSanitizer-x86_64-Test-Nolibc

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 6 10:16:18 PST 2018


MaskRay created this revision.
MaskRay added reviewers: bkramer, pcc, dvyukov, kcc, vitalybuka.
Herald added subscribers: Sanitizers, llvm-commits, delcypher, kubamracek, srhines.

After https://reviews.llvm.org/rCRT346215, TSanitizer-x86_64-Test-Nolibc does not link as getauxval() is a libc dependency.

This patch unifies include <sys/auxv.h> and weak declaration to just use
the weak declaration. If SANITIZER_USE_GETAUXVAL is 1, getauxval() is
guaranteed to be non-null and we can use it for AT_BASE AT_EXECFN and
other purposes.


Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D54160

Files:
  lib/sanitizer_common/sanitizer_getauxval.h


Index: lib/sanitizer_common/sanitizer_getauxval.h
===================================================================
--- lib/sanitizer_common/sanitizer_getauxval.h
+++ lib/sanitizer_common/sanitizer_getauxval.h
@@ -33,15 +33,12 @@
 #  define SANITIZER_USE_GETAUXVAL 0
 # endif
 
-# if SANITIZER_USE_GETAUXVAL
-#  include <sys/auxv.h>
-# else
-// The weak getauxval definition allows to check for the function at runtime.
-// This is useful for Android, when compiled at a lower API level yet running
-// on a more recent platform that offers the function.
+// The weak getauxval definition allows to check for the function at runtime. It
+// guarantees to be non-null if SANITIZER_USE_GETAUXVAL is 1. This is useful for
+// Android, when compiled at a lower API level yet running on a more recent
+// platform that offers the function.
 extern "C" SANITIZER_WEAK_ATTRIBUTE
 unsigned long getauxval(unsigned long type);  // NOLINT
-# endif
 
 #endif // SANITIZER_LINUX || SANITIZER_FUCHSIA
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54160.172791.patch
Type: text/x-patch
Size: 992 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181106/0cbb33d2/attachment.bin>


More information about the llvm-commits mailing list