]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Merge r5979 (fix for: Can't stat .so/.exe error while reading symbols)
authorJulian Seward <jseward@acm.org>
Mon, 28 Aug 2006 12:17:41 +0000 (12:17 +0000)
committerJulian Seward <jseward@acm.org>
Mon, 28 Aug 2006 12:17:41 +0000 (12:17 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/branches/VALGRIND_3_2_BRANCH@6021

coregrind/m_debuginfo/readelf.c
coregrind/m_libcfile.c

index be0d75fc3cdfe4d3c1dabf5f049b3c0a967f50da..e3318e6b71d78edd45944479c7e13a32f7f1c8ac 100644 (file)
@@ -821,7 +821,6 @@ Bool ML_(read_elf_debug_info) ( struct _SegInfo* si )
    Addr          dimage = 0;
    UInt          n_dimage = 0;
    OffT          offset_dimage = 0;
-   struct vki_stat stat_buf;
 
    oimage = (Addr)NULL;
    if (VG_(clo_verbosity) > 1 || VG_(clo_trace_redir))
@@ -832,16 +831,16 @@ Bool ML_(read_elf_debug_info) ( struct _SegInfo* si )
       line number info out of it.  It will be munmapped immediately
       thereafter; it is only aboard transiently. */
 
-   fd = VG_(stat)(si->filename, &stat_buf);
+   fd = VG_(open)(si->filename, VKI_O_RDONLY, 0);
    if (fd.isError) {
-      ML_(symerr)("Can't stat .so/.exe (to determine its size)?!");
+      ML_(symerr)("Can't open .so/.exe to read symbols?!");
       return False;
    }
-   n_oimage = stat_buf.st_size;
 
-   fd = VG_(open)(si->filename, VKI_O_RDONLY, 0);
-   if (fd.isError) {
-      ML_(symerr)("Can't open .so/.exe to read symbols?!");
+   n_oimage = VG_(fsize)(fd.val);
+   if (n_oimage < 0) {
+      ML_(symerr)("Can't stat .so/.exe (to determine its size)?!");
+      VG_(close)(fd.val);
       return False;
    }
 
index 82e29722802a3813a1c7d7fd546a617923bb9af6..f84a1c24c02a40508a393f4d1967e3c3f63feb23 100644 (file)
@@ -133,8 +133,13 @@ Int VG_(fstat) ( Int fd, struct vki_stat* buf )
 
 Int VG_(fsize) ( Int fd )
 {
+#ifdef __NR_fstat64
+   struct vki_stat64 buf;
+   SysRes res = VG_(do_syscall2)(__NR_fstat64, fd, (UWord)&buf);
+#else
    struct vki_stat buf;
    SysRes res = VG_(do_syscall2)(__NR_fstat, fd, (UWord)&buf);
+#endif
    return res.isError ? (-1) : buf.st_size;
 }