[PATCH] Add interceptor for 'textdomain' function
Alexander Taran
alextaran at google.com
Mon Dec 2 05:19:47 PST 2013
Fixed
Hi glider, eugenis,
http://llvm-reviews.chandlerc.com/D2300
CHANGE SINCE LAST DIFF
http://llvm-reviews.chandlerc.com/D2300?vs=5837&id=5843#toc
Files:
lib/tsan/rtl/tsan_stat.cc
lib/tsan/rtl/tsan_stat.h
lib/sanitizer_common/sanitizer_common_interceptors.inc
lib/sanitizer_common/sanitizer_platform_interceptors.h
lib/msan/lit_tests/textdomain.cc
Index: lib/tsan/rtl/tsan_stat.cc
===================================================================
--- lib/tsan/rtl/tsan_stat.cc
+++ lib/tsan/rtl/tsan_stat.cc
@@ -126,6 +126,7 @@
name[StatInt_strlen] = " strlen ";
name[StatInt_memset] = " memset ";
name[StatInt_memcpy] = " memcpy ";
+ name[StatInt_textdomain] = " textdomain ";
name[StatInt_strcmp] = " strcmp ";
name[StatInt_memchr] = " memchr ";
name[StatInt_memrchr] = " memrchr ";
Index: lib/tsan/rtl/tsan_stat.h
===================================================================
--- lib/tsan/rtl/tsan_stat.h
+++ lib/tsan/rtl/tsan_stat.h
@@ -123,6 +123,7 @@
StatInt_strlen,
StatInt_memset,
StatInt_memcpy,
+ StatInt_textdomain,
StatInt_strcmp,
StatInt_memchr,
StatInt_memrchr,
Index: lib/sanitizer_common/sanitizer_common_interceptors.inc
===================================================================
--- lib/sanitizer_common/sanitizer_common_interceptors.inc
+++ lib/sanitizer_common/sanitizer_common_interceptors.inc
@@ -60,6 +60,22 @@
#define COMMON_INTERCEPTOR_HANDLE_RECVMSG(ctx, msg) ((void)(msg))
#endif
+#if SANITIZER_INTERCEPT_TEXTDOMAIN
+INTERCEPTOR(char*, textdomain, const char *domainname) {
+ void *ctx;
+ COMMON_INTERCEPTOR_ENTER(ctx, textdomain, domainname);
+ char* domain = REAL(textdomain)(domainname);
+ if (domain) {
+ COMMON_INTERCEPTOR_INITIALIZE_RANGE(ctx, domain,
+ REAL(strlen)(domain) + 1);
+ }
+ return domain;
+}
+#define INIT_TEXTDOMAIN COMMON_INTERCEPT_FUNCTION(textdomain)
+#else
+#define INIT_TEXTDOMAIN
+#endif
+
#if SANITIZER_INTERCEPT_STRCMP
static inline int CharCmpX(unsigned char c1, unsigned char c2) {
return (c1 == c2) ? 0 : (c1 < c2) ? -1 : 1;
@@ -2893,6 +2909,7 @@
#endif
#define SANITIZER_COMMON_INTERCEPTORS_INIT \
+ INIT_TEXTDOMAIN; \
INIT_STRCMP; \
INIT_STRNCMP; \
INIT_STRCASECMP; \
Index: lib/sanitizer_common/sanitizer_platform_interceptors.h
===================================================================
--- lib/sanitizer_common/sanitizer_platform_interceptors.h
+++ lib/sanitizer_common/sanitizer_platform_interceptors.h
@@ -48,6 +48,7 @@
#endif
# define SANITIZER_INTERCEPT_STRCMP 1
+# define SANITIZER_INTERCEPT_TEXTDOMAIN SI_LINUX_NOT_ANDROID
# define SANITIZER_INTERCEPT_STRCASECMP SI_NOT_WINDOWS
# define SANITIZER_INTERCEPT_READ SI_NOT_WINDOWS
Index: lib/msan/lit_tests/textdomain.cc
===================================================================
--- lib/msan/lit_tests/textdomain.cc
+++ lib/msan/lit_tests/textdomain.cc
@@ -0,0 +1,12 @@
+// RUN: %clangxx_msan -m64 -O0 -g %s -o %t && %t
+
+#include <libintl.h>
+#include <stdio.h>
+
+int main() {
+ const char *td = textdomain("abcd");
+ if (td[0] == 0) {
+ printf("Try read");
+ }
+ return 0;
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2300.2.patch
Type: text/x-patch
Size: 3178 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131202/c4ffa58b/attachment.bin>
More information about the llvm-commits
mailing list