diff --git a/drd/drd_strmem_intercepts.c b/drd/drd_strmem_intercepts.c index 0873617aa..d2d51aaff 100644 --- a/drd/drd_strmem_intercepts.c +++ b/drd/drd_strmem_intercepts.c @@ -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 ---*/ /*--------------------------------------------------------------------*/