bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: two instances of global from shared lib linked with -Bsymbolic


From: Ian Lance Taylor
Subject: Re: two instances of global from shared lib linked with -Bsymbolic
Date: 06 Apr 2004 12:22:09 -0400
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3

Rafal Dabrowa <address@hidden> writes:

> On Tuesday 06 of April 2004 15:13, Ian Lance Taylor wrote:
> > Rafal Dabrowa <address@hidden> writes:
> > >   I have created a global (integer) variable in shared library.
> > > The library is linked with -Bsymbolic option. Main program
> > > sees this variable as a separate copy: any changes of this
> > > variable aren't seen in library and vice versa.
> >
> > Yes, that is what happens when you use -Bsymbolic.  If you don't want
> > this behaviour, don't use -Bsymbolic.
> >
> > Ian
> 
> Even if the variable is declared as "extern" in main program ? This breaks 
> language rules !

Using -Bsymbolic breaks language rules.  That is why it is not the
default.  The option exists because it can make shared library code
more efficient, for people who do not require strict adherence to
normal variable usage.

Why are you using -Bsymbolic?

> Suppose we have defined two variables in shared library: glob1 and glob2.
> In main program, we have defined only glob1 variable, but we use both glob1 
> and glob2.
>       Without -Bsymbolic option, both glob1 and glob2 in program are shared 
> with 
> library. With -Bsymbolic option, both have separate copies.
>       I have a possibility to work under AIX system. It behaves in another 
> way: 
> although glob1 has two separate copies, but glob2 is common. And this is 
> intuitive because glob 1 *is* defined in program, but glob2 is *not* defined 
> in program - it is only an external variable defined in library. Is there a 
> possibility to behave that under Linux ?

I think you could get what you want by using a linker script to hide
glob2 while exposing glob1.  Or vice-versa.  I'm not really sure what
you want.

Ian




reply via email to

[Prev in Thread] Current Thread [Next in Thread]