|
From: <sv...@va...> - 2005-10-11 22:06:41
|
Author: sewardj
Date: 2005-10-11 23:06:29 +0100 (Tue, 11 Oct 2005)
New Revision: 4901
Log:
Make sync checking work on recent x86 kernels (eg SuSE 10) which mark
many 'r' sections also as 'x' because x86 can't really distinguish
them. The change just regards 'x' and 'r' as equivalent on x86.
Checking on ppc32/amd64 is unchanged.
Modified:
trunk/coregrind/m_aspacemgr/aspacemgr.c
Modified: trunk/coregrind/m_aspacemgr/aspacemgr.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_aspacemgr/aspacemgr.c 2005-10-11 18:21:47 UTC (rev =
4900)
+++ trunk/coregrind/m_aspacemgr/aspacemgr.c 2005-10-11 22:06:29 UTC (rev =
4901)
@@ -53,6 +53,11 @@
#include "pub_core_aspacemgr.h" // self
=20
=20
+/* Note: many of the exported functions implemented below are
+ described more fully in comments in pub_core_aspacemgr.h.
+*/
+
+
/*-----------------------------------------------------------------*/
/*--- ---*/
/*--- The Address Space Manager's state. ---*/
@@ -417,16 +422,6 @@
}
=20
=20
-/////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////
-
-
-/* Note: many of the exported functions implemented below are
- described more fully in comments in pub_core_aspacemgr.h.
-*/
-
/*-----------------------------------------------------------------*/
/*--- ---*/
/*--- Displaying the segment array. ---*/
@@ -866,7 +861,8 @@
UInt dev, UInt ino, ULong offs=
et,=20
const UChar* filename )
{
- Int iLo, iHi, i;
+ Int iLo, iHi, i;
+ Bool sloppyRXcheck;
=20
/* If a problem has already been detected, don't continue comparing
segments, so as to avoid flooding the output with error
@@ -890,6 +886,23 @@
aspacem_assert(nsegments[iLo].start <=3D addr );
aspacem_assert(nsegments[iHi].end >=3D addr + len - 1 );
=20
+ /* x86 doesn't differentiate 'x' and 'r' (at least, all except the
+ most recent NX-bit enabled CPUs) and so recent kernels mark most
+ readable sections also as executable (in the /proc/self/maps
+ they give out), which makes checking fail. When sloppyRXcheck
+ is True, the checker therefore regards R and X as
+ interchangeable. */
+ sloppyRXcheck =3D False;
+# if defined(VGA_x86)
+ sloppyRXcheck =3D True;
+# endif
+
+ if (sloppyRXcheck) {
+ /* If either bit is set, ensure both are set. */
+ if (prot & (VKI_PROT_READ|VKI_PROT_EXEC))
+ prot |=3D (VKI_PROT_READ|VKI_PROT_EXEC);
+ }
+
/* NSegments iLo .. iHi inclusive should agree with the presented
data. */
for (i =3D iLo; i <=3D iHi; i++) {
@@ -921,6 +934,12 @@
if (filename && 0=3D=3DVG_(strcmp)(filename, "/dev/zero (deleted)"=
))
cmp_devino =3D False;
=20
+ if (sloppyRXcheck) {
+ /* If either bit is set, ensure both are set. */
+ if (seg_prot & (VKI_PROT_READ|VKI_PROT_EXEC))
+ seg_prot |=3D (VKI_PROT_READ|VKI_PROT_EXEC);
+ }
+
same =3D same
&& seg_prot =3D=3D prot
&& (cmp_devino
|