We have an executable on Linux which is linked to some third party
library. When our executable gets loaded , we got symbol conflicts for
the third party shared library.
To resolve the symbol conflict we tried to build our executable with
'--version-script' to restrict the symbols to local scope , however we
found that symbols were still getting exported to global symbol table.
After looking at some mailing list we found that the --version-script
option works only with Shared library and not with executable on Linux
platform.
We tried another linker flag 'retain-symbol-file’ which is applicable
to even executable s that prevents symbols being added to global
symbol table. With this option, we could see that only listed symbols
in the file were shown in the ‘nm’ output but still we see symbol
conflict when executable gets loaded.
Can anyone please suggest some way we can restrict exporting of our
symbols to global symbol table?
Thanks in advance
Anirudh
[...]
> Can anyone please suggest some way we can restrict exporting of our
> symbols to global symbol table?
If you are using gcc: You could use the visibility #pragma and/ or
suitable visibility __attributes__. The gcc documentation has details
regarding the usage. For C, in the 'C Extensions' section (variable
attributes, function attributes and pragmas).
Regards
Shankar Easwaran