[Top][All Lists]

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

Re: how to hook into shared libraries (by chaining)

From: Ralf Wildenhues
Subject: Re: how to hook into shared libraries (by chaining)
Date: Wed, 14 Feb 2007 00:07:32 +0100
User-agent: Mutt/1.5.13 (2006-08-11)

* Christian Parpart wrote on Tue, Feb 13, 2007 at 04:55:00PM CET:
> On Tuesday 13 February 2007 13:33:58 Ralf Wildenhues wrote:
> >
> > The question is how portable you want to be.

> Only gentoo would be really self-seeking and result into a quite a
> little user base. But when it comes to the "only" point, I'd be happy
> with GNU/Linux and/or ELF systems only.

Good.  What about the last three questions?

> > Can we assume the libGL and libX11 all come from

(AFAIK they do not use -Bsymbolic, which could be a problem for you.)

> > Is using a wrapper shell script acceptable for you?

If yes: on GNU/Linux and Solaris just put a LD_PRELOAD in the script
which loads your library that overwrites their symbols.  The library
can have an arbitrary name and soname.  If you need to get at the
original symbol from inside your library, then dlopen() the original
library and dlsym(... RTLD_NEXT).

Hmm.  You don't even need a wrapper script for this.  Just

once put in the environment.  Of course that will cause quite some
overhead for all the non-game processes your user starts.  For less
overhead, you could ask the user to adjust PATH to put a directory
created by your program first, that then has a wrapper script as above
for each interesting program.  (You could even symlink all those.)

The above will not work for setuid binaries.

If you want to rather go the way of munging library sonames as you
hinted at earlier, then that's probably also possible, but be warned
that library naming/versioning differ quite a bit among ELF systems;
also runtime linkers other than GNU or Solaris won't load in indirect
dependency libs (in general).

> > Is patching a binary (a la objcopy) acceptable for you?
> I don't wanna blame systems like AIX to use .a instead of .so as
> shared object extensions (iirc),

That isn't the problem here.  AFAIR, AIX without runtimelinking
remembers at link time in which library some symbol was found and
uses that information at run time.  A bit like -Bsymbolic but
across libraries.

> but GNU/Linux is what most desktop
> end-users (/gamers) are using below the roof of UNIX, so better stick
> with this one.



reply via email to

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