From: Julian Seward Date: Mon, 28 Aug 2006 12:17:41 +0000 (+0000) Subject: Merge r5979 (fix for: Can't stat .so/.exe error while reading symbols) X-Git-Tag: svn/VALGRIND_3_2_1~28 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=19b61176fbf2098b99e63dd92a7957d3f95be4cc;p=thirdparty%2Fvalgrind.git Merge r5979 (fix for: Can't stat .so/.exe error while reading symbols) git-svn-id: svn://svn.valgrind.org/valgrind/branches/VALGRIND_3_2_BRANCH@6021 --- diff --git a/coregrind/m_debuginfo/readelf.c b/coregrind/m_debuginfo/readelf.c index be0d75fc3c..e3318e6b71 100644 --- a/coregrind/m_debuginfo/readelf.c +++ b/coregrind/m_debuginfo/readelf.c @@ -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; } diff --git a/coregrind/m_libcfile.c b/coregrind/m_libcfile.c index 82e2972280..f84a1c24c0 100644 --- a/coregrind/m_libcfile.c +++ b/coregrind/m_libcfile.c @@ -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; }