This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils 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]

LD: C++ Exceptions and Version Scripts


Hi all.

I am having a problem using gcc 3 C++ exceptions together with ld version 
scripts.

For exception handling, gcc exports certain weak symbols (_ZTI*, _ZTS*) 
from all shared libs that use those exceptions. For exceptions to be 
handled reliably across shared lib boundaries, it is important that all 
libs bind to identical instances of those symbols.

We (OpenOffice.org) have a large number of shared libs, some using 
version scripts to minimize exports, others not (exporting all global 
symbols).  Now, imagine there are two libs using version scripts, namely

# lib1:
NAME1 {
    global:
        # ...
        _ZTI*;
        _ZTS*;
    local:
        *;
};

#lib2:
NAME2 {
    global:
        # ...
        _ZTI*;
        _ZTS*;
    local:
        *;
};

If lib1 throws an exception, it cannot be caught by lib2, as the two libs 
use differently named versions (NAME1 vs. NAME2) of the relevant 
_ZTI*/_ZTS* symbols.

The solution I came up with is

# lib1:
Base. { global: _ZTI*; _ZTS*; };
NAME1 {
    global:
        # ...
    local:
        *;
};

# lib2:
Base. { global: _ZTI*; _ZTS*; };
NAME2 {
    global:
        # ...
    local:
        *;
};

That is, adding a version named "Base." (named with a trailing dot to 
avoid collision with other exported symbols) to each shared lib using 
version scripts.  This has some drawbacks:

-  The name "Base." must be used consistently across all libs.
-  This solution is not backwards compatible.  (Imagine there are two 
libs, both currently using the same NAME1 to version the _ZTI*/_ZTS* 
symbols.  Throwing exceptions currently works between these two.  One of 
the libs is replaced with a new instance, that now uses "Base." to 
version the _ZTI*/_ZTS* symbols.  Throwing exceptions now fails.)

Is there a better way to solve the problem (maybe a way to mark some 
symbols as "unversioned" when using a version script)?

-Stephan

PS:  Please cc me directly, as I'm not on this mailing list.  Thanks.


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