This is the mail archive of the 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] Fix TLS and -fstack-protector on sparc64


%g7 register is fixed thread pointer register both in Linux and to my
knowledge in Solaris as well, used for TLS (and on Linux for
-fstack-protector as well).
But, if in some source we want to read the thread pointer register
and do something like:
register void *tp __asm ("%g7");
then ld won't allow mixing such objects with other objects that
use %g7 solely for TLS (or -fstack-protector).
The patch below just instructs as/ld to not issue any warnings about that,
no checking is IMHO needed for %g7 - GCC has hardcoded %g7 in many places
as thread pointer register and so does Linux (and presumably Solaris)
libc as well.

2006-02-02  Jakub Jelinek  <>

	* config/sparc/sparc.c (sparc_output_scratch_registers): Use
	#ignore instead of #scratch for %g7 .register directive.

--- gcc/config/sparc/sparc.c.jj	2006-01-31 23:32:07.000000000 +0100
+++ gcc/config/sparc/sparc.c	2006-02-02 00:23:25.000000000 +0100
@@ -3693,7 +3693,10 @@ sparc_output_scratch_registers (FILE *fi
 	  && ! sparc_hard_reg_printed [i])
 	  sparc_hard_reg_printed [i] = 1;
-	  fprintf (file, "\t.register\t%%g%d, #scratch\n", i);
+	  /* %g7 is used as TLS base register, use #ignore
+	     for it instead of #scratch.  */
+	  fprintf (file, "\t.register\t%%g%d, #%s\n", i,
+		   i == 7 ? "ignore" : "scratch");
       if (i == 3) i = 5;


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