diff --git a/NEWS b/NEWS
index abcc50237..812edd89f 100644
--- 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)
diff --git a/coregrind/m_redir.c b/coregrind/m_redir.c
index 3d3f70ad2..dcf1fb45f 100644
--- a/coregrind/m_redir.c
+++ b/coregrind/m_redir.c
@@ -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 ---*/
diff --git a/docs/xml/manual-core.xml b/docs/xml/manual-core.xml
index c80aab0be..758e2f479 100644
--- a/docs/xml/manual-core.xml
+++ b/docs/xml/manual-core.xml
@@ -2322,7 +2322,7 @@ need to use them.
own versions. Such replacements are normally done only in shared
libraries whose soname matches a predefined soname pattern (e.g.
libc.so* 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.
+
+ 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 somalloc synonym).
+
+
+
diff --git a/helgrind/hg_main.c b/helgrind/hg_main.c
index ae6eec0ab..9aed05afa 100644
--- a/helgrind/hg_main.c
+++ b/helgrind/hg_main.c
@@ -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
diff --git a/include/pub_tool_redir.h b/include/pub_tool_redir.h
index 21d186b7b..aa879d636 100644
--- a/include/pub_tool_redir.h
+++ b/include/pub_tool_redir.h
@@ -351,6 +351,8 @@
#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
/*--------------------------------------------------------------------*/