R
Ryan Mack
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
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