Index: coregrind/vg_include.h
===================================================================
RCS file: /home/kde/valgrind/coregrind/vg_include.h,v
retrieving revision 1.187
diff -u -3 -p -r1.187 vg_include.h
--- coregrind/vg_include.h	16 Mar 2004 09:49:07 -0000	1.187
+++ coregrind/vg_include.h	18 Mar 2004 18:41:03 -0000
@@ -1376,6 +1376,8 @@ extern void VG_(add_redirect_sym)(const 
 				  const Char *to_lib, const Char *to_sym);
 extern void VG_(add_redirect_addr)(const Char *from_lib, const Char *from_sym,
 				   Addr to_addr);
+extern void VG_(add_redirect_addr_addr)(Addr from, Addr to);
+
 extern Addr VG_(code_redirect)	  (Addr orig);
 
 /* ---------------------------------------------------------------------
@@ -1402,6 +1404,7 @@ extern Addr VG_(client_mapbase); /* base
 extern Addr VG_(clstk_base);	/* client stack range */
 extern Addr VG_(clstk_end);
 extern Addr VG_(client_trampoline_code);
+extern Addr VG_(client_sysinfo_ehdr);
 
 extern Addr VG_(brk_base);	/* start of brk */
 extern Addr VG_(brk_limit);	/* current brk */
