Re: Difference between -shared, -symbolic, and -G?

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

 



Todd wrote:
Ian Lance Taylor wrote:
I have a function defined in a shared library which is exported. I
also call the function from within the shared library. I am having the
issue where, when linked from a certain executable, the calls
originating within the shared library are calling some other function,
defined elsewhere. It sounds like -symbolic is what I want.

However, when I try to link with -symbolic, I get this

gcc: unrecognized option '-symbolic'

I realize from the documentation, that -symbolic is not supported on
all platforms. Could you briefly explain, or point out some
documentation explaining how to achieve the same effect as -symbolic
using a linker script?

This stuff is all platform specific, so you need to tell us what
platform you are using.  You also need to tell us which version of gcc
you are using.

-symbolic ought to work on any ELF platform.  You can also use -shared
-Wl,-Bsymbolic to get pretty much the same effect.

Ian

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.


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux