Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common Add get...



details:   https://anonhg.NetBSD.org/src/rev/30b4e0891e73
branches:  trunk
changeset: 954782:30b4e0891e73
user:      kamil <kamil%NetBSD.org@localhost>
date:      Fri Sep 11 01:08:36 2020 +0000

description:
Add getauxval() compat for NetBSD

Cherry-pick and adapt:

commit 02519fc7a6f8c528f67975a9f78ce64dabf402b4
Author: Kamil Rytarowski <n54%gmx.com@localhost>
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

diffstat:

 external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_getauxval.h |  20 +++++++++-
 1 files changed, 19 insertions(+), 1 deletions(-)

diffs (36 lines):

diff -r 8405cd57507c -r 30b4e0891e73 external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_getauxval.h
--- a/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_getauxval.h        Fri Sep 11 01:07:53 2020 +0000
+++ b/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_getauxval.h        Fri Sep 11 01:08:36 2020 +0000
@@ -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 @@
 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



Home | Main Index | Thread Index | Old Index