Re: Re: How to make gcc give a check about symbol conflicts in shared libraries it links?

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

 



    Thanks for the infomation. I am using Ubuntu10 with a Linux2.6 kernel on x86 system, and installed the
 gcc tool chain with x86/arm target.
    From my understanding,  there should be two chances to give a check about the symbol naming conflict:
One is when the gcc tool chain try to link the .o file and .so file into the executable file, Two is before it is run the
loader of the system could check if there are functions or names having same name in which it would load to
 memory. So the gcc would have a chance to do that.
    The scenario is that: I got two .so file from other project. Not considering how it is created, as the user of these
 .so files, I want make sure there would be no confilict that would affect .so's behavior otherwise there would be
 hidden errors very hard to find. If there is same name in one namespace, report it.
    Checked about the visibilty feature, I think it is a controlling method  about what is exportd when .so was
 created but not a checking method when .so was linked.  I have little knowledge about gcc internal, could u give
more information about the " linker version scripts."? I am also wondering if there is a simple way to tell gcc check
 for the name conflict when it link .so files.

Best Regards
 
                                                                                                                                     Wayne Xia
2011-11-08
-----------------------------------------------------------------------------------------
发件人:  Ian Lance Taylor <iant@xxxxxxxxxx>
发送时间:  2011-11-07 23:33
主   题:  Re: How to make gcc give a check about symbol conflicts in shared libraries it links?
收件人:  "xiaxia347work"<xiaxia347work@xxxxxxx>
抄   送:  "gcc-help"<gcc-help@xxxxxxxxxxx>




"xiaxia347work"<xiaxia347work@xxxxxxx> writes:

>      I got a tricky problem when I link my exe program with 2 shared libraries,
>  the global variable with same name in the  2 .so file may be linked to the same
>  address, resulting problem that is hard to find.  

This is not a gcc issue.

You didn't mention which OS you are using.  I will assume it is
GNU/Linux.  On GNU/Linux, or any other ELF based system, there is a
single global namespace of global variables and functions.  When two
shared libraries use the same global variable name, they are referring
to the same variable.  This is a feature.

If you want something different to happen, look into symbol visibility
and linker version scripts.

Ian




[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