DYLD_LIBRARY_PATH & DYLD_INSERT_LIBRARIES not working

后端 未结 4 1707
一整个雨季
一整个雨季 2020-12-14 10:45

I create a .dylib file and compile it:

#define _GNU_SOURCE
#include 
#include 

static void* (*real_malloc)(size_t);

void *mal         


        
4条回答
  •  一个人的身影
    2020-12-14 11:21

    If you can recompile the executable being hooked, then I think a simpler solution is to recompile the executable with -force_flat_namespace:

    ➜  clang slow_leak.c -force_flat_namespace -o slow_leak
    ➜  DYLD_INSERT_LIBRARIES=malloc_hook.dylib ./slow_leak
    leaking
    in hooked malloc
    

    More info. This is on OSX 10.12.2 MacOS Sierra.

    A comment on HN (2 years later) mentioned DYLD_FORCE_FLAT_NAMESPACE=1 can help in cases where it's not feasible to recompile. I haven't tried it yet, so YMMV.

提交回复
热议问题