This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch committed] SH: Fix PR target/32163


Hi,

I've applied the attached patch on trunk to fix PR target/32163.
In the faulty case, stack protector inserts PIC insns after
the result is set to R0 register but optimizers turn them into
the insn which requires R0.  Then we get a yet another R0 spill
failure.  The patch stops such insns from scheduling.  This is
not a good solution but would be enough for this rare situation.
It's tested with bootstrap and the top level "make -k check" on
sh4-unknown-linux-gnu with no new failures.  I'll apply this
patch to 4.1/4.2 too, after the same tests done.  I think that
this PR would be a regression from 4.0 when the most secure
options are needed as gcc options.

Regards,
	kaz
--
2007-06-03  Kaz Kojima  <kkojima@gcc.gnu.org>

	PR target/32163
	* config/sh/sh.md (symGOT_load): Don't schedule insns when
	the symbol is generated with the stack protector.

--- ORIG/trunk/gcc/config/sh/sh.md	2007-04-27 21:30:47.000000000 +0900
+++ LOCAL/trunk/gcc/config/sh/sh.md	2007-06-01 08:21:18.000000000 +0900
@@ -8502,6 +8502,20 @@ label:
 					     operands[2],
 					     gen_rtx_REG (Pmode, PIC_REG)));
 
+  /* When stack protector inserts codes after the result is set to
+     R0, @(rX, r12) will cause a spill failure for R0.  Don't schedule
+     insns to avoid combining (set A (plus rX r12)) and (set op0 (mem A))
+     when rX is a GOT address for the guard symbol.  Ugly but doesn't
+     matter because this is a rare situation.  */
+  if (!TARGET_SHMEDIA
+      && flag_stack_protect
+      && GET_CODE (operands[1]) == CONST
+      && GET_CODE (XEXP (operands[1], 0)) == UNSPEC
+      && GET_CODE (XVECEXP (XEXP (operands[1], 0), 0, 0)) == SYMBOL_REF
+      && strcmp (XSTR (XVECEXP (XEXP (operands[1], 0), 0, 0), 0),
+		 \"__stack_chk_guard\") == 0)
+    emit_insn (gen_blockage ());
+
   /* N.B. This is not constant for a GOTPLT relocation.  */
   mem = gen_rtx_MEM (Pmode, operands[3]);
   MEM_NOTRAP_P (mem) = 1;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]