]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Fix up the libc_freeres_wrapper code so that m_main depends on m_redir,
authorNicholas Nethercote <njn@valgrind.org>
Sun, 19 Jun 2005 18:58:03 +0000 (18:58 +0000)
committerNicholas Nethercote <njn@valgrind.org>
Sun, 19 Jun 2005 18:58:03 +0000 (18:58 +0000)
not the other way around.

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

coregrind/m_main.c
coregrind/m_redir.c
coregrind/pub_core_main.h
coregrind/pub_core_redir.h

index bb43b62ff44cea9fa717b599df65c8ed5124c68c..881e765f57afb8a24b92f855f396f4333cf3f274 100644 (file)
@@ -2759,26 +2759,19 @@ int main(int argc, char **argv, char **envp)
 }
 
 
-/* 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  ||
index b78350bed44e9c04b3b1e9343a487c500d9e1a0d..e7c72304704661e82ca7539ca2b19cd5de7dd465 100644 (file)
@@ -36,7 +36,6 @@
 #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"
@@ -512,6 +511,13 @@ static void handle_replacement_function( Char* symbol, Addr addr )
    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.
@@ -521,7 +527,7 @@ static void handle_replacement_function( Char* symbol, Addr addr )
 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
index 0e1f59b4243e40a69bf5f5e1bcb48e4c4a9883b9..c47e1f263a7a38fab4a6ce1d6753c54032ef24ec 100644 (file)
@@ -48,9 +48,6 @@ Char* VG_(build_child_exename)     ( void );
 /* 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) (
index d734d450624a5420b201a017875c9cb06a748237..59743e1f3c0dea6ff2f1c07b875dd4b6542bf9f9 100644 (file)
@@ -89,6 +89,8 @@ extern void VG_(resolve_seg_redirs)(SegInfo *si);
 #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