[Top][All Lists]

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

Re: Help with weak symbols needed (gcc question).

From: Marcus Brinkmann
Subject: Re: Help with weak symbols needed (gcc question).
Date: Mon, 23 Jul 2001 04:34:40 +0200
User-agent: Mutt/1.3.18i

On Mon, Jul 23, 2001 at 04:07:57AM +0200, Farid Hajji wrote:
> What is the "official" way to wrap library (e.g. glibc) functions with
> user-defined code, without fiddling in the glibc sources themselves?

Look into fakeroot, libtricks or even installwatch (all Debian packages).
They seem to use RTLD_NEXT/dlopen and dlsym to get the real symbol, and wrap
them in true_creat/next_creat or whatever.

However, there are some tricks involved.  From a quick glance at the
fakeroot source, you should not dlopen the C library directly, but just use
RTLD_NEXT (so the linker will do the right thing for you).  Makes sense, of
course, as we don't know what other libraries are preloaded or in the path
(optimized versions, or whatever).  For this to work with glibc, you need
to define _GNU_SOURCE at the beginning of the library...

As an exercise and test if you understood it correctly, port fakeroot to the
Hurd please ;)


`Rhubarb is no Egyptian god.' Debian http://www.debian.org brinkmd@debian.org
Marcus Brinkmann              GNU    http://www.gnu.org    marcus@gnu.org

reply via email to

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