libgcc problems with shared libraries

Andrey Slepuhin pooh@msu.ru
Tue Jan 13 04:52:00 GMT 1998


On 12-Jan-98 David Edelsohn wrote:
>>>>>> Andrey Slepuhin  writes:
> 
> Andrey> I found a serious problem with libgcc using shared libraries on AIX.
> Andrey> The problem is following:
> Andrey> 1) Because every shared library is linked with static libgcc.a,
> Andrey> it has its own instances of libgcc's static variables.
> Andrey> 2) This causes the following effect: if, for example, a function
> Andrey> in shared library calls set_terminate(), then a local instance
> Andrey> of __terminate_func is changed, while a program linked with this
> Andrey> shared library uses its own instance of __terminate_func which
> Andrey> is still set to default.
> 
> Andrey> I can suggest the following possible workarounds:
> Andrey> 1) to move static variables into libstdc++,
> Andrey> 2) to create a shared libgcc,
> Andrey> but both are not good.
> 
>       This should not be limited to AIX.  It should affect any system
> using shared libraries where libgcc.a is a static library.

On AIX4.2 and later problem can be solved by the following way:
1) Linking shared library without libgcc but with -G ld flag (i.e. ready
   for run-time linking).
2) Linking executable with -brtl ld flag.
I checked that this method works, but not compatible with older AIXes.

Question: should I try to build shared libgcc, or this is unacceptable?

Andrey.

P.S. I discussed a problem with some specialists in MSU, and they said
     that libgcc shouldn't contain such static variables as __terminate_func.
 



More information about the Gcc mailing list