linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* malloc interposition how?
@ 2008-07-17  3:55 bkerin
  2008-07-17  7:39 ` Leslie P. Polzer
  0 siblings, 1 reply; 2+ messages in thread
From: bkerin @ 2008-07-17  3:55 UTC (permalink / raw)
  To: linux-c-programming


I'm trying to do these things simultaneously:

use glib
use gc (Hans-Boehm)
use my own library of random code

I dont want to have to do manual garbage collection at least in the
prototype stage.

However, I haven't found a way to link the above together that works.

I use the set_vtable function in glib to hopefully make it use the GC_malloc
etc. from gc

I include fcnts malloc/free/realloc in my library and the compiler/linker
doesn't complain
(presumably libc contains some special goop to not complain about these
getting redefined
in client code).  My malloc etc. of course just call GC_* fctns.

I believe I have all the right -I -L -Wl,-rpath etc. crud.

When I look at bins and my .so file with ldd everything appears to look for
the correct libraries.

When I use nm on my .so I see symbols like malloc supposedly in the text
secion (marked with T).

When I step with the debugger and a breakpoint in malloc (or realloc etc.) I
always end up in the malloc
in my library, not the system malloc.

And yet, the program always seg faults eventually in a GC_malloc.

Any ideas what I'm missing, or is the whole approach somehow fatally flawed?

I've also tried using --wrap linker option, but it seemed to only map
function defined in the source files being linked and
didn't affect the use of malloc etc. by depended-on libraries (I ultimately
need this to work for gsl (GNU scientific library as well not only glib
which provides the set_vtable functionality).

Thanks,
Britton
-- 
View this message in context: http://www.nabble.com/malloc-interposition-how--tp18501119p18501119.html
Sent from the linux-c-programming mailing list archive at Nabble.com.


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: malloc interposition how?
  2008-07-17  3:55 malloc interposition how? bkerin
@ 2008-07-17  7:39 ` Leslie P. Polzer
  0 siblings, 0 replies; 2+ messages in thread
From: Leslie P. Polzer @ 2008-07-17  7:39 UTC (permalink / raw)
  To: bkerin; +Cc: linux-c-programming


Check the -M argument to ld to see where your malloc comes from
(well, presumably from libc, but let's be sure).

Supposedly your set_vtable stuff isn't working at all,
and you need to put the gc libs higher in the linking
order (before libc).

  Leslie


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-07-17  7:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-17  3:55 malloc interposition how? bkerin
2008-07-17  7:39 ` Leslie P. Polzer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).