@@ -1437,11 +1440,6 @@ extern UInt VG_(sigstack)[VG_SIGSTACK_SI
 extern Int    VG_(vg_argc);
 extern Char **VG_(vg_argv);
 
-/* Indicates presence, and holds address of client's sysinfo page, a
-   feature of some modern kernels used to provide vsyscalls, etc. */
-extern Bool VG_(sysinfo_page_exists);
-extern Addr VG_(sysinfo_page_addr);
-
 /* Walk through a colon separated list variable, removing entries
    which match pattern. */
 extern void VG_(mash_colon_env)(Char *varp, const Char *pattern);
Index: coregrind/vg_main.c
===================================================================
RCS file: /home/kde/valgrind/coregrind/vg_main.c,v
retrieving revision 1.147
diff -u -3 -p -r1.147 vg_main.c
--- coregrind/vg_main.c	13 Mar 2004 02:06:58 -0000	1.147
+++ coregrind/vg_main.c	18 Mar 2004 18:41:05 -0000
@@ -50,18 +50,6 @@
 #include <sys/wait.h>
 #include <unistd.h>
 
-#ifndef AT_SYSINFO
-#define AT_SYSINFO		32
-#endif /* AT_SYSINFO */
-
-#ifndef AT_SYSINFO_EHDR
-#define AT_SYSINFO_EHDR		33
-#endif /* AT_SYSINFO_EHDR */
-
-#ifndef AT_SECURE
-#define AT_SECURE 23   /* secure mode boolean */
-#endif	/* AT_SECURE */
-
 /* Amount to reserve for Valgrind's internal heap */
 #define VALGRIND_HEAPSIZE	(128*1024*1024)
 
@@ -91,6 +79,7 @@ Addr VG_(client_base);           /* clie
 Addr VG_(client_end);
 Addr VG_(client_mapbase);
 Addr VG_(client_trampoline_code);
+Addr VG_(client_sysinfo_ehdr);
 Addr VG_(clstk_base);
 Addr VG_(clstk_end);
 
@@ -110,11 +99,6 @@ vki_rlimit VG_(client_rlimit_data);
    SSE/fxsave/fxrestor features.  */
 Bool VG_(have_ssestate);
 
-/* Indicates presence, and holds address of client's sysinfo page, a
-   feature of some modern kernels used to provide vsyscalls, etc. */
-Bool VG_(sysinfo_page_exists) = False;
-Addr VG_(sysinfo_page_addr) = 0;
-
 /* stage1 (main) executable */
 Int  VG_(vgexecfd) = -1;
 
@@ -520,7 +504,8 @@ static void layout_remaining_space(float
 
    VG_(client_end)     = VG_(client_base) + client_size;
    VG_(client_mapbase) = PGROUNDDN((client_size/4)*3); /* where !FIXED mmap goes */
-   VG_(client_trampoline_code) = VG_(client_end) - VKI_BYTES_PER_PAGE;
+   VG_(client_sysinfo_ehdr) = VG_(client_end) - VKI_BYTES_PER_PAGE;
+   VG_(client_trampoline_code) = VG_(client_sysinfo_ehdr) - VKI_BYTES_PER_PAGE;
 
    VG_(shadow_base) = VG_(client_end) + REDZONE_SIZE;
    VG_(shadow_end)  = VG_(shadow_base) + shadow_size;
@@ -1030,11 +1015,10 @@ static Addr setup_client_stack(char **or
       sizeof(char **)*envc +		/* envp */
       sizeof(char **) +			/* terminal NULL */
       auxsize +				/* auxv */
-      ROUNDUP(stringsize, sizeof(int)) +/* strings (aligned) */
-      VKI_BYTES_PER_PAGE;		/* page for trampoline code */
+      ROUNDUP(stringsize, sizeof(int)); /* strings (aligned) */
 
    /* cl_esp is the client's stack pointer */
-   cl_esp = VG_(client_end) - stacksize;
+   cl_esp = VG_(client_trampoline_code) - stacksize;
    cl_esp = ROUNDDN(cl_esp, 16); /* make stack 16 byte aligned */
 
    if (0)
@@ -1143,7 +1127,7 @@ static Addr setup_client_stack(char **or
 	    about them. */
 	 break;
 
-      case AT_SECURE:
+      case VKI_AT_SECURE:
 	 /* If this is 1, then it means that this program is running
 	    suid, and therefore the dynamic linker should be careful
 	    about LD_PRELOAD, etc.  However, since stage1 (the thing
@@ -1153,14 +1137,10 @@ static Addr setup_client_stack(char **or
 	 auxv->u.a_val = 0;
 	 break;
 
-      case AT_SYSINFO:
-	 /* Leave this unmolested for now, but we'll update it later
-	    when we set up the client trampoline code page */
-	 break;
-
-      case AT_SYSINFO_EHDR:
-	 /* Trash this, because we don't reproduce it */
-	 auxv->a_type = AT_IGNORE;
+      case VKI_AT_SYSINFO:
+      case VKI_AT_SYSINFO_EHDR:
+	 /* Leave these unmolested for now, but we'll update them
+	    later when we set up the client trampoline code page */
 	 break;
 
       default:
@@ -1630,10 +1610,21 @@ static void process_cmd_line_options 
 
    for (auxp = client_auxv; auxp[0] != VKI_AT_NULL; auxp += 2) {
       switch(auxp[0]) {
+      case VKI_AT_SYSINFO_EHDR:
+	 /* Copy the EHDR (actually the whole page) into the client
+	    address space, so it can been accessed.  We don't bother
+	    updating anything in the ELF file itself; don't know if
+	    this matters (references to the real syscall intstruction
+	    are redirected below). */
+	 VG_(memcpy)((void *)VG_(client_sysinfo_ehdr), (void *)auxp[1], VKI_BYTES_PER_PAGE);
+	 auxp[1] = (Int)VG_(client_sysinfo_ehdr);
+	 break;
+
       case VKI_AT_SYSINFO:
-	 VG_(sysinfo_page_exists) = True;
-	 auxp[1] = (Int)(VG_(client_trampoline_code) + VG_(tramp_syscall_offset));
-	 VG_(sysinfo_page_addr) = auxp[1];
+	 /* Leave this unmodifed, but add a redirect to point to our
+	    syscall instruction */
+	 VG_(add_redirect_addr_addr)(auxp[1], 
+				     VG_(client_trampoline_code) + VG_(tramp_syscall_offset));
 	 break;
       }
    } 
Index: coregrind/vg_symtab2.c
===================================================================
RCS file: /home/kde/valgrind/coregrind/vg_symtab2.c,v
retrieving revision 1.75
diff -u -3 -p -r1.75 vg_symtab2.c
--- coregrind/vg_symtab2.c	5 Feb 2004 22:58:37 -0000	1.75
+++ coregrind/vg_symtab2.c	18 Mar 2004 18:41:07 -0000
@@ -2004,7 +2004,7 @@ static Bool resolve_redir(CodeRedirect *
 		  redir->to_lib, redir->to_sym,
 		  si->filename, si->soname);
 
-   vg_assert(!resolved);
+   //vg_assert(!resolved);
 
    if (redir->from_addr == 0) {
       vg_assert(redir->from_sym != NULL);
@@ -2162,6 +2162,25 @@ void VG_(add_redirect_addr)(const Char *
    }
 }
 
+void VG_(add_redirect_addr_addr)(Addr from, Addr to)
+{
+   CodeRedirect *redir = VG_(SkipNode_Alloc)(&sk_resolved_redir);
+
+   redir->from_lib = NULL;
+   redir->from_sym = NULL;
+   redir->from_addr = from;
+
+   redir->to_lib = NULL;
+   redir->to_sym = NULL;
+   redir->to_addr = to;
+
+   if (!resolve_redir_allsegs(redir)) {
+      /* can't resolve immediately; add to list */
+      redir->next = unresolved_redir;
+      unresolved_redir = redir;
+   }
+}
+
 Addr VG_(code_redirect)(Addr a)
 {
    CodeRedirect *r = VG_(SkipList_Find)(&sk_resolved_redir, &a);
Index: coregrind/vg_translate.c
===================================================================
RCS file: /home/kde/valgrind/coregrind/vg_translate.c,v
retrieving revision 1.72
diff -u -3 -p -r1.72 vg_translate.c
--- coregrind/vg_translate.c	16 Mar 2004 09:49:07 -0000	1.72
+++ coregrind/vg_translate.c	18 Mar 2004 18:41:08 -0000
@@ -2397,18 +2397,13 @@ void VG_(translate) ( /*IN*/  ThreadId t
       VG_TRACK( pre_mem_read, Vg_CoreTranslate, tid, "", orig_addr, 1 );
 
    if (seg == NULL ||
-       !VG_(seg_contains)(seg, orig_addr, 1) || 
-       (seg->prot & (VKI_PROT_READ|VKI_PROT_EXEC)) == 0) {
-      /* Code address is bad - deliver a signal instead */
-      vg_assert(!VG_(is_addressable)(orig_addr, 1));
-
-      if (seg != NULL && VG_(seg_contains)(seg, orig_addr, 1)) {
-	 vg_assert((seg->prot & VKI_PROT_EXEC) == 0);
-	 VG_(synth_fault_perms)(tid, orig_addr);
-      } else
-	 VG_(synth_fault_mapping)(tid, orig_addr);
-
-      return;
+       !VG_(seg_contains)(seg, orig_addr, 1) ||
+       !VG_(is_client_addr)(orig_addr)) {
+      VG_(synth_fault_mapping)(tid, orig_addr);
+      VG_(core_panic)("synth_fault_mapping returned?!");
+   } else if ((seg->prot & (VKI_PROT_READ|VKI_PROT_EXEC)) == 0) {
+      VG_(synth_fault_perms)(tid, orig_addr);
+      VG_(core_panic)("synth_fault_perms returned?!");
    } else
       seg->flags |= SF_CODE;	/* contains cached code */
 
Index: coregrind/vg_transtab.c
===================================================================
RCS file: /home/kde/valgrind/coregrind/vg_transtab.c,v
retrieving revision 1.27
diff -u -3 -p -r1.27 vg_transtab.c
--- coregrind/vg_transtab.c	4 Jan 2004 16:43:20 -0000	1.27
+++ coregrind/vg_transtab.c	18 Mar 2004 18:41:09 -0000
@@ -557,6 +557,10 @@ void VG_(add_to_trans_tab) ( Addr orig_a
 Addr VG_(search_transtab) ( Addr original_addr )
 {
    TTEntry* tte;
+
+   if (vg_tt == NULL)
+      return 0;			/* transtab not initialized yet */
+
    VGP_PUSHCC(VgpSlowFindT);
    tte = search_tt ( original_addr );
    if (tte == NULL) {
Index: include/vg_kerneliface.h
===================================================================
RCS file: /home/kde/valgrind/include/vg_kerneliface.h,v
retrieving revision 1.16
diff -u -3 -p -r1.16 vg_kerneliface.h
--- include/vg_kerneliface.h	13 Mar 2004 02:06:58 -0000	1.16
+++ include/vg_kerneliface.h	18 Mar 2004 18:41:10 -0000
@@ -594,7 +594,9 @@ struct vki_stat {
                   and its counterpart in the 2.2.14 kernel sources 
                   in Red Hat 6.2.  */
 #define VKI_AT_NULL   0
+#define VKI_AT_SECURE 23    /* true if operating securely */
 #define VKI_AT_SYSINFO 32   /* address of system info page */
+#define VKI_AT_SYSINFO_EHDR 33	/* address of sysinfo dso */
 #define VKI_AT_CLKTCK 17    /* frequency at which times() increments */
 #define VKI_AT_HWCAP  16    /* arch dependent hints at CPU capabilities */
 #define VKI_AT_BASE   7     /* base address of interpreter */
