Patchwork [v3] cxxabi.h vs. unwind-cxx.h

login
register
mail settings
Submitter Benjamin Kosnik
Date Oct. 10, 2011, 7:22 p.m.
Message ID <20111010122211.77454fb6@shotwell>
Download mbox | patch
Permalink /patch/118819/
State New
Headers show

Comments

Benjamin Kosnik - Oct. 10, 2011, 7:22 p.m.
Here's a patch that works for both C and C++. 

tested x86/linux

-benjamin

Patch


2011-10-10  Benjamin Kosnik  <bkoz@redhat.com>

	PR libstdc++/49818
	* config/abi/pre/gnu.ver (CXXABI_1.3.6): Add symbols.
	* testsuite/util/testsuite_abi.cc: Same.
	* libsupc++/unwind-cxx.h: Move required eh API...
	* libsupc++/cxxabi.h: ... to here. Add required forward declarations.
	Use _GLIBCXX_NOTHROW.
	* libsupc++/pure.cc (__cxa_deleted_virtual): Add.
	* libsupc++/eh_alloc.cc: Use _GLIBCXX_NOTHROW.
	* libsupc++/eh_catch.cc: Same.
	* libsupc++/eh_globals.cc: Same.
	* libsupc++/eh_type.cc: Same.

diff --git a/libstdc++-v3/config/abi/pre/gnu.ver b/libstdc++-v3/config/abi/pre/gnu.ver
index 5e5aa6a..c45b7db 100644
--- a/libstdc++-v3/config/abi/pre/gnu.ver
+++ b/libstdc++-v3/config/abi/pre/gnu.ver
@@ -104,7 +104,7 @@  GLIBCXX_3.4 {
       std::logic_error*;
       std::locale::[A-Za-e]*;
       std::locale::facet::[A-Za-z]*;
-      std::locale::facet::_S_get_c_locale*;	
+      std::locale::facet::_S_get_c_locale*;
       std::locale::facet::_S_clone_c_locale*;
       std::locale::facet::_S_create_c_locale*;
       std::locale::facet::_S_destroy_c_locale*;
@@ -145,7 +145,7 @@  GLIBCXX_3.4 {
       std::strstream*;
       std::strstreambuf*;
 #     std::t[a-q]*;
-      std::t[a-g]*;      
+      std::t[a-g]*;
       std::th[a-h]*;
       std::th[j-q]*;
       std::th[s-z]*;
@@ -238,7 +238,7 @@  GLIBCXX_3.4 {
     _ZNKSs8_M_limit*;
     _ZNKSs9_M_ibeginEv;
     _ZStplIcSt11char_traitsIcESaIcEESbIT_T0_T1_E*;
-    _ZNKSs7compare*; 
+    _ZNKSs7compare*;
     _ZNKSs5c_strEv;
     _ZNKSs8capacityEv;
     _ZNKSs4copyEPc[jmy][jmy];
@@ -435,10 +435,10 @@  GLIBCXX_3.4 {
 
     # std::locale destructors
     _ZNSt6localeD*;
-	
+
     # std::locale::facet destructors
     _ZNSt6locale5facetD*;
-	 
+
     # std::locale::_Impl constructors, destructors
     _ZNSt6locale5_ImplC*;
     _ZNSt6locale5_ImplD*;
@@ -447,7 +447,7 @@  GLIBCXX_3.4 {
     _ZNSt8ios_baseD*;
     _ZNSt8ios_base4InitD*;
 
-    # bool std::has_facet 
+    # bool std::has_facet
     _ZSt9has_facetIS*;
 
     # std::use_facet
@@ -486,7 +486,7 @@  GLIBCXX_3.4 {
 
     # std::time_get_byname
     _ZNSt15time_get_byname*;
-    
+
     # std::time_put
     _ZNSt8time_put*;
     _ZNKSt8time_put*;
@@ -569,7 +569,7 @@  GLIBCXX_3.4 {
     _ZNK11__gnu_debug16_Error_formatter13_M_print_word*;
     _ZNK11__gnu_debug16_Error_formatter15_M_print_string*;
     _ZNK11__gnu_debug16_Error_formatter8_M_error*;
-    
+
     # exceptions as functions
     _ZSt16__throw_bad_castv;
     _ZSt17__throw_bad_allocv;
@@ -809,11 +809,11 @@  GLIBCXX_3.4 {
 };
 
 GLIBCXX_3.4.1 {
- 
+
     _ZNSt12__basic_fileIcE4fileEv;
- 
+
 } GLIBCXX_3.4;
- 
+
 GLIBCXX_3.4.2 {
 
     _ZN9__gnu_cxx18stdio_sync_filebufI[cw]St11char_traitsI[cw]EE4fileEv;
@@ -825,7 +825,7 @@  GLIBCXX_3.4.2 {
 } GLIBCXX_3.4.1;
 
 GLIBCXX_3.4.3 {
- 
+
     # stub functions from libmath
     acosf;
     acosl;
@@ -969,7 +969,7 @@  GLIBCXX_3.4.10 {
     _ZNKSt4hashIeEclEe;
 
     _ZSt17__verify_grouping*;
-    
+
     _ZNSt8__detail12__prime_listE;
     _ZNSt3tr18__detail12__prime_listE;
 
@@ -992,7 +992,7 @@  GLIBCXX_3.4.10 {
 } GLIBCXX_3.4.9;
 
 GLIBCXX_3.4.11 {
-	 
+
     # atomic
     __atomic_flag_for_address;
     __atomic_flag_wait_explicit;
@@ -1328,16 +1328,16 @@  CXXABI_1.3 {
     __cxa_rethrow;
     __cxa_throw;
     __cxa_type_match;
+    __cxa_vec_ctor;
     __cxa_vec_cctor;
     __cxa_vec_cleanup;
-    __cxa_vec_ctor;
+    __cxa_vec_delete;
     __cxa_vec_delete2;
     __cxa_vec_delete3;
-    __cxa_vec_delete;
     __cxa_vec_dtor;
+    __cxa_vec_new;
     __cxa_vec_new2;
     __cxa_vec_new3;
-    __cxa_vec_new;
     __gxx_personality_v0;
     __gxx_personality_sj0;
     __dynamic_cast;
@@ -1491,3 +1491,12 @@  CXXABI_1.3.5 {
     _ZTVSt16nested_exception;
 
 } CXXABI_1.3.4;
+
+CXXABI_1.3.6 {
+
+    __cxa_allocate_dependent_exception;
+    __cxa_free_dependent_exception;
+    __cxa_get_exception_ptr;
+    __cxa_deleted_virtual;
+
+} CXXABI_1.3.5;
\ No newline at end of file
diff --git a/libstdc++-v3/libsupc++/cxxabi.h b/libstdc++-v3/libsupc++/cxxabi.h
index 0f3856e..e78f551 100644
--- a/libstdc++-v3/libsupc++/cxxabi.h
+++ b/libstdc++-v3/libsupc++/cxxabi.h
@@ -123,23 +123,26 @@  namespace __cxxabiv1
   void
   __cxa_guard_abort(__guard*) _GLIBCXX_NOTHROW;
 
+  // DSO destruction.
+  int
+  __cxa_atexit(void (*)(void*), void*, void*) _GLIBCXX_NOTHROW;
+
+  int
+  __cxa_finalize(void*);
+
   // Pure virtual functions.
   void
   __cxa_pure_virtual(void) __attribute__ ((__noreturn__));
 
-  // Exception handling.
   void
-  __cxa_bad_cast();
+  __cxa_deleted_virtual(void) __attribute__ ((__noreturn__));
 
-  void
-  __cxa_bad_typeid();
-
-  // DSO destruction.
-  int
-  __cxa_atexit(void (*)(void*), void*, void*) _GLIBCXX_NOTHROW;
+  // Exception handling auxillary.
+  void 
+  __cxa_bad_cast() __attribute__((__noreturn__));
 
-  int
-  __cxa_finalize(void*);
+  void 
+  __cxa_bad_typeid() __attribute__((__noreturn__));
 
 
   /**
@@ -185,6 +188,7 @@  namespace __cxxabiv1
   char*
   __cxa_demangle(const char* __mangled_name, char* __output_buffer,
 		 size_t* __length, int* __status);
+
 #ifdef __cplusplus
   }
 } // namespace __cxxabiv1
@@ -547,30 +551,89 @@  namespace __cxxabiv1
 		__upcast_result& __restrict __result) const;
   };
 
+  // Exception handling forward declarations.
+  struct __cxa_exception;
+  struct __cxa_refcounted_exception;
+  struct __cxa_dependent_exception;
+  struct __cxa_eh_globals;
+
+  extern "C"
+  {
   // Dynamic cast runtime.
+
   // src2dst has the following possible values
   //  >-1: src_type is a unique public non-virtual base of dst_type
   //       dst_ptr + src2dst == src_ptr
   //   -1: unspecified relationship
   //   -2: src_type is not a public base of dst_type
   //   -3: src_type is a multiple public non-virtual base of dst_type
-  extern "C" void*
+  void*
   __dynamic_cast(const void* __src_ptr, // Starting object.
 		 const __class_type_info* __src_type, // Static type of object.
 		 const __class_type_info* __dst_type, // Desired target type.
 		 ptrdiff_t __src2dst); // How src and dst are related.
 
 
+  // Exception handling runtime.
+
+  // The __cxa_eh_globals for the current thread can be obtained by using
+  // either of the following functions.  The "fast" version assumes at least
+  // one prior call of __cxa_get_globals has been made from the current
+  // thread, so no initialization is necessary.
+  __cxa_eh_globals*
+  __cxa_get_globals() _GLIBCXX_NOTHROW __attribute__ ((__const__));
+
+  __cxa_eh_globals*
+  __cxa_get_globals_fast() _GLIBCXX_NOTHROW __attribute__ ((__const__));
+
+  // Allocate memory for the primary exception plus the thrown object.
+  void*
+  __cxa_allocate_exception(size_t) _GLIBCXX_NOTHROW;
+
+  // Free the space allocated for the primary exception.
+  void 
+  __cxa_free_exception(void*) _GLIBCXX_NOTHROW;
+
+  // Throw the exception.
+  void
+  __cxa_throw(void*, std::type_info*, void (*) (void *)) 
+  __attribute__((__noreturn__));
+
+  // Used to implement exception handlers.
+  void*
+  __cxa_get_exception_ptr(void*) _GLIBCXX_NOTHROW __attribute__ ((__pure__));
+
+  void*
+  __cxa_begin_catch(void*) _GLIBCXX_NOTHROW;
+
+  void 
+  __cxa_end_catch();
+
+  void 
+  __cxa_rethrow() __attribute__((__noreturn__));
+
   // Returns the type_info for the currently handled exception [15.3/8], or
   // null if there is none.
-  extern "C" std::type_info*
+  std::type_info*
   __cxa_current_exception_type() _GLIBCXX_NOTHROW __attribute__ ((__pure__));
 
+  // GNU Extensions.
+
+  // Allocate memory for a dependent exception.
+  __cxa_dependent_exception*
+  __cxa_allocate_dependent_exception() _GLIBCXX_NOTHROW;
+
+  // Free the space allocated for the dependent exception.
+  void
+  __cxa_free_dependent_exception(__cxa_dependent_exception*) _GLIBCXX_NOTHROW;
+
+  } // extern "C"
+
   // A magic placeholder class that can be caught by reference
   // to recognize foreign exceptions.
   class __foreign_exception
   {
-    virtual ~__foreign_exception() _GLIBCXX_NOTHROW;
+    virtual ~__foreign_exception() throw();
     virtual void __pure_dummy() = 0; // prevent catch by value
   };
 
diff --git a/libstdc++-v3/libsupc++/eh_alloc.cc b/libstdc++-v3/libsupc++/eh_alloc.cc
index 818af0f..74474d8 100644
--- a/libstdc++-v3/libsupc++/eh_alloc.cc
+++ b/libstdc++-v3/libsupc++/eh_alloc.cc
@@ -1,5 +1,5 @@ 
 // -*- C++ -*- Allocate exception objects.
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009, 2011
 // Free Software Foundation, Inc.
 //
 // This file is part of GCC.
@@ -94,7 +94,7 @@  namespace
 }
 
 extern "C" void *
-__cxxabiv1::__cxa_allocate_exception(std::size_t thrown_size) throw()
+__cxxabiv1::__cxa_allocate_exception(std::size_t thrown_size) _GLIBCXX_NOTHROW
 {
   void *ret;
 
@@ -139,7 +139,7 @@  __cxxabiv1::__cxa_allocate_exception(std::size_t thrown_size) throw()
 
 
 extern "C" void
-__cxxabiv1::__cxa_free_exception(void *vptr) throw()
+__cxxabiv1::__cxa_free_exception(void *vptr) _GLIBCXX_NOTHROW
 {
   char *base = (char *) emergency_buffer;
   char *ptr = (char *) vptr;
@@ -158,7 +158,7 @@  __cxxabiv1::__cxa_free_exception(void *vptr) throw()
 
 
 extern "C" __cxa_dependent_exception*
-__cxxabiv1::__cxa_allocate_dependent_exception() throw()
+__cxxabiv1::__cxa_allocate_dependent_exception() _GLIBCXX_NOTHROW
 {
   __cxa_dependent_exception *ret;
 
@@ -202,7 +202,7 @@  __cxxabiv1::__cxa_allocate_dependent_exception() throw()
 
 extern "C" void
 __cxxabiv1::__cxa_free_dependent_exception
-  (__cxa_dependent_exception *vptr) throw()
+  (__cxa_dependent_exception *vptr) _GLIBCXX_NOTHROW
 {
   char *base = (char *) dependents_buffer;
   char *ptr = (char *) vptr;
diff --git a/libstdc++-v3/libsupc++/eh_catch.cc b/libstdc++-v3/libsupc++/eh_catch.cc
index 567222a..b111497 100644
--- a/libstdc++-v3/libsupc++/eh_catch.cc
+++ b/libstdc++-v3/libsupc++/eh_catch.cc
@@ -1,5 +1,5 @@ 
 // -*- C++ -*- Exception handling routines for catching.
-// Copyright (C) 2001, 2003, 2004, 2009 Free Software Foundation, Inc.
+// Copyright (C) 2001, 2003, 2004, 2009, 2011 Free Software Foundation, Inc.
 //
 // This file is part of GCC.
 //
@@ -28,7 +28,7 @@ 
 using namespace __cxxabiv1;
 
 extern "C" void *
-__cxxabiv1::__cxa_get_exception_ptr(void *exc_obj_in) throw()
+__cxxabiv1::__cxa_get_exception_ptr(void *exc_obj_in) _GLIBCXX_NOTHROW
 {
   _Unwind_Exception *exceptionObject
     = reinterpret_cast <_Unwind_Exception *>(exc_obj_in);
@@ -37,7 +37,7 @@  __cxxabiv1::__cxa_get_exception_ptr(void *exc_obj_in) throw()
 }
 
 extern "C" void *
-__cxxabiv1::__cxa_begin_catch (void *exc_obj_in) throw()
+__cxxabiv1::__cxa_begin_catch (void *exc_obj_in) _GLIBCXX_NOTHROW
 {
   _Unwind_Exception *exceptionObject
     = reinterpret_cast <_Unwind_Exception *>(exc_obj_in);
diff --git a/libstdc++-v3/libsupc++/eh_globals.cc b/libstdc++-v3/libsupc++/eh_globals.cc
index 63f46a9..0c7f6b7 100644
--- a/libstdc++-v3/libsupc++/eh_globals.cc
+++ b/libstdc++-v3/libsupc++/eh_globals.cc
@@ -1,5 +1,5 @@ 
 // -*- C++ -*- Manage the thread-local exception globals.
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2009
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2009, 2011
 // Free Software Foundation, Inc.
 //
 // This file is part of GCC.
@@ -47,7 +47,7 @@  using namespace __cxxabiv1;
 namespace
 {
   abi::__cxa_eh_globals*
-  get_global() throw()
+  get_global() _GLIBCXX_NOTHROW
   {
     static __thread abi::__cxa_eh_globals global;
     return &global;
@@ -55,11 +55,11 @@  namespace
 } // anonymous namespace
 
 extern "C" __cxa_eh_globals*
-__cxxabiv1::__cxa_get_globals_fast() throw()
+__cxxabiv1::__cxa_get_globals_fast() _GLIBCXX_NOTHROW
 { return get_global(); }
 
 extern "C" __cxa_eh_globals*
-__cxxabiv1::__cxa_get_globals() throw()
+__cxxabiv1::__cxa_get_globals() _GLIBCXX_NOTHROW
 { return get_global(); }
 
 
@@ -110,7 +110,7 @@  struct __eh_globals_init
 static __eh_globals_init init;
 
 extern "C" __cxa_eh_globals*
-__cxxabiv1::__cxa_get_globals_fast() throw()
+__cxxabiv1::__cxa_get_globals_fast() _GLIBCXX_NOTHROW
 {
   __cxa_eh_globals* g;
   if (init._M_init)
@@ -121,7 +121,7 @@  __cxxabiv1::__cxa_get_globals_fast() throw()
 }
 
 extern "C" __cxa_eh_globals*
-__cxxabiv1::__cxa_get_globals() throw()
+__cxxabiv1::__cxa_get_globals() _GLIBCXX_NOTHROW
 {
   __cxa_eh_globals* g;
   if (init._M_init)
@@ -148,11 +148,11 @@  __cxxabiv1::__cxa_get_globals() throw()
 #else
 
 extern "C" __cxa_eh_globals*
-__cxxabiv1::__cxa_get_globals_fast() throw()
+__cxxabiv1::__cxa_get_globals_fast() _GLIBCXX_NOTHROW
 { return &eh_globals; }
 
 extern "C" __cxa_eh_globals*
-__cxxabiv1::__cxa_get_globals() throw()
+__cxxabiv1::__cxa_get_globals() _GLIBCXX_NOTHROW
 { return &eh_globals; }
 
 #endif
diff --git a/libstdc++-v3/libsupc++/eh_type.cc b/libstdc++-v3/libsupc++/eh_type.cc
index bb8be0b..245e0ea 100644
--- a/libstdc++-v3/libsupc++/eh_type.cc
+++ b/libstdc++-v3/libsupc++/eh_type.cc
@@ -1,5 +1,5 @@ 
 // -*- C++ -*- Exception handling routines for catching.
-// Copyright (C) 2001, 2008, 2009 Free Software Foundation, Inc.
+// Copyright (C) 2001, 2008, 2009, 2011 Free Software Foundation, Inc.
 //
 // This file is part of GCC.
 //
@@ -33,7 +33,7 @@  namespace __cxxabiv1
 // Returns the type_info for the currently handled exception [15.3/8], or
 // null if there is none.
 extern "C"
-std::type_info *__cxa_current_exception_type () throw()
+std::type_info *__cxa_current_exception_type () _GLIBCXX_NOTHROW
 {
   __cxa_eh_globals *globals = __cxa_get_globals ();
   __cxa_exception *header = globals->caughtExceptions;
diff --git a/libstdc++-v3/libsupc++/pure.cc b/libstdc++-v3/libsupc++/pure.cc
index acf7232..4879e59 100644
--- a/libstdc++-v3/libsupc++/pure.cc
+++ b/libstdc++-v3/libsupc++/pure.cc
@@ -1,5 +1,5 @@ 
 // -*- C++ -*- 
-// Copyright (C) 2000, 2001, 2009 Free Software Foundation
+// Copyright (C) 2000, 2001, 2009, 2011 Free Software Foundation
 //
 // This file is part of GCC.
 //
@@ -49,3 +49,10 @@  __cxxabiv1::__cxa_pure_virtual (void)
   writestr ("pure virtual method called\n");
   std::terminate ();
 }
+
+extern "C" void
+__cxxabiv1::__cxa_deleted_virtual (void)
+{
+  writestr ("deleted virtual method called\n");
+  std::terminate ();
+}
diff --git a/libstdc++-v3/libsupc++/unwind-cxx.h b/libstdc++-v3/libsupc++/unwind-cxx.h
index e62ea7c..84dd367 100644
--- a/libstdc++-v3/libsupc++/unwind-cxx.h
+++ b/libstdc++-v3/libsupc++/unwind-cxx.h
@@ -36,6 +36,7 @@ 
 #include <cstddef>
 #include "unwind.h"
 #include <bits/atomic_word.h>
+#include <cxxabi.h>
 
 #pragma GCC visibility push(default)
 
@@ -143,47 +144,6 @@  struct __cxa_eh_globals
 #endif
 };
 
-
-// The __cxa_eh_globals for the current thread can be obtained by using
-// either of the following functions.  The "fast" version assumes at least
-// one prior call of __cxa_get_globals has been made from the current
-// thread, so no initialization is necessary.
-extern "C" __cxa_eh_globals *__cxa_get_globals () throw() 
-  __attribute__ ((__const__));
-extern "C" __cxa_eh_globals *__cxa_get_globals_fast () throw() 
-  __attribute__ ((__const__));
-
-// Allocate memory for the primary exception plus the thrown object.
-extern "C" void *__cxa_allocate_exception(std::size_t thrown_size) throw();
-
-// Free the space allocated for the primary exception.
-extern "C" void __cxa_free_exception(void *thrown_exception) throw();
-
-// Allocate memory for a dependent exception.
-extern "C" __cxa_dependent_exception*
-__cxa_allocate_dependent_exception() throw();
-
-// Free the space allocated for the dependent exception.
-extern "C" void
-__cxa_free_dependent_exception(__cxa_dependent_exception *ex) throw();
-
-// Throw the exception.
-extern "C" void __cxa_throw (void *thrown_exception,
-			     std::type_info *tinfo,
-			     void (*dest) (void *))
-  __attribute__((__noreturn__));
-
-// Used to implement exception handlers.
-extern "C" void *__cxa_get_exception_ptr (void *) throw()
-  __attribute__ ((__pure__));
-extern "C" void *__cxa_begin_catch (void *) throw();
-extern "C" void __cxa_end_catch ();
-extern "C" void __cxa_rethrow () __attribute__((__noreturn__));
-
-// These facilitate code generation for recurring situations.
-extern "C" void __cxa_bad_cast () __attribute__((__noreturn__));
-extern "C" void __cxa_bad_typeid () __attribute__((__noreturn__));
-
 // @@@ These are not directly specified by the IA-64 C++ ABI.
 
 // Handles re-checking the exception specification if unexpectedHandler
diff --git a/libstdc++-v3/testsuite/util/testsuite_abi.cc b/libstdc++-v3/testsuite/util/testsuite_abi.cc
index f1f5ad6..9e6837e 100644
--- a/libstdc++-v3/testsuite/util/testsuite_abi.cc
+++ b/libstdc++-v3/testsuite/util/testsuite_abi.cc
@@ -204,6 +204,7 @@  check_version(symbol& test, bool added)
       known_versions.push_back("CXXABI_1.3.3");
       known_versions.push_back("CXXABI_1.3.4");
       known_versions.push_back("CXXABI_1.3.5");
+      known_versions.push_back("CXXABI_1.3.6");
       known_versions.push_back("CXXABI_LDBL_1.3");
     }
   compat_list::iterator begin = known_versions.begin();