|
From: <sv...@va...> - 2006-07-05 17:48:15
|
Author: tom
Date: 2006-07-05 18:47:46 +0100 (Wed, 05 Jul 2006)
New Revision: 5979
Log:
Use fstat64 to work out the size of a file if it is available as it
copes with a wider range of filesystems than the old fstat call.
Fixes bug #130020.
Modified:
trunk/coregrind/m_debuginfo/readelf.c
trunk/coregrind/m_libcfile.c
Modified: trunk/coregrind/m_debuginfo/readelf.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_debuginfo/readelf.c 2006-06-25 12:18:20 UTC (rev 59=
78)
+++ trunk/coregrind/m_debuginfo/readelf.c 2006-07-05 17:47:46 UTC (rev 59=
79)
@@ -821,7 +821,6 @@
Addr dimage =3D 0;
UInt n_dimage =3D 0;
OffT offset_dimage =3D 0;
- struct vki_stat stat_buf;
=20
oimage =3D (Addr)NULL;
if (VG_(clo_verbosity) > 1 || VG_(clo_trace_redir))
@@ -832,16 +831,16 @@
line number info out of it. It will be munmapped immediately
thereafter; it is only aboard transiently. */
=20
- fd =3D VG_(stat)(si->filename, &stat_buf);
+ fd =3D 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 =3D stat_buf.st_size;
=20
- fd =3D VG_(open)(si->filename, VKI_O_RDONLY, 0);
- if (fd.isError) {
- ML_(symerr)("Can't open .so/.exe to read symbols?!");
+ n_oimage =3D 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;
}
=20
Modified: trunk/coregrind/m_libcfile.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_libcfile.c 2006-06-25 12:18:20 UTC (rev 5978)
+++ trunk/coregrind/m_libcfile.c 2006-07-05 17:47:46 UTC (rev 5979)
@@ -133,8 +133,13 @@
=20
Int VG_(fsize) ( Int fd )
{
+#ifdef __NR_fstat64
+ struct vki_stat64 buf;
+ SysRes res =3D VG_(do_syscall2)(__NR_fstat64, fd, (UWord)&buf);
+#else
struct vki_stat buf;
SysRes res =3D VG_(do_syscall2)(__NR_fstat, fd, (UWord)&buf);
+#endif
return res.isError ? (-1) : buf.st_size;
}
=20
|