Limiting exposed symbols via version scripts
#1
Hi all,

Just spent almost five hours trying to understand why MIDI playing does not work with x86 OpenSuSE 11. I debugged timidity-i486-linux.so and found that while its DLL_Init() gets called and successfully returned error, its Timidity_Init() was not called. After long investigation I found that my SDL_mixer library has also Timidity stuff compiled in. Then when the timidity-i486-linux.so shared library was loaded, its Timidity_Init() and other symbols were somehow resolved by pointing out to the functions in the SDL_mixer, which do not support virtual file I/O and therefore the file cannot be loaded.

To resolve this problem the following version script was written (for those who do not know a version script is a file which is used by gcc during linking and controls symbol visibility):

Code:
# Version script for use with GNU linkers
XBMC
{
    global:
        DLL_Init;
        DLL_LoadMID;
        DLL_FreeMID;
        DLL_FillBuffer;
        DLL_GetLength;
        DLL_Seek;

    local:
        *;
};

And enabling this script at the link phase in Makefile.in:
Code:
$(LIB): $(OBJS) exports.def
    g++ -shared -o $@ *.o `cat ../../DllLoader/exports/wrapper.def` ../../DllLoader/exports/wrapper.o -Wl,--version-script=exports.def

This fixed this problem. Besides removing potential symbol conflicts, this solution also has an advantage of speeding up loading a shared library, as there is less visible symbols to resolve.

Do you think it makes sense to modify other plugins as well?
Reply

Logout Mark Read Team Forum Stats Members Help
Limiting exposed symbols via version scripts0