diff mbox series

[3/4] rs6000: Conditionally define __ROP_PROTECT__

Message ID 5ff87a6cff8fe7bdf0cc4df44b7c8968e8b5ae50.1619400506.git.wschmidt@linux.ibm.com
State New
Headers show
Series ROP support | expand

Commit Message

Bill Schmidt April 26, 2021, 1:50 a.m. UTC
2021-03-25  Bill Schmidt  <wschmidt@linux.ibm.com>

gcc/
	* config/rs6000/rs6000-c.c (rs6000_target_modify_macros): Define
	__ROP_PROTECT__ if -mrop-protect is selected.
---
 gcc/config/rs6000/rs6000-c.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

will schmidt April 26, 2021, 4:03 p.m. UTC | #1
On Sun, 2021-04-25 at 20:50 -0500, Bill Schmidt via Gcc-patches wrote:
> 2021-03-25  Bill Schmidt  <wschmidt@linux.ibm.com>
> 
> gcc/
> 	* config/rs6000/rs6000-c.c (rs6000_target_modify_macros): Define
> 	__ROP_PROTECT__ if -mrop-protect is selected.


ok

> ---
>  gcc/config/rs6000/rs6000-c.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/gcc/config/rs6000/rs6000-c.c b/gcc/config/rs6000/rs6000-c.c
> index 0f8a629ff5a..afcb5bb6e39 100644
> --- a/gcc/config/rs6000/rs6000-c.c
> +++ b/gcc/config/rs6000/rs6000-c.c
> @@ -602,6 +602,9 @@ rs6000_target_modify_macros (bool define_p, HOST_WIDE_INT flags,
>    /* Whether pc-relative code is being generated.  */
>    if ((flags & OPTION_MASK_PCREL) != 0)
>      rs6000_define_or_undefine_macro (define_p, "__PCREL__");
> +  /* Tell the user -mrop-protect is in play.  */
> +  if (rs6000_rop_protect)
> +    rs6000_define_or_undefine_macro (define_p, "__ROP_PROTECT__");
> 

I notice that almost all of the other defines are controled by an (if
(flags & OPTION) logic block.. but this seems OK.

lgtm, 
thanks,
-WIll


>  }
> 
>  void
Segher Boessenkool May 12, 2021, 11:19 p.m. UTC | #2
On Mon, Apr 26, 2021 at 11:03:22AM -0500, will schmidt wrote:
> On Sun, 2021-04-25 at 20:50 -0500, Bill Schmidt via Gcc-patches wrote:
> > @@ -602,6 +602,9 @@ rs6000_target_modify_macros (bool define_p, HOST_WIDE_INT flags,
> >    /* Whether pc-relative code is being generated.  */
> >    if ((flags & OPTION_MASK_PCREL) != 0)
> >      rs6000_define_or_undefine_macro (define_p, "__PCREL__");
> > +  /* Tell the user -mrop-protect is in play.  */
> > +  if (rs6000_rop_protect)
> > +    rs6000_define_or_undefine_macro (define_p, "__ROP_PROTECT__");
> > 
> 
> I notice that almost all of the other defines are controled by an (if
> (flags & OPTION) logic block.. but this seems OK.

That is rs6000_isa_flags, which is only 64 bits.  Not every option can
be put in there, only the ones used all over the place in the compiler
should be.  Currently there are 53 of 64 bits used, there is some room,
and that is good :-)


Segher
Segher Boessenkool May 12, 2021, 11:20 p.m. UTC | #3
On Sun, Apr 25, 2021 at 08:50:17PM -0500, Bill Schmidt wrote:
> 2021-03-25  Bill Schmidt  <wschmidt@linux.ibm.com>
> 
> gcc/
> 	* config/rs6000/rs6000-c.c (rs6000_target_modify_macros): Define
> 	__ROP_PROTECT__ if -mrop-protect is selected.

Okay for trunk and 11.  Thanks!


Segher
diff mbox series

Patch

diff --git a/gcc/config/rs6000/rs6000-c.c b/gcc/config/rs6000/rs6000-c.c
index 0f8a629ff5a..afcb5bb6e39 100644
--- a/gcc/config/rs6000/rs6000-c.c
+++ b/gcc/config/rs6000/rs6000-c.c
@@ -602,6 +602,9 @@  rs6000_target_modify_macros (bool define_p, HOST_WIDE_INT flags,
   /* Whether pc-relative code is being generated.  */
   if ((flags & OPTION_MASK_PCREL) != 0)
     rs6000_define_or_undefine_macro (define_p, "__PCREL__");
+  /* Tell the user -mrop-protect is in play.  */
+  if (rs6000_rop_protect)
+    rs6000_define_or_undefine_macro (define_p, "__ROP_PROTECT__");
 }
 
 void