Module Name:    src
Committed By:   kamil
Date:           Fri Sep 11 01:08:36 UTC 2020

Modified Files:
        src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common:
            sanitizer_getauxval.h

Log Message:
Add getauxval() compat for NetBSD

Cherry-pick and adapt:

commit 02519fc7a6f8c528f67975a9f78ce64dabf402b4
Author: Kamil Rytarowski <n...@gmx.com>
Date:   Thu Sep 12 18:57:58 2019 +0000

    Add getauxval() compat for NetBSD

    Summary:
    getauxval() is not available on NetBSD and there is no a direct equivalent.

    Add a function that implements the same semantics with NetBSD internals.

    Reorder the GetPageSize() functions to prefer the sysctl approach for 
NetBSD.
    It no longer makes a difference which approach is better. Avoid changing
    conditional code path.

    Reviewers: vitalybuka, dvyukov, mgorny, joerg

    Reviewed By: vitalybuka

    Subscribers: llvm-commits, #sanitizers

    Tags: #sanitizers, #llvm

    Differential Revision: https://reviews.llvm.org/D67329

    llvm-svn: 371758


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r1.2 \
    
src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_getauxval.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_getauxval.h
diff -u src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_getauxval.h:1.1.1.1 src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_getauxval.h:1.2
--- src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_getauxval.h:1.1.1.1	Sat Sep  5 07:52:57 2020
+++ src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_getauxval.h	Fri Sep 11 01:08:36 2020
@@ -8,6 +8,7 @@
 // Common getauxval() guards and definitions.
 // getauxval() is not defined until glibc version 2.16, or until API level 21
 // for Android.
+// Implement the getauxval() compat function for NetBSD.
 //
 //===----------------------------------------------------------------------===//
 
@@ -41,6 +42,23 @@ extern "C" SANITIZER_WEAK_ATTRIBUTE
 unsigned long getauxval(unsigned long type);  // NOLINT
 # endif
 
-#endif // SANITIZER_LINUX || SANITIZER_FUCHSIA
+#elif SANITIZER_NETBSD
+
+#define SANITIZER_USE_GETAUXVAL 1
+
+#include <dlfcn.h>
+#include <elf.h>
+
+static inline decltype(AuxInfo::a_v) getauxval(decltype(AuxInfo::a_type) type) {
+  for (const AuxInfo *aux = (const AuxInfo *)_dlauxinfo();
+       aux->a_type != AT_NULL; ++aux) {
+    if (type == aux->a_type)
+      return aux->a_v;
+  }
+
+  return 0;
+}
+
+#endif
 
 #endif // SANITIZER_GETAUXVAL_H

Reply via email to