* 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.
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)
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;
}
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 ---*/
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
</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>
{
DebugInfo* dinfo;
const HChar* soname;
- if (0) return False;
dinfo = VG_(find_DebugInfo)( ga );
if (!dinfo) return False;
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
#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
/*--------------------------------------------------------------------*/