This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: "ld --wrapper" but without changing legacy executable, possible?
- From: "sean yang" <seanatpurdue at hotmail dot com>
- To: paul at codesourcery dot com, binutils at sourceware dot org
- Date: Tue, 21 Mar 2006 02:19:12 +0000
- Subject: Re: "ld --wrapper" but without changing legacy executable, possible?
- Bcc:
I know we can do a if(!=NULL) to get it around.
I guess there could be some clever way, say analogy to the .PLT entry
filling.
From: Paul Brook <paul@codesourcery.com>
To: binutils@sourceware.org
CC: "sean yang" <seanatpurdue@hotmail.com>
Subject: Re: "ld --wrapper" but without changing legacy executable,
possible?
Date: Tue, 21 Mar 2006 01:23:23 +0000
> //runtimewrapper.c
> 1 #define _GNU_SOURCE
> 2 #include <stdio.h>
> 3 #include <dlfcn.h>
> 4 void* malloc(int size) {
> 5 printf("wrapped malloc\n");
> 6 void* (*real_malloc)(const char*, const char*) =
> 7 dlsym(RTLD_NEXT, "malloc");
> 8 return real_malloc(size);
> 9 }
>...
> But the problem of above approach is that " void* (*real_malloc)(const
> char*, const char*) = dlsym(RTLD_NEXT, "malloc");" is called each time
the
> application want to use malloc(), which is the major source of overhead.
Unless I'm missing something the answer is "Don't do that then". ie. only
call
dlsym the first time the wrapper is run.
Paul
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/