libgmalloc如何与两个级别的名称空间一起使用? [英] How libgmalloc work with two level namespaces?
问题描述
我想编写自己的具有调试目的的malloc/free函数,文档说我必须同时使用DYLD_FORCE_FLAT_NAMESPACE和DYLD_INSERT_LIBRARIES.但同时libgmalloc文章明确指出:
I want to write my own malloc/free functions with debug purposes, documentation says I have to use DYLD_FORCE_FLAT_NAMESPACE together with DYLD_INSERT_LIBRARIES. But at the same time libgmalloc article clearly states:
libgmalloc is available in /usr/lib/libgmalloc.dylib. To use it, set this environment variable:
set DYLD_INSERT_LIBRARIES to /usr/lib/libgmalloc.dylib
Note: it is no longer necessary to set DYLD_FORCE_FLAT_NAMESPACE.
问题是:如何删除DYLD_FORCE_FLAT_NAMESPACE中的必要性?如果我不强制命名空间平坦,则不使用我自己的库中的malloc.
The question is: how to remove the necessity in DYLD_FORCE_FLAT_NAMESPACE ? malloc from my own library is not used if I don't force the namespace flatness.
推荐答案
您需要使用dyld插入.这包括在动态库的__DATA
段中生成一个特殊的__interpose
部分,其中包含成对的替换/替换函数地址. 私有dyld-interposed.h dyld源文件中的标头包含一个方便使用的宏,以及示例用法.
You need to use dyld interposing. This consists of generating a special __interpose
section in the __DATA
segment of your dynamic library containing pairs of replacement / replaced function addresses. The private dyld-interposing.h header from the dyld source contains a handy macro to help with this, along with an example usage.
这篇关于libgmalloc如何与两个级别的名称空间一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!