Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 03 Aug 2000 23:49:51 +0200
From:      Bjoern Fischer <bfischer@Techfak.Uni-Bielefeld.DE>
To:        Karl Pielorz <kpielorz@tdx.co.uk>
Cc:        hackers@FreeBSD.ORG
Subject:   Re: LD_PRELOAD odities / Documentation?
Message-ID:  <20000803234951.B267@frolic.no-support.loc>
In-Reply-To: <39894897.79E14398@tdx.co.uk>; from kpielorz@tdx.co.uk on Thu, Aug 03, 2000 at 11:25:27AM %2B0100
References:  <39894897.79E14398@tdx.co.uk>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Aug 03, 2000 at 11:25:27AM +0100, Karl Pielorz wrote:
> The code is a 'wrapper' / 'shim' that's meant to be LD_PRELOAD'ed before an
> executable... I've gotten everything to compile, and the LD_PRELOAD works, but
> a lot of syscall's from the wrapper library fail either with bizare messages
> such as "malloc(): recursive call", or just die horibly (segmentation faults,
> and all sorts).

To wrap libc functions you have to use dlsym() with the special
handle RTLD_NEXT to get the next incarnation of your function.
E.g. you want to wrap fchmod(), so write your own fchmod() and
after you `corrected' the params you may have to call the `real'
fchmod(). You will get this with dlsym(RTLD_NEXT, "fchmod").

  Bjoern

-- 
-----BEGIN GEEK CODE BLOCK-----
GCS d--(+) s++: a- C+++(-) UB++++OSI++++$ P+++(-) L---(++) !E W- N+ o>+
K- !w !O !M !V  PS++  PE-  PGP++  t+++  !5 X++ tv- b+++ D++ G e+ h-- y+ 
------END GEEK CODE BLOCK------


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000803234951.B267>