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] fix PR 33168


The attached patch fixes PR 33168, a build issue with powerpc*-* and
libstdc++.  The problem was that a C++ VAR_DECL was getting assigned to
.sdata by rs6000_elf_in_small_data_p and therefore was assigned to the
section .sdata.$NAME.  The next time rs6000_elf_in_small_data_p was
called on the same decl, it noticed that the decl now had a section name
and compared the name to ".sdata" to determine whether the decl lived in
.sdata or not.  Of course the comparison failed, which meant that GCC
became confused about which section the variable lived in.

The patch changes things to compare section prefixes instead of full
section names.  A reduced testcase has also been added to the testsuite.
libstdc++ now builds on powerpc-none-linux-gnuspe for me; a full test
run on powerpc64-unknown-linux-gnu will commence shortly.

OK for mainline if tests pass?

-Nathan

gcc/
2007-08-24  Nathan Froyd  <froydnj@codesourcery.com>

	PR 33168
	* config/rs6000/rs6000.c (rs6000_elf_in_small_data_p): Compare
	section prefixes instead of full names.

gcc/testsuite
2007-08-24  Nathan Froyd  <froydnj@codesourcery.com>

	PR 33168
	* g++.dg/other/pr33168.C: New test.

Index: gcc/config/rs6000/rs6000.c
===================================================================
--- gcc/config/rs6000/rs6000.c	(revision 127784)
+++ gcc/config/rs6000/rs6000.c	(working copy)
@@ -19251,12 +19238,12 @@ rs6000_elf_in_small_data_p (tree decl)
   if (TREE_CODE (decl) == VAR_DECL && DECL_SECTION_NAME (decl))
     {
       const char *section = TREE_STRING_POINTER (DECL_SECTION_NAME (decl));
-      if (strcmp (section, ".sdata") == 0
-	  || strcmp (section, ".sdata2") == 0
-	  || strcmp (section, ".sbss") == 0
-	  || strcmp (section, ".sbss2") == 0
-	  || strcmp (section, ".PPC.EMB.sdata0") == 0
-	  || strcmp (section, ".PPC.EMB.sbss0") == 0)
+      if (strncmp (section, ".sdata", strlen (".sdata")) == 0
+	  || strncmp (section, ".sdata2", strlen (".sdata2")) == 0
+	  || strncmp (section, ".sbss", strlen (".sbss")) == 0
+	  || strncmp (section, ".sbss2", strlen (".sbss2")) == 0
+	  || strncmp (section, ".PPC.EMB.sdata0", strlen (".PPC.EMB.sdata0")) == 0
+	  || strncmp (section, ".PPC.EMB.sbss0", strlen (".PPC.EMB.sbss0")) == 0)
 	return true;
     }
   else
Index: gcc/testsuite/g++.dg/other/pr33168.C
===================================================================
--- gcc/testsuite/g++.dg/other/pr33168.C	(revision 0)
+++ gcc/testsuite/g++.dg/other/pr33168.C	(revision 0)
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+
+namespace {
+
+struct foo {
+  int i;
+};
+
+  const foo the_real_foo = foo();
+}
+
+namespace std {
+  const foo &the_foo = the_real_foo;
+}

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