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]

Fix PR other/29639


I recently commited a patch that had a long history

2006-10-28  Eric Botcazou  <ebotcazou@adacore.com>

	* except.h (output_function_exception_table): Add 'const char*' param.
	* except.c (switch_to_exception_section): Add 'const char*' param.
	If named sections are supported and HAVE_LD_EH_GC_SECTIONS is defined
	and flag_function_sections is set, use a function-specific section.
	(output_function_exception_table): Add 'const char*' param.
	Adjust call to switch_to_exception_section.
	* final.c (rest_of_handle_final): Adjust calls to
	output_function_exception_table.
	* configure.ac (HAVE_LD_EH_GC_SECTIONS): New check.
	* config.in: Regenerate.
	* configure: Likewise.

Initial discussion: http://gcc.gnu.org/ml/gcc/2004-03/msg00506.html
First submission: http://gcc.gnu.org/ml/gcc-patches/2004-04/msg01768.html
Second submission: http://gcc.gnu.org/ml/gcc-patches/2006-03/msg01265.html

It turns out that the changes related to the section anchor stuff had been
installed in-between and had slightly changed the code, which I totally 
overlooked, thus causing PR other/29639.  Sorry about that.

Bootstrapped/regtested on i586-suse-linux, w/ and w/o binutils support, and 
installed on the mainline as obvious.


2006-11-02  Eric Botcazou  <ebotcazou@adacore.com>

	PR other/29639
	* except.c (switch_to_exception_section): Do not cache the section
	if named sections are supported and HAVE_LD_EH_GC_SECTIONS is defined
	and flag_function_sections is set.


2006-11-02  Eric Botcazou  <ebotcazou@adacore.com>

	* g++.dg/eh/gcsec1.C: New test.


-- 
Eric Botcazou
Index: except.c
===================================================================
--- except.c	(revision 118107)
+++ except.c	(working copy)
@@ -3522,8 +3522,14 @@ sjlj_output_call_site_table (void)
 static void
 switch_to_exception_section (const char * ARG_UNUSED (fnname))
 {
-  if (exception_section == 0)
+  section *s;
+
+  if (exception_section)
+    s = exception_section;
+  else
     {
+      /* Compute the section and cache it into exception_section,
+	 unless it depends on the function name.  */
       if (targetm.have_named_sections)
 	{
 	  int flags;
@@ -3539,22 +3545,26 @@ switch_to_exception_section (const char 
 	    }
 	  else
 	    flags = SECTION_WRITE;
+
 #ifdef HAVE_LD_EH_GC_SECTIONS
 	  if (flag_function_sections)
 	    {
 	      char *section_name = xmalloc (strlen (fnname) + 32);
 	      sprintf (section_name, ".gcc_except_table.%s", fnname);
-	      exception_section = get_section (section_name, flags, NULL);
+	      s = get_section (section_name, flags, NULL);
 	      free (section_name);
 	    }
 	  else
 #endif
-	  exception_section = get_section (".gcc_except_table", flags, NULL);
+	    exception_section
+	      = s = get_section (".gcc_except_table", flags, NULL);
 	}
       else
-	exception_section = flag_pic ? data_section : readonly_data_section;
+	exception_section
+	  = s = flag_pic ? data_section : readonly_data_section;
     }
-  switch_to_section (exception_section);
+
+  switch_to_section (s);
 }
 #endif
 
/* PR other/29639 */
/* AIX gld supports garbage collection. But AIX gcc does not support 
   -ffunction-sections or -fdata-sections.  */
/* { dg-do run { xfail rs6000-*-aix* powerpc*-*-aix* } } */
/* { dg-require-gc-sections "" } */
/* { dg-options "-ffunction-sections -Wl,--gc-sections" } */

extern "C" void abort (void);

int g = 0;

void raise_exception()
{
  throw 1;
}

void used()
{
  try {
    raise_exception ();
  }
  catch (int) {
    g = 1;
  }
}

void unused()
{
  try {
    raise_exception ();
  }
  catch (int) {
    g = 1;
  }
}

int main()
{
  used ();

  if (g != 1)
    abort ();

  return 0;
}

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