]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
When searching for global public symbols (like for the somalloc
authorIvo Raisr <ivosh@ivosh.net>
Wed, 18 Nov 2015 20:38:37 +0000 (20:38 +0000)
committerIvo Raisr <ivosh@ivosh.net>
Wed, 18 Nov 2015 20:38:37 +0000 (20:38 +0000)
synonym symbols), exclude the dynamic (runtime) linker as it is very
special.
Fixes BZ#355454

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15728

NEWS
coregrind/m_redir.c
docs/xml/manual-core.xml
helgrind/hg_main.c
include/pub_tool_redir.h

diff --git a/NEWS b/NEWS
index abcc502377d16ae7038b91225b8b00d2c32c0bb9..812edd89fa184e2575ffcd918f24d0d3286dc256 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -20,7 +20,8 @@ n-i-bz Improved thread startup time significantly on non-Linux platforms.
 * Replacement/wrapping of malloc/new related functions is now done not just
   for system libraries by default, but for any globally defined malloc/new
   related function (both in shared libraries and staticly linked alternative
-  malloc implementations). To only intercept malloc/new related functions in
+  malloc implementations). Dynamic (runtime) linker is excluded, though.
+  To only intercept malloc/new related functions in
   system libraries use --soname-synonyms=somalloc=nouserintercepts (where
   "nouserintercepts" can be any non-existing library name).
   This new functionality is not implemented for darwin/macosx.
@@ -52,6 +53,7 @@ where XXXXXX is the bug number as listed below.
 354933  Fix documentation of --kernel-variant=android-no-hw-tls option
 355188  valgrind should intercept all malloc related global functions
 355455  expected stderr of test cases wrapmalloc and wrapmallocstatic overconstrained
+355454  do not intercept malloc related symbols from the runtime linker
 
 
 Release 3.11.0 (22 September 2015)
index 3d3f70ad2f4896269c7c5f434e2ceab28d329609..dcf1fb45ff0cb1bc89809a93242a83bb1375624a 100644 (file)
@@ -809,8 +809,19 @@ void generate_and_add_actives (
    anyMark = False;
    for (sp = specs; sp; sp = sp->next) {
       sp->done = False;
-      sp->mark = VG_(string_match)( sp->from_sopatt, 
-                                    VG_(DebugInfo_get_soname)(di) );
+      const HChar *soname = VG_(DebugInfo_get_soname)(di);
+
+      /* When searching for global public symbols (like for the somalloc
+         synonym symbols), exclude the dynamic (runtime) linker as it is very
+         special. See https://bugs.kde.org/show_bug.cgi?id=355454 */
+      if ((VG_(strcmp)(sp->from_sopatt, "*") == 0) &&
+          (sp->isGlobal == True) &&
+          VG_(is_soname_ld_so)(soname)) {
+         sp->mark = False;
+         continue;
+      }
+
+      sp->mark = VG_(string_match)( sp->from_sopatt, soname );
       anyMark = anyMark || sp->mark;
    }
 
@@ -1179,6 +1190,29 @@ Addr VG_(redir_do_lookup) ( Addr orig, Bool* isWrap )
    return r->to_addr;
 }
 
+/* Does the soname represent a dynamic (runtime) linker?
+   Considers various VG_U_LD* entries from pub_tool_redir.h. */
+Bool VG_(is_soname_ld_so) (const HChar *soname)
+{
+#  if defined(VGO_linux)
+   if (VG_STREQ(soname, VG_U_LD_LINUX_SO_3))         return True;
+   if (VG_STREQ(soname, VG_U_LD_LINUX_SO_2))         return True;
+   if (VG_STREQ(soname, VG_U_LD_LINUX_X86_64_SO_2))  return True;
+   if (VG_STREQ(soname, VG_U_LD64_SO_1))             return True;
+   if (VG_STREQ(soname, VG_U_LD64_SO_2))             return True;
+   if (VG_STREQ(soname, VG_U_LD_SO_1))               return True;
+   if (VG_STREQ(soname, VG_U_LD_LINUX_AARCH64_SO_1)) return True;
+   if (VG_STREQ(soname, VG_U_LD_LINUX_ARMHF_SO_3))   return True;
+#  elif defined(VGO_darwin)
+   if (VG_STREQ(soname, VG_U_DYLD)) return True;
+#  elif defined(VGO_solaris)
+   if (VG_STREQ(soname, VG_U_LD_SO_1)) return True;
+#  else
+#    error "Unsupported OS"
+#  endif
+
+   return False;
+}
 
 /*------------------------------------------------------------*/
 /*--- INITIALISATION                                       ---*/
