public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Fix SH PIE TLS ICE
@ 2009-10-21 12:34 Joseph S. Myers
  2009-10-21 13:03 ` Kaz Kojima
  0 siblings, 1 reply; 2+ messages in thread
From: Joseph S. Myers @ 2009-10-21 12:34 UTC (permalink / raw)
  To: gcc-patches; +Cc: aoliva, kkojima

This patch fixes an ICE that appears when compiling code using TLS
variables for SH with -fpie or -fPIE.  This combination causes
UNSPEC_TPOFF - the Local Exec model - to be used in
position-independent code.  @TPOFF should be fine in a PIE; the value
is resolved at link time and does not depend on the location of the
executable, while if code for a shared library is being built (-fpic
or -fPIC) then UNSPEC_TPOFF will never be generated anyway because the
Local Exec TLS model will not be used.  So I think
nonpic_symbol_mentioned_p should allow this case.

Tested with no regressions with cross to sh-linux-gnu.  OK to commit?

2009-10-21  Joseph Myers  <joseph@codesourcery.com>

	* config/sh/sh.c (nonpic_symbol_mentioned_p): Allow UNSPEC_TPOFF.

testsuite:
2009-10-21  Joseph Myers  <joseph@codesourcery.com>

	* gcc.dg/tls/pie-1.c: New test.

Index: gcc/testsuite/gcc.dg/tls/pie-1.c
===================================================================
--- gcc/testsuite/gcc.dg/tls/pie-1.c	(revision 0)
+++ gcc/testsuite/gcc.dg/tls/pie-1.c	(revision 0)
@@ -0,0 +1,6 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target fpic } */
+/* { dg-options "-fpie" } */
+/* { dg-require-effective-target tls } */
+
+__thread int a; int b; int main() { return a = b; }
Index: gcc/config/sh/sh.c
===================================================================
--- gcc/config/sh/sh.c	(revision 152999)
+++ gcc/config/sh/sh.c	(working copy)
@@ -9431,6 +9431,7 @@
 	  || XINT (x, 1) == UNSPEC_GOTPLT
 	  || XINT (x, 1) == UNSPEC_GOTTPOFF
 	  || XINT (x, 1) == UNSPEC_DTPOFF
+	  || XINT (x, 1) == UNSPEC_TPOFF
 	  || XINT (x, 1) == UNSPEC_PLT
 	  || XINT (x, 1) == UNSPEC_SYMOFF
 	  || XINT (x, 1) == UNSPEC_PCREL_SYMOFF))

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Fix SH PIE TLS ICE
  2009-10-21 12:34 Fix SH PIE TLS ICE Joseph S. Myers
@ 2009-10-21 13:03 ` Kaz Kojima
  0 siblings, 0 replies; 2+ messages in thread
From: Kaz Kojima @ 2009-10-21 13:03 UTC (permalink / raw)
  To: joseph; +Cc: gcc-patches, aoliva

"Joseph S. Myers" <joseph@codesourcery.com> wrote:
> This patch fixes an ICE that appears when compiling code using TLS
> variables for SH with -fpie or -fPIE.  This combination causes
> UNSPEC_TPOFF - the Local Exec model - to be used in
> position-independent code.  @TPOFF should be fine in a PIE; the value
> is resolved at link time and does not depend on the location of the
> executable, while if code for a shared library is being built (-fpic
> or -fPIC) then UNSPEC_TPOFF will never be generated anyway because the
> Local Exec TLS model will not be used.  So I think
> nonpic_symbol_mentioned_p should allow this case.
> 
> Tested with no regressions with cross to sh-linux-gnu.  OK to commit?

OK.  Thanks for the patch!

Regards,
	kaz

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-10-21 13:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-21 12:34 Fix SH PIE TLS ICE Joseph S. Myers
2009-10-21 13:03 ` Kaz Kojima

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).