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 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/coregrind/Makefile.am b/coregrind/Makefile.am
index 6c84309..ade1a6d 100644
--- a/coregrind/Makefile.am
+++ b/coregrind/Makefile.am
@@ -45,6 +45,7 @@
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 @@
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 @@
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 58b3a73..96f3688 100644
--- a/coregrind/amd64-linux/Makefile.am
+++ b/coregrind/amd64-linux/Makefile.am
@@ -4,9 +4,3 @@
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 d420b83..0000000
--- 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 cb4cb1f..96f3688 100644
--- a/coregrind/arm-linux/Makefile.am
+++ b/coregrind/arm-linux/Makefile.am
@@ -4,8 +4,3 @@
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 795a0c3..104390c 100644
--- a/coregrind/core.h
+++ b/coregrind/core.h
@@ -489,45 +489,6 @@
/* ---------------------------------------------------------------------
- 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 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 1214e58..6ffbb8e 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 @@
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 ee20139..8f04780 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 7c1eb6f..f181423 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 @@
//--------------------------------------------------------------
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 eb788e2..80bdaaa 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.h> /* ELF defns */
diff --git a/coregrind/x86-linux/Makefile.am b/coregrind/x86-linux/Makefile.am
index 58b3a73..96f3688 100644
--- a/coregrind/x86-linux/Makefile.am
+++ b/coregrind/x86-linux/Makefile.am
@@ -4,9 +4,3 @@
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 7e06419..0000000
--- 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));
-}