Nat! bio photo

Nat!

Senior Mull

Twitter Github Twitch

First attempt at writing the MallocTracer

My feeble attempt was cut short by my ineptness to handle the linker. I took the easy way out and asked for help on the darwin developers mailing list. That was maybe a good one hour attempt, that lead nowhere. Here's the letter I wrote, in case any of the few thousand readers that frequent this site might know the answer:


I figured to advance with baby steps into this uncharted territory to write a malloc tracer.

So I want to take the libMallocDebug.a replace the debug_malloc.o file with my code and then link it back together into a dylib.

The first baby step was to simply unar the .a archive into its constituent .o files and then naively try to link them back together into a dylib with:

ld -flat_namespace -dylib -o libTestMalloc.dylib _mallocProtocolUser.o _mallocProtocolServer.o excUser.o excServer.o exceptionCatcher.o debug_malloc.o PortListen.o -F/System/Library/PrivateFrameworks -framework vmutils

as the original dylib appears to be linked like that:

bash-2.05a$ !534
otool -L /usr/lib/libMallocDebug.A.dylib
/usr/lib/libMallocDebug.A.dylib:
        /usr/lib/libMallocDebug.A.dylib (compatibility version 1.0.0, current version 1.0.0)
        /System/Library/PrivateFrameworks/vmutils.framework/Versions/A/vmutils (compatibility version 1.0.0, current version 1.0.0)

unfortunately that didn't work, because the linker complains thusly:

ld: _mallocProtocolUser.o illegal undefined reference for multi module MH_DYLIB output file to symbol: dyld_stub_binding_helper from section (__DATA,__la_symbol_ptr) relocation entry: 0

which already sees me at the end of my wits :( Help!

Ciao
        Nat!

Then I tried to synchronize some directories between Windows and Mac OS X. Checked out Unison for that. It appears to work, but unfortunately it can't seem to handle the UTF-8 filenames very well, as it couldn't deal with the Mac OS X file Ügür Mülüsüs Turkisch für Anfänger.pdf at all. Asked for help on this well on the relevant mailing list. I hope that help is on the way...

Another day of failure and missed chances. :)