This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


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

Re: PATCH: Share the dwarf2 unwind code between glibc and gcc 3.0


   Content-Type: text/plain;
     charset="iso-8859-1"
   From: Bo Thorsen <bo@sonofthor.dk>
   Organization: SuSE Labs
   Date: Mon, 9 Jul 2001 12:25:19 +0100
   Cc: "H . J . Lu" <hjl@lucon.org>, gcc@gcc.gnu.org,
      GNU C Library <libc-alpha@sourceware.cygnus.com>, gcc-patches@gcc.gnu.org

   On Monday 09 July 2001 15:06, Mark Kettenis wrote:
   > ... And mixing code compiled with -fexceptions with a new version of
   > GCC with C++ code compiled with an older version of GCC cannot be
   > expected to work either

   Could you please explain to me how someone can ever make a binary
   compatible (between different versions of gcc compiled code) shared
   c++ library using exceptions if what you're stating here is true?

With GCC you can't, not even for C++ code that doesn't use exceptions.
The C++ ABI has been changed in almost every release.  In principle
bug-fix releases are compatible (i.e. 2.95.1 should be binary
compatible with 2.95) but even in that case there are subtle changes
that might affect binary compatibility.  GCC 3.0 is supposed to solve
this by providing a new C++ ABI that's supposed to never be changed
again.

What we're talking about here is a more subtle issue of mixing plain C
code compiled with -fexceptions with C++ code from another GCC
version.  Why would you compile plain C code with -fexceptions?  Well,
this is necessary if you have C code called from C++ that might in
turn call C++ code that throws an exception.  An example is qsort().
qsort() calls a comparison function that you pass to it.  Now if this
comparison function is a C++ function that might throw an exception
that is supposed to be caught by the C++ code that calls qsort(), then
the exception handling code needs to unwind the stack.  In order to do
so, it needs some information which we usually refer to as "frame
info".  This frame info is generated by -fexceptions.  For C++ code
-fexceptions also generates information about the exception handlers
that you defined (and about destructors).  But that stuff isn't
present in C code.  New versions of GCC can handle the frame info from
older GCC versions just fine, and they ignore the information about
exception handlers generated by older GCC versions.  So you can mix C
code compiled with -fexceptions with C++ code from GCC 3.0.  The other
way around is tricky, and will in principle not work.

Mark


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