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 COMDAT crash on AMD64


Michael Matz reported that my COMDAT patch caused a crash on AMD64 due
to the fact that we were not passing in a DECL for a linkonce
section.  The jump tables for a switch statement, which go in
read-only data on AMD64, are placed in their own linkonce section if
the associated function is linkonce.  This patch makes sure they go in
the same COMDAT group.

Tested with Michael's test case in an AMD64 cross compiler, committed
to mainline and csl-arm-branch as obvious.

--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com

2004-09-15  Mark Mitchell  <mark@codesourcery.com>

	* varasm.c (default_function_rdodata_section): Make sure to pass
	along a decl for a link-once section.

2004-09-15  Mark Mitchell  <mark@codesourcery.com>

	* g++.dg/opt/switch1.C: New test.

Index: varasm.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/varasm.c,v
retrieving revision 1.449
diff -c -5 -p -r1.449 varasm.c
*** varasm.c	15 Sep 2004 17:02:56 -0000	1.449
--- varasm.c	15 Sep 2004 22:05:18 -0000
*************** default_function_rodata_section (tree de
*** 598,608 ****
  	  size_t len = strlen (name) + 1;
  	  char *rname = alloca (len);
  
  	  memcpy (rname, name, len);
  	  rname[14] = 'r';
! 	  named_section_flags (rname, SECTION_LINKONCE);
  	  return;
  	}
        /* For .text.foo we want to use .rodata.foo.  */
        else if (flag_function_sections && flag_data_sections
  	       && strncmp (name, ".text.", 6) == 0)
--- 598,608 ----
  	  size_t len = strlen (name) + 1;
  	  char *rname = alloca (len);
  
  	  memcpy (rname, name, len);
  	  rname[14] = 'r';
! 	  named_section_real (rname, SECTION_LINKONCE, decl);
  	  return;
  	}
        /* For .text.foo we want to use .rodata.foo.  */
        else if (flag_function_sections && flag_data_sections
  	       && strncmp (name, ".text.", 6) == 0)
Index: testsuite/g++.dg/opt/switch1.C
===================================================================
RCS file: testsuite/g++.dg/opt/switch1.C
diff -N testsuite/g++.dg/opt/switch1.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/opt/switch1.C	15 Sep 2004 22:05:26 -0000
***************
*** 0 ****
--- 1,23 ----
+ // { dg-options "-O1" }
+ 
+ template <typename T>
+ int f(T t) {
+   switch (t) {
+   case 1:
+     return 5;
+   case 2:
+     return 6;
+   case 3:
+     return -4;
+   case 4:
+     return 8;
+   case 5:
+     return 12;
+   case 6:
+     return 13;
+   default:
+     return -27;
+   }
+ }
+ 
+ template int f(int);


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