diff mbox

[Committed/AARCH64] Fix stack protector for ILP32

Message ID CA+=Sn1kwK0-DSYMc3MKR_oP0quBTJU_ENN6kNWtzjJiopLvDUQ@mail.gmail.com
State New
Headers show

Commit Message

Andrew Pinski May 28, 2014, 1:23 a.m. UTC
Hi,
  I was trying to compile an ilp32 enabled glibc and ran into a
failure with stack protector.  The problem is two fold.  First we were
generating the wrong mode for the result to testing against zero.  The
next issue is we were using 64bit loads instead of 32bit loads from
__stack_chk_guard.  This was caused by using x instead of <w> in the
assembly template.

I committed the patch for both of these issues after a build and test
on aarch64-linux-gnu with no regressions.

Thanks,
Andrew Pinski

ChangeLog:
* config/aarch64/aarch64.md (stack_protect_set_<mode>):
Use <w> for the register in assembly template.
(stack_protect_test): Use the mode of operands[0] for the
result.
(stack_protect_test_<mode>): Use <w> for the register
in assembly template.
diff mbox

Patch

Index: config/aarch64/aarch64.md
===================================================================
--- config/aarch64/aarch64.md	(revision 210995)
+++ config/aarch64/aarch64.md	(working copy)
@@ -3859,7 +3859,7 @@  (define_insn "stack_protect_set_<mode>"
 	 UNSPEC_SP_SET))
    (set (match_scratch:PTR 2 "=&r") (const_int 0))]
   ""
-  "ldr\\t%x2, %1\;str\\t%x2, %0\;mov\t%x2,0"
+  "ldr\\t%<w>2, %1\;str\\t%<w>2, %0\;mov\t%<w>2,0"
   [(set_attr "length" "12")
    (set_attr "type" "multiple")])
 
@@ -3869,11 +3869,11 @@  (define_expand "stack_protect_test"
    (match_operand 2)]
   ""
 {
-
-  rtx result = gen_reg_rtx (Pmode);
-
+  rtx result;
   enum machine_mode mode = GET_MODE (operands[0]);
 
+  result = gen_reg_rtx(mode);
+
   emit_insn ((mode == DImode
 	      ? gen_stack_protect_test_di
 	      : gen_stack_protect_test_si) (result,
@@ -3896,7 +3896,7 @@  (define_insn "stack_protect_test_<mode>"
 	 UNSPEC_SP_TEST))
    (clobber (match_scratch:PTR 3 "=&r"))]
   ""
-  "ldr\t%x3, %x1\;ldr\t%x0, %x2\;eor\t%x0, %x3, %x0"
+  "ldr\t%<w>3, %x1\;ldr\t%<w>0, %x2\;eor\t%<w>0, %<w>3, %<w>0"
   [(set_attr "length" "12")
    (set_attr "type" "multiple")])