]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR target/60991 ([avr] Stack corruption when using 24-bit integers __int...
authorSenthil Kumar Selvaraj <senthil_kumar.selvaraj@atmel.com>
Mon, 12 May 2014 16:07:44 +0000 (16:07 +0000)
committerDenis Chertykov <denisc@gcc.gnu.org>
Mon, 12 May 2014 16:07:44 +0000 (20:07 +0400)
Backport from mainline
2014-05-12  Senthil Kumar Selvaraj  <senthil_kumar.selvaraj@atmel.com>

PR target/60991
* config/avr/avr.c (avr_out_store_psi): Use correct constant
to restore Y.

Backport from mainline
2014-05-12  Senthil Kumar Selvaraj  <senthil_kumar.selvaraj@atmel.com>

PR target/60991
* gcc.target/avr/pr60991.c: New testcase.

From-SVN: r210328

gcc/ChangeLog
gcc/config/avr/avr.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/avr/pr60991.c [new file with mode: 0644]

index f8d30c154aed5c07c98e2dc61c4dc68b983c7d8e..ac561d56e9bc66766af092189c1801a9d90c87e4 100644 (file)
@@ -1,3 +1,12 @@
+2014-05-12  Senthil Kumar Selvaraj  <senthil_kumar.selvaraj@atmel.com>
+
+       Backport from mainline
+       2014-05-12  Senthil Kumar Selvaraj  <senthil_kumar.selvaraj@atmel.com>
+
+       PR target/60991
+       * config/avr/avr.c (avr_out_store_psi): Use correct constant
+       to restore Y.
+
 2014-05-09  Georg-Johann Lay  <avr@gjlay.de>
 
        Backport from 2014-05-09 trunk r210267
index 05ef3860018f22786bd57999a73cbe91acae83ee..86c46e9c4a242ba5d0c3609f092f142b044ff3b2 100644 (file)
@@ -3987,7 +3987,7 @@ avr_out_store_psi (rtx insn, rtx *op, int *plen)
                                 "std Y+61,%A1"    CR_TAB
                                 "std Y+62,%B1"    CR_TAB
                                 "std Y+63,%C1"    CR_TAB
-                                "sbiw r28,%o0-60", op, plen, -5);
+                                "sbiw r28,%o0-61", op, plen, -5);
 
           return avr_asm_len ("subi r28,lo8(-%o0)" CR_TAB
                               "sbci r29,hi8(-%o0)" CR_TAB
index 421bd1fac9b126018659fd6786397fd9a78ce5cd..499415e52e05b45f86704307cda8c186d72ab529 100644 (file)
@@ -1,3 +1,11 @@
+2014-05-12  Senthil Kumar Selvaraj  <senthil_kumar.selvaraj@atmel.com>
+
+       Backport from mainline
+       2014-05-12  Senthil Kumar Selvaraj  <senthil_kumar.selvaraj@atmel.com>
+
+       PR target/60991
+       * gcc.target/avr/pr60991.c: New testcase.
+
 2014-05-09  Georg-Johann Lay  <avr@gjlay.de>
 
        Backport from 2014-05-09 trunk r210267
diff --git a/gcc/testsuite/gcc.target/avr/pr60991.c b/gcc/testsuite/gcc.target/avr/pr60991.c
new file mode 100644 (file)
index 0000000..a09f42a
--- /dev/null
@@ -0,0 +1,21 @@
+/* { dg-do run } */
+/* { dg-options "-O1" } */
+
+/* This testcase (simplified from the original bug report) exposes 
+   PR60991. The code generated for writing the __int24 value corrupts
+   the frame pointer if the offset is <= 63 + MAX_LD_OFFSET */
+
+#include <stdlib.h>
+
+int main(void)
+{
+    volatile char junk[62];
+    junk[0] = 5;
+    volatile __int24 staticConfig = 0;
+
+    if (junk[0] != 5)
+      abort();
+
+    exit(0);
+    return 0;
+}