summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>2003-11-10 08:11:47 +0000
committerebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>2003-11-10 08:11:47 +0000
commitf299cc9c6d289528799696d2f9650a7fcf4384ae (patch)
tree330f8625ffee6edd1608675f088c55cb673ef0d6
parent3e22a9e6cde86b083a25a8305ef659d0f4383c1e (diff)
downloadppe42-gcc-f299cc9c6d289528799696d2f9650a7fcf4384ae.tar.gz
ppe42-gcc-f299cc9c6d289528799696d2f9650a7fcf4384ae.zip
PR target/12865
* config/sparc/sparc.c (sparc_initialize_trampoline): Call __enable_execute_stack only after writing onto the stack. (sparc64_initialize_trampoline): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@73402 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/config/sparc/sparc.c29
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.dg/trampoline-1.c50
4 files changed, 79 insertions, 11 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 8603eb5aeb6..268e61f826d 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2003-11-10 Waldek Hebisch <hebisch@math.uni.wroc.pl>
+
+ PR target/12865
+ * config/sparc/sparc.c (sparc_initialize_trampoline): Call
+ __enable_execute_stack only after writing onto the stack.
+ (sparc64_initialize_trampoline): Likewise.
+
2003-11-09 Roger Sayle <roger@eyesopen.com>
* loop.c (check_dbra_loop): Try swapping the comparison operands
diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c
index 1454fd94375..f821a5a7682 100644
--- a/gcc/config/sparc/sparc.c
+++ b/gcc/config/sparc/sparc.c
@@ -7087,7 +7087,7 @@ sparc_type_code (register tree type)
void
sparc_initialize_trampoline (rtx tramp, rtx fnaddr, rtx cxt)
{
- /* SPARC 32 bit trampoline:
+ /* SPARC 32-bit trampoline:
sethi %hi(fn), %g1
sethi %hi(static), %g2
@@ -7097,10 +7097,6 @@ sparc_initialize_trampoline (rtx tramp, rtx fnaddr, rtx cxt)
SETHI i,r = 00rr rrr1 00ii iiii iiii iiii iiii iiii
JMPL r+i,d = 10dd ddd1 1100 0rrr rr1i iiii iiii iiii
*/
-#ifdef TRANSFER_FROM_TRAMPOLINE
- emit_library_call (gen_rtx (SYMBOL_REF, Pmode, "__enable_execute_stack"),
- LCT_NORMAL, VOIDmode, 1, tramp, Pmode);
-#endif
emit_move_insn
(gen_rtx_MEM (SImode, plus_constant (tramp, 0)),
@@ -7139,21 +7135,25 @@ sparc_initialize_trampoline (rtx tramp, rtx fnaddr, rtx cxt)
&& sparc_cpu != PROCESSOR_ULTRASPARC3)
emit_insn (gen_flush (validize_mem (gen_rtx_MEM (SImode,
plus_constant (tramp, 8)))));
+
+ /* Call __enable_execute_stack after writing onto the stack to make sure
+ the stack address is accessible. */
+#ifdef TRANSFER_FROM_TRAMPOLINE
+ emit_library_call (gen_rtx (SYMBOL_REF, Pmode, "__enable_execute_stack"),
+ LCT_NORMAL, VOIDmode, 1, tramp, Pmode);
+#endif
+
}
-/* The 64 bit version is simpler because it makes more sense to load the
+/* The 64-bit version is simpler because it makes more sense to load the
values as "immediate" data out of the trampoline. It's also easier since
we can read the PC without clobbering a register. */
void
sparc64_initialize_trampoline (rtx tramp, rtx fnaddr, rtx cxt)
{
-#ifdef TRANSFER_FROM_TRAMPOLINE
- emit_library_call (gen_rtx (SYMBOL_REF, Pmode, "__enable_execute_stack"),
- LCT_NORMAL, VOIDmode, 1, tramp, Pmode);
-#endif
+ /* SPARC 64-bit trampoline:
- /*
rd %pc, %g1
ldx [%g1+24], %g5
jmp %g5
@@ -7176,6 +7176,13 @@ sparc64_initialize_trampoline (rtx tramp, rtx fnaddr, rtx cxt)
if (sparc_cpu != PROCESSOR_ULTRASPARC
&& sparc_cpu != PROCESSOR_ULTRASPARC3)
emit_insn (gen_flushdi (validize_mem (gen_rtx_MEM (DImode, plus_constant (tramp, 8)))));
+
+ /* Call __enable_execute_stack after writing onto the stack to make sure
+ the stack address is accessible. */
+#ifdef TRANSFER_FROM_TRAMPOLINE
+ emit_library_call (gen_rtx (SYMBOL_REF, Pmode, "__enable_execute_stack"),
+ LCT_NORMAL, VOIDmode, 1, tramp, Pmode);
+#endif
}
/* Subroutines to support a flat (single) register window calling
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 93599540726..f69b0d67f72 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2003-11-10 Waldek Hebisch <hebisch@math.uni.wroc.pl>
+
+ * gcc.dg/trampoline-1.c: New test.
+
2003-11-09 Andrew Pinski <pinskia@physics.uc.edu>
* gcc.c-torture/compile/200031109-1.c: New test.
diff --git a/gcc/testsuite/gcc.dg/trampoline-1.c b/gcc/testsuite/gcc.dg/trampoline-1.c
new file mode 100644
index 00000000000..dbbd8509bff
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/trampoline-1.c
@@ -0,0 +1,50 @@
+/* PR target/12865 */
+/* Origin: Waldek Hebisch <hebisch@math.uni.wroc.pl> */
+
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+/* This used to fail on various versions of Solaris 2 because the
+ trampoline couldn't be made executable. */
+
+extern void abort(void);
+
+void foo (void)
+{
+ const int correct[1100] = {1, 0, -2, 0, 1, 0, 1, -1, -10, -30, -67};
+ int i;
+
+ double x1 (void) {return 1; }
+ double x2 (void) {return -1;}
+ double x3 (void) {return -1;}
+ double x4 (void) {return 1; }
+ double x5 (void) {return 0; }
+
+ typedef double pfun(void);
+
+ double a (int k, pfun x1, pfun x2, pfun x3, pfun x4, pfun x5)
+ {
+ double b (void)
+ {
+ k = k - 1;
+ return a (k, b, x1, x2, x3, x4 );
+ }
+
+ if (k <= 0)
+ return x4 () + x5 ();
+ else
+ return b ();
+ }
+
+ for (i=0; i<=10; i++)
+ {
+ if (fabs(a( i, x1, x2, x3, x4, x5 ) - correct [i]) > 0.1)
+ abort();
+ }
+}
+
+int main (void)
+{
+ foo ();
+ return 0;
+}
OpenPOWER on IntegriCloud