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/RFA] SH: Fix a wrong INITIAL_EXEC TLS sequence


Hi,

I could run glibc testsuite using 4.0.0 sh-linux compiler and
found elf/tst-tls10.c fails because of a wrong INITIAL_EXEC TLS
sequence like

	mov.l	.L81,r12
	mova	.L81,r0
	add	r0,r12
	mov.l	1f,r0
	stc	gbr,r12
	mov.l	@(r0,r12),r0
	bra	2f
	add	r0,r12
	.align	2
1:	.long	a4@GOTTPOFF
2:
	...
.L81:
	.long	_GLOBAL_OFFSET_TABLE_

which clobbers the GOT value in r12 with gbr.  The appended patch
fixes it.  Bootstrapped and regtested on sh4-unknown-linux-gnu.

Regards,
	kaz
--
2004-11-04  Kaz Kojima  <kkojima@gcc.gnu.org>

	* config/sh/sh.c (prepare_move_operands): Emit a use of r12
	for non-PIC TLS_MODEL_INITIAL_EXEC case.

diff -uprN ORIG/gcc/gcc/config/sh/sh.c LOCAL/gcc/gcc/config/sh/sh.c
--- ORIG/gcc/gcc/config/sh/sh.c	2004-11-01 08:44:51.000000000 +0900
+++ LOCAL/gcc/gcc/config/sh/sh.c	2004-11-01 10:21:46.000000000 +0900
@@ -1041,7 +1041,11 @@ prepare_move_operands (rtx operands[], e
 
 	    case TLS_MODEL_INITIAL_EXEC:
 	      if (! flag_pic)
-		emit_insn (gen_GOTaddr2picreg ());
+		{
+		  emit_insn (gen_GOTaddr2picreg ());
+		  emit_insn (gen_rtx_USE (VOIDmode, gen_rtx_REG (SImode,
+								 PIC_REG)));
+		}
 	      tga_op1 = no_new_pseudos ? op0 : gen_reg_rtx (Pmode);
 	      tmp = gen_sym2GOTTPOFF (op1);
 	      emit_insn (gen_tls_initial_exec (tga_op1, tmp));


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