Add a new mechanism for intercepting calls, which doesn't depend on
the vagaries of the dynamic linker.  In particular this has been
devised so as to work around errno/h_errno/resolver-state misbehaviour
caused by excessive PLT bypassing in glibc-2.3.2: we need to intercept
calls to __errno_location(), __h_errno_location() and __res_state(),
in threaded programs, but we can't always do that because some calls
made internally within glibc-2.3.2 bypass the PLT.

New mechanism is:

- In vg_symtab2.c, VG_(setup_code_redirect_table), search the
  symbol tables to find the entry points of the above functions,
  and find the corresponding entry points replacements in our
  vg_libpthread.c.  Put these pairs into a table,
  VG_(code_redirect_table).

- In vg_translate.c, VG_(translate), consult the table each time
  a translation is made, and if a hit is found, translate from
  the substitute address instead.

This seems to make corecheck/tests/res_search work properly,
although for some as-yet unknown reason breaks the corecheck
skin.  All other skins appear unaffected.

One unfortunate effect is that the lazy debug info scheme is now
nullified, since we always need to read debug info in order to
generate the redirection table.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1743 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/coregrind/vg_include.h b/coregrind/vg_include.h
index ca5a1d9..db1caf7 100644
--- a/coregrind/vg_include.h
+++ b/coregrind/vg_include.h
@@ -1281,6 +1281,18 @@
 
 extern Bool VG_(get_fnname_nodemangle)( Addr a, Char* fnname, Int n_fnname );
 extern void VG_(mini_stack_dump)      ( ExeContext* ec );
+extern Int  VG_(setup_code_redirect_table) ( void );
+
+typedef
+   struct {
+      Addr entry_pt_orig;
+      Addr entry_pt_subst;
+   }
+   CodeRedirect;
+
+#define VG_N_CODE_REDIRECTS 10
+extern CodeRedirect VG_(code_redirect_table)[VG_N_CODE_REDIRECTS];
+/* Table is terminated by a NULL entry_pt_orig field. */
 
 
 /* ---------------------------------------------------------------------