]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Minimal, horrible hacks needed to make vsyscalls work on amd64.
authorJulian Seward <jseward@acm.org>
Wed, 2 Mar 2005 14:06:08 +0000 (14:06 +0000)
committerJulian Seward <jseward@acm.org>
Wed, 2 Mar 2005 14:06:08 +0000 (14:06 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3259

coregrind/amd64/helpers.S
coregrind/vg_main.c
coregrind/vg_symtab2.c

index 50c4f4553514527b6ebd0b14335c1077e16b30d2..fc05795fa3b0f4adcf7441ca8206be9d9c6a9511 100644 (file)
@@ -27,7 +27,6 @@
   The GNU General Public License is contained in the file COPYING.
 */
 
-#if 0
 #include "core_asm.h"
 
 /* ------------------ SIMULATED CPU HELPERS ------------------ */
@@ -69,8 +68,10 @@ sigreturn_start:
 
        # We can point our sysinfo stuff here
        .align 16
-syscall_start: 
-       int     $0x80
+syscall_start:
+       /* Rerouted entry point for __NR_vgettimeofday */
+       movq    $96 /*__NR_gettimeofday*/, %rax
+       syscall
        ret
 tramp_code_end:
                        
@@ -86,7 +87,6 @@ VG_(tramp_syscall_offset):
 
 /* Let the linker know we don't need an executable stack */
 .section .note.GNU-stack,"",@progbits
-#endif
                
 ##--------------------------------------------------------------------##
 ##--- end                                                          ---##
index 0dc668219341c8abbf4b1e52eba1fb68e0244d5d..46d3683b680a1de16dd037dc9455110c6b665980 100644 (file)
@@ -1121,7 +1121,7 @@ static Addr setup_client_stack(void* init_sp,
 
 // XXX: what architectures is this necessary for?  x86 yes, PPC no, others ?
 // Perhaps a per-arch VGA_NEEDS_TRAMPOLINE constant is necessary?
-#ifdef __x86__
+#if defined(__i386__) || defined(__amd64__)
    /* --- trampoline page --- */
    VG_(memcpy)( (void *)VG_(client_trampoline_code),
                 &VG_(trampoline_code_start), VG_(trampoline_code_length) );
@@ -1690,7 +1690,7 @@ static void process_cmd_line_options( UInt* client_auxv, const char* toolname )
 // XXX: what architectures is this necessary for?  x86 yes, PPC no, others ?
 #ifdef __x86__
    {
-      Int *auxp;
+      Word *auxp;
       for (auxp = client_auxv; auxp[0] != AT_NULL; auxp += 2) {
          switch(auxp[0]) {
          case AT_SYSINFO:
@@ -2669,7 +2669,7 @@ int main(int argc, char **argv)
    VG_(parse_procselfmaps) ( build_segment_map_callback );  /* everything */
    sp_at_startup___global_arg = 0;
    
-#ifdef __i386__
+#if defined(__i386__) || defined(__amd64__)
    //--------------------------------------------------------------
    // Protect client trampoline page (which is also sysinfo stuff)
    //   p: segment stuff   [otherwise get seg faults...]
index 67e65cb245c66bd6cf1a7c85d1906867b3a48b94..d2d46b6939d59cffa76a5ddb6bc4877a69fb49c3 100644 (file)
@@ -2197,7 +2197,7 @@ Char* VG_(describe_eip)(Addr eip, Char* buf, Int n_buf)
    Bool  know_objname = VG_(get_objname)(eip, buf_obj, M_VG_ERRTXT);
    Bool  know_srcloc  = VG_(get_filename_linenum)(eip, buf_srcloc, M_VG_ERRTXT, 
                                                   &lineno);
-   VG_(sprintf)(ibuf,"0x%x: ", eip);
+   VG_(sprintf)(ibuf,"0x%llx: ", (ULong)eip);
    APPEND(ibuf);
    if (know_fnname) { 
       APPEND(buf_fn);
@@ -2495,7 +2495,7 @@ static void add_redirect_sym(const Char *from_lib, const Char *from_sym,
    }
 }
 
-/* Redirect a lib/symbol reference to a function at lib/symbol */
+/* Redirect a lib/symbol reference to an addr */
 static void add_redirect_addr(const Char *from_lib, const Char *from_sym,
                              Addr to_addr)
 {
@@ -2525,6 +2525,17 @@ Addr VG_(code_redirect)(Addr a)
 {
    CodeRedirect *r = VG_(SkipList_Find)(&sk_resolved_redir, &a);
 
+#ifdef __amd64__
+   /* HACK.  0xFFFFFFFFFF600000 is the entry point for 
+      __NR_vgettimeofday.  Therefore the code at 
+      VG_(client_trampoline_code)+VG_(tramp_syscall_offset)
+      must be the magic conversion code to turn it into a normal
+      __NR_gettimeofday call. 
+   */
+   if (a == 0xFFFFFFFFFF600000ULL)
+      return VG_(client_trampoline_code)+VG_(tramp_syscall_offset);
+#endif
+
    if (r == NULL || r->from_addr != a)
       return a;
 
@@ -2561,7 +2572,7 @@ void VG_(setup_code_redirect_table) ( void )
    add_redirect_addr("soname:ld-linux.so.2", "_dl_sysinfo_int80",
                      VG_(client_trampoline_code)+VG_(tramp_syscall_offset));
 #endif
-   
+
    /* Overenthusiastic use of PLT bypassing by the glibc people also
       means we need to patch the following functions to our own
       implementations of said, in mac_replace_strmem.c.