469,903 Members | 2,122 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,903 developers. It's quick & easy.

Strange linking behavior when overriding global new and malloc

I'm doing development on an embedded system using a GCC 2.96 MIPS cross
compiler and a minimal C standard library replacement. The system loads
at startup a base executable. The base executable then loads one DLL
after another during execution to reduce memory usage. The base
executable statically links in a library which overrides the default
malloc (and related functions) and the built-in operator new/delete. That
works fine and as expected.

The DLLs, on the other hand, do not statically link in this library (or
the C standard library) as they can call code in the base executable which
already defines these functions. The DLL, unlike I had expected, does not
call my new function, but the built-in new function in turn *does* call my
malloc function. The solution was to statically link the library defining
new/malloc/etc into both the base executable and all of the DLLs. These
functions are one-line wrappers around our memory manager so the space
wasted is minimal.

Could someone please explain why I'm seeing this behavior? I don't
understand why the DLLs wouldn't call my new function but it would call my
malloc function. I would have guessed they would behave the same.

Thanks a bunch, Ryan Mack. Please CC me at:
[first letter of first name][last name]@[last name]man.net
Jul 22 '05 #1
0 974

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

13 posts views Thread by Neil Zanella | last post: by
1 post views Thread by john smith | last post: by
6 posts views Thread by Edd Dawson | last post: by
16 posts views Thread by Ronny Mandal | last post: by
9 posts views Thread by groleo | last post: by
12 posts views Thread by gooch | last post: by
9 posts views Thread by Me | last post: by
2 posts views Thread by Andy Carlson | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.