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, pr31490] Fix section type error.


PR 31490 (Compile error section type conflict) has been sitting around
for a while even though there are two patches for it.  I picked one of
those patches (from comment #9) and tested it and would like it check it
in.  This patch seems better then the one in comment #10 because it
avoids the mis-catorization instead of fixing it up later after the
mistake was made.

Also, this patch was approved by Ian, modulo a comment request, back in
2007 (see http://gcc.gnu.org/ml/gcc-patches/2007-05/msg01280.html) and I
have updated the comment to address that issue.  I tested it on my HP-UX
and Linux boxes with no regressions.

OK to checkin?

Steve Ellcey
sje@cup.hp.com


2010-11-17  Dinar Temirbulatov <dtemirbulatov@gmail.com>
	    Steve Ellcey  <sje@cup.hp.com>

	PR middle-end/31490
	* varasm.c (categorize_decl_for_section): Ignore reloc_rw_mask
	if section attribute used.


Index: varasm.c
===================================================================
--- varasm.c	(revision 166852)
+++ varasm.c	(working copy)
@@ -6102,13 +6102,16 @@ categorize_decl_for_section (const_tree 
 	  /* Here the reloc_rw_mask is not testing whether the section should
 	     be read-only or not, but whether the dynamic link will have to
 	     do something.  If so, we wish to segregate the data in order to
-	     minimize cache misses inside the dynamic linker.  */
-	  if (reloc & targetm.asm_out.reloc_rw_mask ())
+	     minimize cache misses inside the dynamic linker.  If the data
+	     has a section attribute, ignore the value of reloc_rw_mask().  */
+	  if (reloc & targetm.asm_out.reloc_rw_mask ()
+	      && !lookup_attribute ("section", DECL_ATTRIBUTES (decl)))
 	    ret = reloc == 1 ? SECCAT_DATA_REL_LOCAL : SECCAT_DATA_REL;
 	  else
 	    ret = SECCAT_DATA;
 	}
-      else if (reloc & targetm.asm_out.reloc_rw_mask ())
+      else if (reloc & targetm.asm_out.reloc_rw_mask ()
+	       && !lookup_attribute ("section", DECL_ATTRIBUTES (decl)))
 	ret = reloc == 1 ? SECCAT_DATA_REL_RO_LOCAL : SECCAT_DATA_REL_RO;
       else if (reloc || flag_merge_constants < 2)
 	/* C and C++ don't allow different variables to share the same



2010-11-17  Steve Ellcey  <sje@cup.hp.com>

	PR middle-end/31490
	* gcc.dg/pr31490.c: New test.


Index: gcc.dg/pr31490.c
===================================================================
--- gcc.dg/pr31490.c	(revision 0)
+++ gcc.dg/pr31490.c	(revision 0)
@@ -0,0 +1,6 @@
+/* PR middle-end/31490 */
+/* { dg-do compile } */
+/* { dg-require-named-sections "" } */
+int cpu (void *attr) {}
+const unsigned long x __attribute__((section("foo"))) =  (unsigned long)&cpu;
+const unsigned long g __attribute__((section("foo"))) = 0;


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