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

Tue Nov 8 02:22:00 GMT 2011

    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
发件人:  Ian Lance Taylor <>
发送时间:  2011-11-07 23:33
主   题:  Re: How to make gcc give a check about symbol conflicts in shared libraries it links?
收件人:  "xiaxia347work"<>
抄   送:  "gcc-help"<>

"xiaxia347work"<> 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.


More information about the Gcc-help mailing list