I'm having a heck of a time getting a program working that uses Lua (version 5.2) if I also have to link against the RPM libraries - specifically librpmio.so. This is part of a large application with several shared libraries that also use Lua.
The underlying problem is that the version of librpmio.so we're using (4.4.X) has a Lua interpreter embedded in it, and it doesn't hide the global symbols contained in the Lua code. The rpmio version of Lua is older (5.0.2) than the Lua we're using (5.2.x), so they're not exactly interchangeable.
So far I haven't been able to get both our own Lua code and the RPM API calls to work. Lua APIs like lua_pushlstring() will bind against whichever of liblua.so or librpmio.so appears first in the chain of loaded modules. If I specify -llua earlier on the linker command line then all of our code works fine, but calls to RPM APIs eventually crash. If -lrpmio is earlier than our code will crash eventually because some Lua calls end up using librpmio's copy of Lua.
I tried versioning the symbols in the liblua.so that we build using a version script like this:
LUA_5.2 {
global:
lua_*;
luaL_*;
local: *;
};
That wasn't enough however since librpmio.so uses unversioned symbols, and the version script above creates a LUA_5.2 version of the symbols plus a "default" version. The run-time binding seems to favour the unversioned symbol from liblua.so over librpmio.so even though the former is earlier in the chain:
19075: symbol=lua_pushlstring; lookup in file=output/Linux64/bin/myapp [0]
19075: symbol=lua_pushlstring; lookup in file=/home/output/Linux64/lib/lib1.so [0]
19075: symbol=lua_pushlstring; lookup in file=/home/output/Linux64/lib/lib2.so [0]
19075: symbol=lua_pushlstring; lookup in file=/home/output/Linux64/lib/lib3.so [0]
19075: symbol=lua_pushlstring; lookup in file=/home/lib/libwx_base-2.8.so.0 [0]
19075: symbol=lua_pushlstring; lookup in file=/home/lib/libsqlite.so [0]
19075: symbol=lua_pushlstring; lookup in file=/home/lib/libssl.so.0.9.8 [0]
19075: symbol=lua_pushlstring; lookup in file=/home/lib/libcrypto.so.0.9.8 [0]
19075: symbol=lua_pushlstring; lookup in file=/lib64/libacl.so.1 [0]
19075: symbol=lua_pushlstring; lookup in file=/usr/lib64/librpm-4.4.so [0]
19075: symbol=lua_pushlstring; lookup in file=/home/lib/liblua.so [0]
19075: binding file /usr/lib64/librpmio-4.4.so [0] to /home/lib/liblua.so [0]: normal symbol `lua_pushlstring'
Note the last line - it's resolving a binding for lua_pushlstring within librpmio against my liblua.
I could solve this by setting the -Bsymbolic flag on librpmio.so, but that's a system library we don't control, and who knows what other problems that might cause. I think I might be able to get around the problem if I could eliminate the creation of the default version of each Lua symbol in my liblua.so, but I haven't been able to figure out how to do that from a version script. The GNU version script docs only show how to do that via __asm__ directives.
Does anyone have any ideas other than creating a file containing a bunch of lines like the following and linking it with my build of Lua?
__asm__(".symver lua_pushlstring,lua_pushlstring@LUA_5.2");