diff mbox

[CHKP,PR,target/65044] Restrict pointer bounds checker with Sanitizer

Message ID 20150312085151.GH27860@msticlxl57.ims.intel.com
State New
Headers show

Commit Message

Ilya Enkovich March 12, 2015, 8:51 a.m. UTC
On 09 Mar 15:51, Jakub Jelinek wrote:
> On Mon, Mar 02, 2015 at 01:25:43PM +0300, Ilya Enkovich wrote:
> > > --- a/gcc/toplev.c
> > > +++ b/gcc/toplev.c
> > > @@ -1376,6 +1376,11 @@ process_options (void)
> > >      {
> > >        if (targetm.chkp_bound_mode () == VOIDmode)
> > >         error ("-fcheck-pointer-bounds is not supported for this target");
> > > +
> > > +      if (flag_sanitize & SANITIZE_ADDRESS)
> > > +       error ("-fcheck-pointer-bounds is not supported with Address Sanitizer");
> > > +
> > > +      flag_check_pointer_bounds = 0;
> > >      }
> 
> Doesn't this disable -fcheck-pointer-bounds always?
> I'd expect you want to clear flag_check_pointer_bounds only if you issued
> one of the two errors...
> 
> 	Jakub

Whoops!  Here is a less destructive version.

Thanks,
Ilya
--
gcc/

2015-03-11  Ilya Enkovich  <ilya.enkovich@intel.com>

	PR target/65044
	* toplev.c (process_options): Restrict Pointer Bounds Checker
	usage with Address Sanitizer.

gcc/testsuite/

2015-03-11  Ilya Enkovich  <ilya.enkovich@intel.com>

	PR target/65044
	* gcc.target/i386/pr65044.c: New.

Comments

Jakub Jelinek March 12, 2015, 9:02 a.m. UTC | #1
On Thu, Mar 12, 2015 at 11:51:51AM +0300, Ilya Enkovich wrote:
> On 09 Mar 15:51, Jakub Jelinek wrote:
> > On Mon, Mar 02, 2015 at 01:25:43PM +0300, Ilya Enkovich wrote:
> > > > --- a/gcc/toplev.c
> > > > +++ b/gcc/toplev.c
> > > > @@ -1376,6 +1376,11 @@ process_options (void)
> > > >      {
> > > >        if (targetm.chkp_bound_mode () == VOIDmode)
> > > >         error ("-fcheck-pointer-bounds is not supported for this target");
> > > > +
> > > > +      if (flag_sanitize & SANITIZE_ADDRESS)
> > > > +       error ("-fcheck-pointer-bounds is not supported with Address Sanitizer");
> > > > +
> > > > +      flag_check_pointer_bounds = 0;
> > > >      }
> > 
> > Doesn't this disable -fcheck-pointer-bounds always?
> > I'd expect you want to clear flag_check_pointer_bounds only if you issued
> > one of the two errors...
> > 
> > 	Jakub
> 
> Whoops!  Here is a less destructive version.

Ok for trunk.  Did the old version pass make check?  If so, perhaps you want to add
(incrementally) some test that would actually verify that
-fcheck-pointer-bounds does what it should do (e.g. by scanning tree dumps
etc.).

	Jakub
diff mbox

Patch

diff --git a/gcc/testsuite/gcc.target/i386/pr65044.c b/gcc/testsuite/gcc.target/i386/pr65044.c
new file mode 100644
index 0000000..4f318d6
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr65044.c
@@ -0,0 +1,12 @@ 
+/* { dg-error "-fcheck-pointer-bounds is not supported with Address Sanitizer" } */
+/* { dg-do compile } */
+/* { dg-require-effective-target mpx } */
+/* { dg-options "-fcheck-pointer-bounds -mmpx -fsanitize=address" } */
+
+extern int x[];
+
+void
+foo ()
+{
+  x[0] = 0;
+}
diff --git a/gcc/toplev.c b/gcc/toplev.c
index 99cf180..b06eed3 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -1375,7 +1375,17 @@  process_options (void)
   if (flag_check_pointer_bounds)
     {
       if (targetm.chkp_bound_mode () == VOIDmode)
-	error ("-fcheck-pointer-bounds is not supported for this target");
+	{
+	  error ("-fcheck-pointer-bounds is not supported for this target");
+	  flag_check_pointer_bounds = 0;
+	}
+
+      if (flag_sanitize & SANITIZE_ADDRESS)
+	{
+	  error ("-fcheck-pointer-bounds is not supported with "
+		 "Address Sanitizer");
+	  flag_check_pointer_bounds = 0;
+	}
     }
 
   /* One region RA really helps to decrease the code size.  */