Difference between -shared, -symbolic, and -G?
Todd
todd.freed@gmail.com
Thu Oct 29 21:24:00 GMT 2009
Andrew Haley wrote:
>> I am using gcc version 4.3.3 for x86
>>
>> -Wl,-Bsymbolic looks like it does what I want.
>
> Be very, very careful. -Bsymbolic violates the C standard, and all
> manner of very weird things can happen to your program. One symptom
> is that data in a shared library that is written by an executable
> fails mysteriously to be there when read by the library. This is
> because you end up with two copies of the data, one in the shared
> library and one in the executable, even though the data is only
> defined once in the library. It is possible to solve most of these
> problems by compiling the executable as PIC.
>
> Andrew.
>
Hmm. I just need to have a function in my shared library, callable from
the executable linked against the shared library, which I can also call
from inside the shared library such that calls originating inside always
invoke the one defined inside. What is the right way to achieve this, then?
-Todd
More information about the Gcc-help
mailing list