re PR other/29639 (ext/bitmap_allocator/check_allocate_max_size.cc execution test)
authorEric Botcazou <ebotcazou@adacore.com>
Thu, 2 Nov 2006 18:40:54 +0000 (18:40 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Thu, 2 Nov 2006 18:40:54 +0000 (18:40 +0000)
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.

From-SVN: r118422

gcc/ChangeLog
gcc/except.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/eh/gcsec1.C [new file with mode: 0644]

index 74b905f131ca3dbfc19c5c1fbaeb70e6b3fd39ee..92b9048f93767e7b4e274f98561da858b9330e04 100644 (file)
@@ -1,3 +1,10 @@
+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-01  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
 
        PR middle-end/29335
index 306916968e8189582d1560b6d8389d2b7a8cc236..39827c9b68db48543c0a9405745a379cbcb4d304 100644 (file)
@@ -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 * ARG_UNUSED (fnname))
            }
          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
 
index 3c332b7179e559bdf5c593a57092a72dcae3fb6e..59e983281a7e5640b5f31777802da0c65fe53d61 100644 (file)
@@ -1,3 +1,7 @@
+2006-11-02  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * g++.dg/eh/gcsec1.C: New test.
+
 2006-11-01  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
 
        * gcc.dg/torture/builtin-math-3.c: Fix semicolons.
diff --git a/gcc/testsuite/g++.dg/eh/gcsec1.C b/gcc/testsuite/g++.dg/eh/gcsec1.C
new file mode 100644 (file)
index 0000000..5dfe02a
--- /dev/null
@@ -0,0 +1,45 @@
+/* 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;
+}