From owner-freebsd-hackers Thu Aug 3 14:51:44 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from mail.uni-bielefeld.de (mail2.uni-bielefeld.de [129.70.4.90]) by hub.freebsd.org (Postfix) with ESMTP id 8704437B86A for ; Thu, 3 Aug 2000 14:51:40 -0700 (PDT) (envelope-from bfischer@Techfak.uni-bielefeld.de) Received: from frolic.no-support.loc (ppp36-6.hrz.uni-bielefeld.de [129.70.36.6]) by mail.uni-bielefeld.de (Sun Internet Mail Server sims.4.0.2000.05.17.04.13.p6) with ESMTP id <0FYQ002OTKPZPF@mail.uni-bielefeld.de> for hackers@FreeBSD.ORG; Thu, 3 Aug 2000 23:51:38 +0200 (MET DST) Received: (from bjoern@localhost) by frolic.no-support.loc (8.9.3/8.9.3) id XAA00739; Thu, 03 Aug 2000 23:49:52 +0200 (CEST envelope-from bjoern) Date: Thu, 03 Aug 2000 23:49:51 +0200 From: Bjoern Fischer Subject: Re: LD_PRELOAD odities / Documentation? In-reply-to: <39894897.79E14398@tdx.co.uk>; from kpielorz@tdx.co.uk on Thu, Aug 03, 2000 at 11:25:27AM +0100 To: Karl Pielorz Cc: hackers@FreeBSD.ORG Message-id: <20000803234951.B267@frolic.no-support.loc> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-disposition: inline Content-transfer-encoding: 7BIT User-Agent: Mutt/1.2.4i References: <39894897.79E14398@tdx.co.uk> Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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