Question

I'm working on a Mac launcher for a trace library - the tracing works by adding the library to DYLD_INSERT_LIBRARIES (the Mac equivalent of LD_PRELOAD). The DYLD_INSERT_LIBRARIES variable is then propagated by the trace library as further processes are spawned.

The trouble is that I need the 32-bit version of the trace library to be used for 32-bit tracee processes and the 64-bit version for 64-bit tracee processes. In the Linux launcher I have, this is achieved by using ${LIB} in LD_PRELOAD - the dynamic loader (ld.so) then replaces this with "the right thing" when loading a process.

Is there an equivalent of ld.so's ${LIB} variable for dyld on Mac? I couldn't immediately see one when I looked through the man page (https://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man1/dyld.1.html), but I may just be reading it wrong. If not, is there another way of achieving the same effect please?

Was it helpful?

Solution

I think what you want is to compile your inserted library as a fat binary (e.g., multiple architectures in the same binary). This should allow a single value of DYLD_INSERT_LIBRARIES to work for subprocesses of various architectures.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top