This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: about libc function interfaces and ld --wrap
- From: Daniel Jacobowitz <drow at false dot org>
- To: sean yang <seanatpurdue at hotmail dot com>
- Cc: binutils at sourceware dot org, drepper at redhat dot com, nickc at redhat dot com
- Date: Fri, 3 Mar 2006 17:34:19 -0500
- Subject: Re: about libc function interfaces and ld --wrap
- References: <433D1B55.2040508@redhat.com> <BAY105-F10A3B5FBBAA7616AB8D7FDC0EA0@phx.gbl>
On Fri, Mar 03, 2006 at 10:24:48PM +0000, sean yang wrote:
> Several question to ask about libc and linker:
>
> (1) I would ask general glibc design question: whether an exported function
> in glibc can be called by another function internally?
> For example (--which is a faked example),
> malloc is an exported function;
> foo(this is a faked name example) is another exported function;
> ** is it possible that foo( ) calls malloc( ) internally?
Yes.
> (2) If the answer to above question is yes, then the following that
> question is: if I have printf wrapped by my own layer (by "ld --wrap
> printf"), will _wrap_malloc() change the internal call's behavior?
>
> void *
> __wrap_ malloc(int c)
> {
> printf ("Coming here\n", c);
> return __real_malloc (c);
> }
Not necessarily.
> (3) If there a convenient way to wrap multi function, e.g., malloc, printf,
> getc...., with same "added functionality" (say just print "coming here"). I
> mean an better way than create each wrapper seperately?
Nope.
--
Daniel Jacobowitz
CodeSourcery