automake
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

how to hook into shared libraries (by chaining)


From: Christian Parpart
Subject: how to hook into shared libraries (by chaining)
Date: Tue, 13 Feb 2007 11:59:35 +0100
User-agent: KMail/1.9.6

Hi all,

somewhat unusual, I do understand, but I most obviousely need this.

I want to override some functions located in libGL.so and libX11.so, in order 
to capture movies from (any) OpenGL application.

There are now several ways to achieve this, but none of them seems to be 
userfriendly *and* ideal (system/platform independant).

One way is, to enforce the user to LD_PRELOAD=foo everytime he expects to push 
the `capture` button. This works quite well, but you'd have to hack the 
ut2004 shell script, cedega, and only #devil knows what else.

So, another approach I thought of, was, to reimplement the client GL library. 
But this is not just time consuming, as you've to wrap really really all 
little nasty functions like glVertex{234}{sifd}[v] and friends - and is even 
too much performance overhead, as really every little functions is wrapped 
instead only those you need.

So I found yukon which does seem to have found a way by having a script that 
LD_LIBRARY_PATH's the app you're about to capture a movie from its GL 
context.
However, yukon's build system[1] is far from using autotools nor do I believe, 
that post-patching binaries is the right way to go.

I believe chaining the library you're interested in is great.

        1) clientApp.bin depends on libGL.so.1
        2) libGL.so.1 is a symlink to $PREFIX/libGLcaptury.so
        3) $PREFIX/libGLcaptury.so depends on real libGL.so.1

Unfortunately, I couldn't find anything in ld.so's man-page about such a 
feature, so I thought about replacing step (3) by the following:

        3) $PREFIX/libGLcaptury.so so depends on $PREFIX/libGLsystem.so
        4) $PREFIX/libGLsystem.so is a symlink to /usr/lib/libGL.so

Where $PREFIX in /etc/ld.so.conf is listed above /usr/lib{,32,64} to let our 
(chained) libGL.so being loaded first.

Unfortunately, automake/libtool doesn't have any syntax to express such a 
feature, and I'd just end up (again) in hooking into Makefile.am's 
post install rule:

# -------------------------------------------------------------------
lib_LTLIBRARIES = libGLcaptury.la libGLsystem.la

libGLcaptury_la_SOURCES = libGLcaptury.cpp
libGLcaptury_la_LDFLAGS = -version-info @CAPTURY_VERSION_INFO@
libGLcaptury_la_LIBADD = \
    $(top_builddir)/src/captury/libcaptury.la \
    -ldl libGLsystem.la

libGLsystem_la_SOURCES = #
libGLsystem_la_LDFLAGS = -version-info 1:0:0

SYSGL_libdir = /usr/lib64 # determined by configure

install-exec-local:
    rm $(DESTDIR)/$(SYSGL_libdir)/libGLsystem.{so,a,la}
    ln -s $(SYSGL_libdir)/libGLsystem.so $(DESTDIR)$(libdir)/libGLsystem.so
# -------------------------------------------------------------------

This is a quote form my current Makefile.am. I did a little workaround here to 
get a `virtual` libGLsystem.so I can link against. But I unfortunately (as in 
fact it isn't really `virtual`) have to post-delete the installed files in 
install-exec-local and install the symlink to the system's real libGL.so 
instead.

I'd like to get some feedback from you what/how you do think about, and/or how 
you'd have implemented such a thing.

So... thanks in advance,
Christian Parpart.

[1] svn://dbservice.com/big/svn/yukon/trunk/build.sh

Attachment: pgp_oErTloFVn.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]