index c80aab0be39438f8d64ac7bc00ff95b16b966c50..758e2f479cc7cbaa41550cdb19aa4ae7493a397d 100644 (file)
@@ -2322,7 +2322,7 @@ need to use them.</para>
       own versions.  Such replacements are normally done only in shared
       libraries whose soname matches a predefined soname pattern (e.g.
       <varname>libc.so*</varname> on linux).  By default, no
-      replacement is done for a statically linked library or for
+      replacement is done for a statically linked binary or for
       alternative libraries, except for the allocation functions
       (malloc, free, calloc, memalign, realloc, operator new, operator
       delete, etc.) Such allocation functions are intercepted by
@@ -2392,6 +2392,13 @@ need to use them.</para>
          </para>
        </listitem>
 
+      <listitem>
+         <para>Shared library of the dynamic (runtime) linker is excluded from
+         searching for global public symbols, such as those for the malloc
+         related functions (identified by <varname>somalloc</varname> synonym).
+         </para>
+      </listitem>
+
       </itemizedlist>
    </listitem>
   </varlistentry>
index ae6eec0abba56271c129945e700a7d2f8f67f5d4..9aed05afa259c8989cb787a06371d337472aeafd 100644 (file)
@@ -4589,7 +4589,6 @@ static Bool is_in_dynamic_linker_shared_object( Addr ga )
 {
    DebugInfo* dinfo;
    const HChar* soname;
-   if (0) return False;
 
    dinfo = VG_(find_DebugInfo)( ga );
    if (!dinfo) return False;
@@ -4598,23 +4597,7 @@ static Bool is_in_dynamic_linker_shared_object( Addr ga )
    tl_assert(soname);
    if (0) VG_(printf)("%s\n", soname);
 
-#  if defined(VGO_linux)
-   if (VG_STREQ(soname, VG_U_LD_LINUX_SO_3))        return True;
-   if (VG_STREQ(soname, VG_U_LD_LINUX_SO_2))        return True;
-   if (VG_STREQ(soname, VG_U_LD_LINUX_X86_64_SO_2)) return True;
-   if (VG_STREQ(soname, VG_U_LD64_SO_1))            return True;
-   if (VG_STREQ(soname, VG_U_LD64_SO_2))            return True;
-   if (VG_STREQ(soname, VG_U_LD_SO_1))              return True;
-   if (VG_STREQ(soname, VG_U_LD_LINUX_AARCH64_SO_1)) return True;
-   if (VG_STREQ(soname, VG_U_LD_LINUX_ARMHF_SO_3))  return True;
-#  elif defined(VGO_darwin)
-   if (VG_STREQ(soname, VG_U_DYLD)) return True;
-#  elif defined(VGO_solaris)
-   if (VG_STREQ(soname, VG_U_LD_SO_1)) return True;
-#  else
-#    error "Unsupported OS"
-#  endif
-   return False;
+   return VG_(is_soname_ld_so)(soname);
 }
 
 static
index 21d186b7b43d1a84cf960994075edeb3a9a9cf95..aa879d6362e323413b29d5c26d32833c6dbfece6 100644 (file)
 #define SO_SYN_MALLOC VG_SO_SYN(somalloc)
 #define SO_SYN_MALLOC_NAME "VgSoSynsomalloc"
 
+Bool VG_(is_soname_ld_so) (const HChar *soname);
+
 #endif   // __PUB_TOOL_REDIR_H
 
 /*--------------------------------------------------------------------*/