[compiler-rt] r348369 - Add a new interceptor for nl_langinfo(3) from NetBSD
Kamil Rytarowski via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 5 07:06:53 PST 2018
Author: kamil
Date: Wed Dec 5 07:06:53 2018
New Revision: 348369
URL: http://llvm.org/viewvc/llvm-project?rev=348369&view=rev
Log:
Add a new interceptor for nl_langinfo(3) from NetBSD
Summary:
nl_langinfo - gets locale information.
Add a dedicated test.
Reviewers: vitalybuka, joerg
Reviewed By: vitalybuka
Subscribers: kubamracek, llvm-commits, mgorny, #sanitizers
Tags: #sanitizers
Differential Revision: https://reviews.llvm.org/D55015
Added:
compiler-rt/trunk/test/sanitizer_common/TestCases/NetBSD/nl_langinfo.cc
Modified:
compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc?rev=348369&r1=348368&r2=348369&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc Wed Dec 5 07:06:53 2018
@@ -7664,6 +7664,19 @@ INTERCEPTOR(int, sysctlgetmibinfo, char
#define INIT_SYSCTLGETMIBINFO
#endif
+#if SANITIZER_INTERCEPT_NL_LANGINFO
+INTERCEPTOR(char *, nl_langinfo, long item) {
+ void *ctx;
+ COMMON_INTERCEPTOR_ENTER(ctx, nl_langinfo, item);
+ char *ret = REAL(nl_langinfo)(item);
+ if (ret)
+ COMMON_INTERCEPTOR_WRITE_RANGE(ctx, ret, REAL(strlen)(ret) + 1);
+ return ret;
+}
+#define INIT_NL_LANGINFO COMMON_INTERCEPT_FUNCTION(nl_langinfo)
+#else
+#define INIT_NL_LANGINFO
+#endif
static void InitializeCommonInterceptors() {
static u64 metadata_mem[sizeof(MetadataHashMap) / sizeof(u64) + 1];
@@ -7927,6 +7940,7 @@ static void InitializeCommonInterceptors
INIT_SYSCTL;
INIT_ASYSCTL;
INIT_SYSCTLGETMIBINFO;
+ INIT_NL_LANGINFO;
INIT___PRINTF_CHK;
}
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h?rev=348369&r1=348368&r2=348369&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h Wed Dec 5 07:06:53 2018
@@ -520,6 +520,7 @@
SI_LINUX || SI_MAC)
#define SANITIZER_INTERCEPT_GETMNTINFO SI_NETBSD
#define SANITIZER_INTERCEPT_MI_VECTOR_HASH SI_NETBSD
+#define SANITIZER_INTERCEPT_NL_LANGINFO SI_NETBSD
#define SANITIZER_INTERCEPT_GETVFSSTAT SI_NETBSD
#define SANITIZER_INTERCEPT_REGEX SI_NETBSD
#define SANITIZER_INTERCEPT_FTS SI_NETBSD
Added: compiler-rt/trunk/test/sanitizer_common/TestCases/NetBSD/nl_langinfo.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/sanitizer_common/TestCases/NetBSD/nl_langinfo.cc?rev=348369&view=auto
==============================================================================
--- compiler-rt/trunk/test/sanitizer_common/TestCases/NetBSD/nl_langinfo.cc (added)
+++ compiler-rt/trunk/test/sanitizer_common/TestCases/NetBSD/nl_langinfo.cc Wed Dec 5 07:06:53 2018
@@ -0,0 +1,18 @@
+// RUN: %clangxx -O0 -g %s -o %t && %run %t 2>&1 | FileCheck %s
+
+#include <langinfo.h>
+
+#include <stdio.h>
+
+int main(void) {
+ printf("nl_langinfo\n");
+
+ char *info = nl_langinfo(DAY_1);
+
+ printf("DAY_1='%s'\n", info);
+
+ // CHECK: nl_langinfo
+ // CHECK: DAY_1='{{.*}}'
+
+ return 0;
+}
More information about the llvm-commits
mailing list