Use the redir machinery to forcibly remap stpcpy in libc.so.6 to our
own version in mac_replace_strmem.c.  We have to do this the hard way
because overenthusiastic PLT bypassing in glibc means the usual
symbol-override stuff doesn't work.  IOW, for the usual reason that we
have to use the redir machinery at all.

This makes many programs run much more quietly on SuSE 9.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2139 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/coregrind/vg_symtab2.c b/coregrind/vg_symtab2.c
index bed06c4..35bddcb 100644
--- a/coregrind/vg_symtab2.c
+++ b/coregrind/vg_symtab2.c
@@ -2106,6 +2106,11 @@
    redir->to_sym = VG_(arena_strdup)(VG_AR_SYMTAB, to_sym);
    redir->to_addr = 0;
 
+   if (VG_(clo_verbosity) >= 2)
+      VG_(message)(Vg_UserMsg, 
+                   "REDIRECT %s(%s) to %s(%s)",
+                   from_lib, from_sym, to_lib, to_sym);
+
    if (!resolve_redir_allsegs(redir)) {
       /* can't resolve immediately; add to list */
       redir->next = unresolved_redir;
@@ -2163,13 +2168,14 @@
    for(i = 0; i < sizeof(redirects)/sizeof(*redirects); i++) {
       VG_(add_redirect_sym)("soname:libc.so.6",		redirects[i].from,
 			    "soname:libpthread.so.0",	redirects[i].to);
-
-      if (VG_(clo_verbosity) >= 2)
-         VG_(message)(Vg_UserMsg, 
-		      "REPLACING libc(%s) with libpthread(%s)",
-		      redirects[i].from, redirects[i].to);
    }
 
+   /* Overenthusiastic use of PLT bypassing by the glibc people also
+      means we need to patch the following functions to our own
+      implementations of said, in mac_replace_strmem.c.
+    */
+   VG_(add_redirect_sym)("soname:libc.so.6", "stpcpy",
+			 "*vgpreload_memcheck.so*", "stpcpy");
 }
 
 /*------------------------------------------------------------*/