Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Strange linking behavior when overriding global new and malloc

Reply
Thread Tools

Strange linking behavior when overriding global new and malloc

 
 
Ryan Mack
Guest
Posts: n/a
 
      05-24-2004
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
FWSM/PIX and Dynamic PAT using global IP range vs. global interface vs. global IP Hoffa Cisco 1 10-25-2006 06:50 PM
FWSM/PIX and Dynamic PAT using global IP range vs. global interface vs. global IP Hoffa Cisco 0 10-25-2006 01:04 PM
overriding global new and delete + STL shoosh C++ 6 01-29-2005 09:41 AM
overriding global new john smith C++ 1 01-28-2005 02:58 AM
overriding malloc and free john smith C++ 4 01-19-2005 12:35 PM



Advertisments