not the other way around.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3956
}
-/* The we need to know the address of it so it can be
- called at program exit. */
-static Addr __libc_freeres_wrapper;
-
-void VG_(set_libc_freeres_wrapper_addr)(Addr addr)
-{
- __libc_freeres_wrapper = addr;
-}
-
/* Final clean-up before terminating the process.
Clean up the client by calling __libc_freeres() (if requested)
This is Linux-specific?
*/
static void final_tidyup(ThreadId tid)
{
+ Addr __libc_freeres_wrapper;
+
vg_assert(VG_(is_running_thread)(tid));
- if (!VG_(needs).libc_freeres ||
- !VG_(clo_run_libc_freeres) ||
- __libc_freeres_wrapper == 0)
+ if ( !VG_(needs).libc_freeres ||
+ !VG_(clo_run_libc_freeres) ||
+ 0 == (__libc_freeres_wrapper = VG_(get_libc_freeres_wrapper)()) )
return; /* can't/won't do it */
if (VG_(clo_verbosity) > 2 ||
#include "pub_core_libcbase.h"
#include "pub_core_libcassert.h"
#include "pub_core_libcprint.h"
-#include "pub_core_main.h" // for VG_(set_libc_freeres_wrapper_addr)
#include "pub_core_mallocfree.h"
#include "pub_core_options.h"
#include "pub_core_redir.h"
VG_(arena_free)(VG_AR_SYMTAB, lib);
}
+static Addr __libc_freeres_wrapper = 0;
+
+Addr VG_(get_libc_freeres_wrapper)(void)
+{
+ return __libc_freeres_wrapper;
+}
+
// This is specifically for stringifying VG_(x) function names. We
// need to do two macroexpansions to get the VG_ macro expanded before
// stringifying.
static void handle_load_notifier( Char* symbol, Addr addr )
{
if (VG_(strcmp)(symbol, STR(VG_NOTIFY_ON_LOAD(freeres))) == 0)
- VG_(set_libc_freeres_wrapper_addr)(addr);
+ __libc_freeres_wrapper = addr;
// else if (VG_(strcmp)(symbol, STR(VG_WRAPPER(pthread_startfunc_wrapper))) == 0)
// VG_(pthread_startfunc_wrapper)((Addr)(si->offset + sym->st_value));
else
/* Something of a function looking for a home ... start up debugger. */
extern void VG_(start_debugger) ( ThreadId tid );
-// Set up the libc freeres wrapper
-extern void VG_(set_libc_freeres_wrapper_addr)(Addr);
-
// Do everything which needs doing before the process finally ends,
// like printing reports, etc
extern void VG_(shutdown_actions_NORETURN) (
#define VG_NOTIFY_ON_LOAD_PREFIX "_vgw_"
#define VG_NOTIFY_ON_LOAD_PREFIX_LEN 5
+// Called by m_main to get our __libc_freeres wrapper.
+extern Addr VG_(get_libc_freeres_wrapper)(void);
//--------------------------------------------------------------------
// Function wrapping