|
From: <sv...@va...> - 2013-10-24 10:01:56
|
Author: bart
Date: Thu Oct 24 10:01:45 2013
New Revision: 13694
Log:
drd: Add stpcpy() intercept (#326436)
Modified:
trunk/drd/drd_strmem_intercepts.c
Modified: trunk/drd/drd_strmem_intercepts.c
==============================================================================
--- trunk/drd/drd_strmem_intercepts.c (original)
+++ trunk/drd/drd_strmem_intercepts.c Thu Oct 24 10:01:45 2013
@@ -37,6 +37,8 @@
#include "pub_tool_clreq.h"
+/*---------------------- strchr ----------------------*/
+
#define STRCHR(soname, fnname) \
char* VG_REPLACE_FUNCTION_ZU(soname,fnname)(const char* s, int c); \
char* VG_REPLACE_FUNCTION_ZU(soname,fnname)(const char* s, int c) \
@@ -65,6 +67,8 @@
#endif
+/*---------------------- strnlen ----------------------*/
+
#define STRNLEN(soname, fnname) \
SizeT VG_REPLACE_FUNCTION_ZU(soname,fnname) ( const char* str, SizeT n ); \
SizeT VG_REPLACE_FUNCTION_ZU(soname,fnname) ( const char* str, SizeT n ) \
@@ -81,6 +85,8 @@
#endif
+/*---------------------- strlen ----------------------*/
+
// Note that this replacement often doesn't get used because gcc inlines
// calls to strlen() with its own built-in version. This can be very
// confusing if you aren't expecting it. Other small functions in this file
@@ -104,6 +110,8 @@
#endif
+/*---------------------- strcpy ----------------------*/
+
#define STRCPY(soname, fnname) \
char* VG_REPLACE_FUNCTION_ZU(soname, fnname)(char* dst, const char* src); \
char* VG_REPLACE_FUNCTION_ZU(soname, fnname)(char* dst, const char* src) \
@@ -124,6 +132,8 @@
#endif
+/*---------------------- strcmp ----------------------*/
+
#define STRCMP(soname, fnname) \
int VG_REPLACE_FUNCTION_ZU(soname,fnname)(const char* s1, const char* s2); \
int VG_REPLACE_FUNCTION_ZU(soname,fnname)(const char* s1, const char* s2) \
@@ -152,6 +162,8 @@
#endif
+/*---------------------- memcpy ----------------------*/
+
#define MEMCPY(soname, fnname) \
void* VG_REPLACE_FUNCTION_ZU(soname,fnname) \
(void *dst, const void *src, SizeT len); \
@@ -246,6 +258,33 @@
#endif
+/*---------------------- stpcpy ----------------------*/
+
+/* Copy SRC to DEST, returning the address of the terminating '\0' in
+ DEST. (minor variant of strcpy) */
+#define STPCPY(soname, fnname) \
+ char* VG_REPLACE_FUNCTION_EZU(20200,soname,fnname) \
+ (char* dst, const char* src); \
+ char* VG_REPLACE_FUNCTION_EZU(20200,soname,fnname) \
+ (char* dst, const char* src) \
+ { \
+ while (*src) *dst++ = *src++; \
+ *dst = 0; \
+ \
+ return dst; \
+ }
+
+#if defined(VGO_linux)
+ STPCPY(VG_Z_LIBC_SONAME, stpcpy)
+ STPCPY(VG_Z_LIBC_SONAME, __GI_stpcpy)
+ STPCPY(VG_Z_LD_LINUX_SO_2, stpcpy)
+ STPCPY(VG_Z_LD_LINUX_X86_64_SO_2, stpcpy)
+#elif defined(VGO_darwin)
+ //STPCPY(VG_Z_LIBC_SONAME, stpcpy)
+ //STPCPY(VG_Z_DYLD, stpcpy)
+#endif
+
+
/*--------------------------------------------------------------------*/
/*--- end ---*/
/*--------------------------------------------------------------------*/
|