From: Nicholas Nethercote Date: Sun, 29 May 2005 17:01:48 +0000 (+0000) Subject: Modularised m_redir. As a side-effect, managed to remove X-Git-Tag: svn/VALGRIND_3_0_0~510 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e6f34bdb71291be8285f5c6498ce33faa1fef4a3;p=thirdparty%2Fvalgrind.git Modularised m_redir. As a side-effect, managed to remove $PLATFORM/core_platform.c and $PLATFORM/libplatform.a, hooray. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3808 --- diff --git a/coregrind/Makefile.am b/coregrind/Makefile.am index 6c8430945b..ade1a6d469 100644 --- a/coregrind/Makefile.am +++ b/coregrind/Makefile.am @@ -45,6 +45,7 @@ noinst_HEADERS = \ pub_core_hashtable.h \ pub_core_mallocfree.h \ pub_core_options.h \ + pub_core_redir.h \ pub_core_replacemalloc.h\ pub_core_sigframe.h \ pub_core_skiplist.h \ @@ -79,6 +80,7 @@ stage2_SOURCES = \ m_hashtable.c \ m_mallocfree.c \ m_options.c \ + m_redir.c \ m_skiplist.c \ m_stacktrace.c \ m_tooliface.c \ @@ -95,19 +97,16 @@ stage2_SOURCES = \ vg_symtab2.c \ vg_threadmodel.c \ vg_pthreadmodel.c \ - vg_redir.c \ vg_dwarf.c \ vg_stabs.c \ vg_symtypes.c -## libplatform.a must be before libarch.a and libos.a, it seems. stage2_extra= \ m_dispatch/libdispatch.a \ m_demangle/libdemangle.a \ m_aspacemgr/libaspacemgr.a \ m_sigframe/libsigframe.a \ m_syscalls/libsyscalls.a \ - ${VG_PLATFORM}/libplatform.a \ ${VG_ARCH}/libarch.a \ ${VG_OS}/libos.a \ @VEX_DIR@/libvex.a diff --git a/coregrind/amd64-linux/Makefile.am b/coregrind/amd64-linux/Makefile.am index 58b3a7328b..96f3688d63 100644 --- a/coregrind/amd64-linux/Makefile.am +++ b/coregrind/amd64-linux/Makefile.am @@ -4,9 +4,3 @@ include $(top_srcdir)/Makefile.core-AM_CPPFLAGS.am noinst_HEADERS = \ core_platform.h \ vki_unistd.h - -noinst_LIBRARIES = libplatform.a - - -libplatform_a_SOURCES = \ - core_platform.c diff --git a/coregrind/amd64-linux/core_platform.c b/coregrind/amd64-linux/core_platform.c deleted file mode 100644 index d420b839fb..0000000000 --- a/coregrind/amd64-linux/core_platform.c +++ /dev/null @@ -1,10 +0,0 @@ -#include "core.h" - -void VGP_(setup_redirects)(void) -{ - /* Redirect vsyscalls to local versions */ - VG_(add_redirect_addr_to_addr)(0xFFFFFFFFFF600000ULL, - VG_(client_trampoline_code)+VG_(tramp_gettimeofday_offset)); - VG_(add_redirect_addr_to_addr)(0xFFFFFFFFFF600400ULL, - VG_(client_trampoline_code)+VG_(tramp_time_offset)); -} diff --git a/coregrind/arm-linux/Makefile.am b/coregrind/arm-linux/Makefile.am index cb4cb1f896..96f3688d63 100644 --- a/coregrind/arm-linux/Makefile.am +++ b/coregrind/arm-linux/Makefile.am @@ -4,8 +4,3 @@ include $(top_srcdir)/Makefile.core-AM_CPPFLAGS.am noinst_HEADERS = \ core_platform.h \ vki_unistd.h - -noinst_LIBRARIES = libplatform.a - -libplatform_a_SOURCES = - diff --git a/coregrind/core.h b/coregrind/core.h index 795a0c3ce4..104390cf96 100644 --- a/coregrind/core.h +++ b/coregrind/core.h @@ -488,45 +488,6 @@ extern Bool VG_(use_CFI_info) ( /*MOD*/Addr* ipP, Addr max_accessible ); -/* --------------------------------------------------------------------- - Exports of vg_redir.c - ------------------------------------------------------------------ */ - -/* Redirection machinery */ -extern Addr VG_(code_redirect) ( Addr orig ); - -/* Set up some default redirects */ -extern void VG_(setup_code_redirect_table) ( void ); - -extern void VG_(add_redirect_sym_to_addr)(const Char *from_lib, - const Char *from_sym, - Addr to_addr); -extern void VG_(add_redirect_addr_to_addr)(Addr from_addr, Addr to_addr); -extern void VG_(resolve_seg_redirs)(SegInfo *si); - -/* Wrapping machinery */ -enum return_type { - RT_RETURN, - RT_LONGJMP, - RT_EXIT, -}; - -typedef struct _FuncWrapper FuncWrapper; -struct _FuncWrapper { - void *(*before)(va_list args); - void (*after) (void *nonce, enum return_type, Word retval); -}; - -extern void VG_(wrap_function)(Addr eip, const FuncWrapper *wrapper); -extern const FuncWrapper *VG_(is_wrapped)(Addr eip); -extern Bool VG_(is_wrapper_return)(Addr eip); - -/* Primary interface for adding wrappers for client-side functions. */ -extern CodeRedirect *VG_(add_wrapper)(const Char *from_lib, const Char *from_sym, - const FuncWrapper *wrapper); - -extern Bool VG_(is_resolved)(const CodeRedirect *redir); - /* --------------------------------------------------------------------- Exports of vg_main.c ------------------------------------------------------------------ */ @@ -688,13 +649,6 @@ extern void VGA_(final_tidyup)(ThreadId tid); extern Bool VGA_(client_requests)(ThreadId tid, UWord *args); -// --------------------------------------------------------------------- -// Platform-specific things defined in eg. x86/*.c -// --------------------------------------------------------------------- - -// Do any platform specific redirects. -extern void VGP_(setup_redirects)(void); - ///* --------------------------------------------------------------------- // Thread modelling // ------------------------------------------------------------------ */ diff --git a/coregrind/vg_redir.c b/coregrind/m_redir.c similarity index 96% rename from coregrind/vg_redir.c rename to coregrind/m_redir.c index 1214e5839f..6ffbb8ecdf 100644 --- a/coregrind/vg_redir.c +++ b/coregrind/m_redir.c @@ -35,6 +35,7 @@ #include "pub_core_aspacemgr.h" #include "pub_core_skiplist.h" #include "pub_core_options.h" +#include "pub_core_redir.h" #include "pub_core_transtab.h" /*------------------------------------------------------------*/ @@ -490,8 +491,23 @@ void VG_(setup_code_redirect_table) ( void ) add_redirect_sym_to_sym("soname:ld-linux-x86-64.so.2", "strlen", "*vgpreload_memcheck.so*", "strlen"); -} +#if defined(VGP_x86_linux) + /* Redirect _dl_sysinfo_int80, which is glibc's default system call + routine, to the routine in our trampoline page so that the + special sysinfo unwind hack in m_stacktrace.c will kick in. */ + VG_(add_redirect_sym_to_addr)("soname:ld-linux.so.2", "_dl_sysinfo_int80", + VG_(client_trampoline_code)+VG_(tramp_syscall_offset)); +#elif defined(VGP_amd64_linux) + /* Redirect vsyscalls to local versions */ + VG_(add_redirect_addr_to_addr)(0xFFFFFFFFFF600000ULL, + VG_(client_trampoline_code)+VG_(tramp_gettimeofday_offset)); + VG_(add_redirect_addr_to_addr)(0xFFFFFFFFFF600400ULL, + VG_(client_trampoline_code)+VG_(tramp_time_offset)); +#else +# error Unknown platform +#endif +} //:: /*------------------------------------------------------------*/ //:: /*--- General function wrapping. ---*/ diff --git a/coregrind/m_translate.c b/coregrind/m_translate.c index ee20139a85..8f04780dd0 100644 --- a/coregrind/m_translate.c +++ b/coregrind/m_translate.c @@ -32,6 +32,7 @@ #include "core.h" #include "pub_core_aspacemgr.h" #include "pub_core_options.h" +#include "pub_core_redir.h" #include "pub_core_tooliface.h" #include "pub_core_translate.h" #include "pub_core_transtab.h" diff --git a/coregrind/vg_main.c b/coregrind/vg_main.c index 7c1eb6f6a4..f181423cb7 100644 --- a/coregrind/vg_main.c +++ b/coregrind/vg_main.c @@ -37,6 +37,7 @@ #include "pub_core_errormgr.h" #include "pub_core_execontext.h" #include "pub_core_options.h" +#include "pub_core_redir.h" #include "pub_core_syscalls.h" #include "pub_core_tooliface.h" #include "pub_core_transtab.h" @@ -2794,7 +2795,6 @@ int main(int argc, char **argv, char **envp) //-------------------------------------------------------------- VG_(debugLog)(1, "main", "Initialise redirects\n"); VG_(setup_code_redirect_table)(); - VGP_(setup_redirects)(); //-------------------------------------------------------------- // Verbosity message diff --git a/coregrind/vg_symtab2.c b/coregrind/vg_symtab2.c index eb788e2192..80bdaaa0bf 100644 --- a/coregrind/vg_symtab2.c +++ b/coregrind/vg_symtab2.c @@ -36,6 +36,7 @@ #include "pub_core_aspacemgr.h" #include "pub_core_demangle.h" #include "pub_core_options.h" +#include "pub_core_redir.h" #include "pub_core_tooliface.h" #include /* ELF defns */ diff --git a/coregrind/x86-linux/Makefile.am b/coregrind/x86-linux/Makefile.am index 58b3a7328b..96f3688d63 100644 --- a/coregrind/x86-linux/Makefile.am +++ b/coregrind/x86-linux/Makefile.am @@ -4,9 +4,3 @@ include $(top_srcdir)/Makefile.core-AM_CPPFLAGS.am noinst_HEADERS = \ core_platform.h \ vki_unistd.h - -noinst_LIBRARIES = libplatform.a - - -libplatform_a_SOURCES = \ - core_platform.c diff --git a/coregrind/x86-linux/core_platform.c b/coregrind/x86-linux/core_platform.c deleted file mode 100644 index 7e064197eb..0000000000 --- a/coregrind/x86-linux/core_platform.c +++ /dev/null @@ -1,11 +0,0 @@ -#include "core.h" - -void VGP_(setup_redirects)(void) -{ - /* Redirect _dl_sysinfo_int80, which is glibc's default system call - routine, to the routine in our trampoline page so that the - special sysinfo unwind hack in vg_execontext.c will kick in. - */ - VG_(add_redirect_sym_to_addr)("soname:ld-linux.so.2", "_dl_sysinfo_int80", - VG_(client_trampoline_code)+VG_(tramp_syscall_offset)); -}