[ARM/FDPIC,v5,21/21,ARM] FDPIC: Handle stack-protector combined patterns

Message ID 20190515124006.25840-22-christophe.lyon@st.com
State Superseded
Headers show
Series
  • FDPIC ABI for ARM
Related show

Commit Message

Christophe Lyon May 15, 2019, 12:39 p.m.
The recent stack_protect_combined_set_insn and
stack_protect_combined_test_insn force recomputing of GOT base, but
need to take into account that in FDPIC mode, the PIC register is
fixed by the ABI (r9).

2019-XX-XX  Christophe Lyon  <christophe.lyon@st.com>

	* config/arm/arm.md (stack_protect_combined_set_insn): Handle
	FDPIC mode.
	(stack_protect_combined_test_insn): Likewise.

Change-Id: Ib243fab0791fc883ca7b1c1205af1e0893f3e8c5

-- 
2.6.3

Comments

Kyrill Tkachov July 19, 2019, 9:03 a.m. | #1
On 5/15/19 1:39 PM, Christophe Lyon wrote:
> The recent stack_protect_combined_set_insn and

> stack_protect_combined_test_insn force recomputing of GOT base, but

> need to take into account that in FDPIC mode, the PIC register is

> fixed by the ABI (r9).

>

> 2019-XX-XX  Christophe Lyon  <christophe.lyon@st.com>

>

>         * config/arm/arm.md (stack_protect_combined_set_insn): Handle

>         FDPIC mode.

>         (stack_protect_combined_test_insn): Likewise.

>

> Change-Id: Ib243fab0791fc883ca7b1c1205af1e0893f3e8c5

>

> diff --git a/gcc/config/arm/arm.md b/gcc/config/arm/arm.md

> index 0edcb1d..5a4dd00 100644

> --- a/gcc/config/arm/arm.md

> +++ b/gcc/config/arm/arm.md

> @@ -8869,8 +8869,19 @@

>  {

>    if (flag_pic)

>      {

> +      rtx pic_reg;

> +

> +      if (TARGET_FDPIC)

> +        {

> +         pic_reg = gen_rtx_REG (Pmode, FDPIC_REGNUM);

> +       }

> +      else

> +        {

> +         pic_reg = operands[3];

> +       }


Redundant braces here...

> +

>        /* Forces recomputing of GOT base now.  */

> -      legitimize_pic_address (operands[1], SImode, operands[2], 

> operands[3],

> +      legitimize_pic_address (operands[1], SImode, operands[2], pic_reg,

>                                true /*compute_now*/);

>      }

>    else

> @@ -8943,8 +8954,19 @@

>

>    if (flag_pic)

>      {

> +      rtx pic_reg;

> +

> +      if (TARGET_FDPIC)

> +        {

> +         pic_reg = gen_rtx_REG (Pmode, FDPIC_REGNUM);

> +        }

> +      else

> +        {

> +         pic_reg = operands[4];

> +       }

> +


... and here.

Ok with that fixed.

Thanks,

Kyrill



>        /* Forces recomputing of GOT base now.  */

> -      legitimize_pic_address (operands[1], SImode, operands[3], 

> operands[4],

> +      legitimize_pic_address (operands[1], SImode, operands[3], pic_reg,

>                                true /*compute_now*/);

>      }

>    else

> -- 

> 2.6.3

>

Patch

diff --git a/gcc/config/arm/arm.md b/gcc/config/arm/arm.md
index 0edcb1d..5a4dd00 100644
--- a/gcc/config/arm/arm.md
+++ b/gcc/config/arm/arm.md
@@ -8869,8 +8869,19 @@ 
 {
   if (flag_pic)
     {
+      rtx pic_reg;
+
+      if (TARGET_FDPIC)
+        {
+	  pic_reg = gen_rtx_REG (Pmode, FDPIC_REGNUM);
+	}
+      else
+        {
+	  pic_reg = operands[3];
+	}
+
       /* Forces recomputing of GOT base now.  */
-      legitimize_pic_address (operands[1], SImode, operands[2], operands[3],
+      legitimize_pic_address (operands[1], SImode, operands[2], pic_reg,
 			      true /*compute_now*/);
     }
   else
@@ -8943,8 +8954,19 @@ 
 
   if (flag_pic)
     {
+      rtx pic_reg;
+
+      if (TARGET_FDPIC)
+        {
+	  pic_reg = gen_rtx_REG (Pmode, FDPIC_REGNUM);
+        }
+      else
+        {
+	  pic_reg = operands[4];
+	}
+
       /* Forces recomputing of GOT base now.  */
-      legitimize_pic_address (operands[1], SImode, operands[3], operands[4],
+      legitimize_pic_address (operands[1], SImode, operands[3], pic_reg,
 			      true /*compute_now*/);
     }
   else