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: 07 Apr 2004 09:47:34 -0400
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3

Rafal Dabrowa <address@hidden> writes:

> 2. behave more smart with global variables: if the variable is defined in 
> main 
> program also, then two separate instances are created. If the variable is not 
> defined in main program (but declared only as "extern"), then only one 
> variable instance appears. This should work like function symbols resolution: 
> if a function is defined both in library and in main program, then both use 
> own function instance. If main program doesn't have own function defined, 
> then it uses function from library.
> 
> I am compiling a code which is primarily developed under AIX system. AIX 
> behaves in this way, and I went into trouble. Is complicated to add such 
> possibility in ld program ?

AIX does not use ELF, and the semantics of shared libraries are
different, as you have discovered.  I personally think that the ELF
behaviour is simpler to understand: if the main program and a shared
library use the same name for a global variable, then they refer to
the same global variable.

Of course it does not work that way if you use -Bsymbolic, and you can
also use version scripts, or various attributes, to achieve other
effects, including the one you want.  But I think that the default
behaviour is appropriate and reasonable.

If you want a single command line option to make the ELF linker work
like the AIX linker, then I'm afraid that there isn't one.  I suppose
the right option might be something to use when creating the shared
library which would give every dynamic symbol the protected attribute.
It probably wouldn't be too difficult to write such a patch.

Ian




reply via email to

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