[quake3] SDL_loadso.h in less than recent SDL?

Ludwig Nussel ludwig.nussel at suse.de
Sat Dec 3 08:30:16 EST 2005


Ryan C. Gordon wrote:
> > Or we just use dlopen instead of that SDL function again. It's bad
> > that SDL adds new symbols without using symbol versioning. It will
> > make binaries crash at runtime on distros with older libs.
> 
> I don't have much pity for people using software that far out of date,
> especially when the upgrade is free. If they can't upgrade SDL because
> the system is too mission-critical to update components, they really
> shouldn't be playing Quake 3 on that box.  :)

For enterprise distros (includes Desktops) three years are no time.
There are no updates for unimportant stuff like SDL. I am surprised
SDL is included at all though. If you want to take Linux as serious
as you do with Windows and MacOS you have to look at distros as a
whole and not at individual packages that may be available in newer
versions elsewhere.

> If you want to use dlopen, use linux_glimp.c, but the point of moving to
> SDL functions is to remove the Unix dependency...SDL_LoadObject() lets
> us use the same code on Mac OS, where dlopen() doesn't exist until
> recently, and eventually Windows, where dlopen() won't _ever_ exist.

Currently:

#if USE_SDL_VIDEO
  libHandle = SDL_LoadObject(fn);
#else
  libHandle = dlopen( fn, Q_RTLD );
#endif

That is not much better than

#if windows
  libHandle = windowsfoo(fn);
#elif mac
  libHandle = macfoo(fn);
#else
  libHandle = dlopen( fn, Q_RTLD );
#endif

> Also, I'm pretty ignorant of symbol versioning, so this is an honest
> question: How does that help in this case? If you need a symbol, it's
> either there or it isn't...even if you could check it at runtime (a
> "weak reference"?), you still have to pretty much give up when crucial
> symbols are missing.

ELF has a feature called lazy binding. With this feature binaries
can start up quickly and symbols from shared libraries are resolved
when they are first accessed. If your program uses symbols that are
not contained in the installed libs you won't notice until execution
actually runs across the symbol. Ie as long as you don't actually
call SDL_LoadObject() Q3 will run fine with older SDL libs. Q3 uses
it pretty early so you will notice quickly, other programs may run
for hours and then suddenly crash. GTK2 for example introduced a new
file selection dialog in 2.4, your your programs runs fine with 2.2
until the user wants to save his document ... ouch.

Symbol versioning basically adds tags to symbols. A summary of all
needed tags are in the binary. Libraries have a list of tags they
support (use objdump -p to see them). Now the linker can quickly (as
#tags << #symbols) compare the lists and refuse start the binary in
the first place. It will no longer crash in the middle of execution.

So using symbol versioning on platforms where it's supported is
really desirable.

cu
Ludwig

-- 
 (o_   Ludwig Nussel
 //\   SUSE LINUX Products GmbH, Development
 V_/_  http://www.suse.de/






More information about the quake3 mailing list