From owner-freebsd-hackers Tue Nov 17 13:29:59 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id NAA18130 for freebsd-hackers-outgoing; Tue, 17 Nov 1998 13:29:59 -0800 (PST) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from detlev.UUCP (50.camalott.com [208.203.140.50]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id NAA18111 for ; Tue, 17 Nov 1998 13:29:51 -0800 (PST) (envelope-from joelh@gnu.org) Received: (from joelh@localhost) by detlev.UUCP (8.9.1/8.9.1) id PAA04702; Tue, 17 Nov 1998 15:29:09 -0600 (CST) (envelope-from joelh) To: Nate Williams Cc: Thomas David Rivers , hackers@FreeBSD.ORG Subject: Re: Wrapping a function References: <199811170517.WAA22627@mt.sri.com> <199811171348.IAA11670@lakes.dignus.com> <199811171638.JAA24053@mt.sri.com> From: Joel Ray Holveck Date: 17 Nov 1998 15:29:06 -0600 In-Reply-To: Nate Williams's message of "Tue, 17 Nov 1998 09:38:37 -0700" Message-ID: <86lnlaypnh.fsf@detlev.UUCP> Lines: 22 X-Mailer: Gnus v5.5/Emacs 20.3 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG >>> Does anyone have an easy way of 'wrapping' an already existing library >>> function so that any programs linked against your .o will call your >>> function, but so your function can call the 'real' library function? >> The standard trick would be to pre-link the malloc code from the library; >> renaming the malloc entry there - to say, MALLOC. (ld -r is how you >> prelink.) > Unfortunately, the symbol exists in a shlib, so it must use the same > symbol name as the library since sometimes the shlib exists, and other > times it doesn't. :( I don't know much about ELF, but what about instead of renaming malloc on the prelink, duplicating it in the table as malloc and nate_old_malloc, and making malloc weak? Would this be feasable? Happy hacking, joelh -- Joel Ray Holveck - joelh@gnu.org Fourth law of programming: Anything that can go wrong wi sendmail: segmentation violation - core dumped To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message