[Top][All Lists]

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

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

From: Mark Kettenis
Subject: Re: Help with weak symbols needed (gcc question).
Date: Mon, 23 Jul 2001 10:40:27 +0200

   From: Igor Khavkine <i_khavki@alcor.concordia.ca>
   Date: Sun, 22 Jul 2001 23:19:19 -0400

   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?
   > As far as I understand it, (most) glibc functions are declared to be
   > "weak symbols", so that they can be overridden by simply redefining
   > them in user-code. gcc would be so smart as to reference the
   > user-defined code instead of the weak symbol.

   I'm not sure there is an automatic way of doing this. But practical
   experience suggests that most of these "weak symbols" are declared
   in the following way:
   weak_alias (__foo, foo)
   So all you need to do is call __foo() from your user defined foo()
   function and that should work (in most cases). I think that's the
   simplest solution you can come up with.

That's not officially supported.  The __-prepended symbols are
implementation details, and subject to removal or change between glibc
releases.  The official way is using RTLD_NEXT as Marcus described.

reply via email to

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