Date: 17 Nov 1998 15:29:06 -0600 From: Joel Ray Holveck <joelh@gnu.org> To: Nate Williams <nate@mt.sri.com> Cc: Thomas David Rivers <rivers@dignus.com>, hackers@FreeBSD.ORG Subject: Re: Wrapping a function Message-ID: <86lnlaypnh.fsf@detlev.UUCP> In-Reply-To: Nate Williams's message of "Tue, 17 Nov 1998 09:38:37 -0700" References: <199811170517.WAA22627@mt.sri.com> <199811171348.IAA11670@lakes.dignus.com> <199811171638.JAA24053@mt.sri.com>
next in thread | previous in thread | raw e-mail | index | archive | help
>>> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?86lnlaypnh.fsf>