llvm_mode/alloc-preload.so.c
static void __attribute__((constructor)) preload_init(void)
{
    // Put calloc first
    real_calloc = dlsym(RTLD_NEXT, "calloc");
    real_malloc = dlsym(RTLD_NEXT, "malloc");
    real_free = dlsym(RTLD_NEXT, "free");
    real_reallocarray = dlsym(RTLD_NEXT, "reallocarray");
    real_realloc = dlsym(RTLD_NEXT, "realloc");
    if (!real_malloc || !real_free || /*!real_calloc ||*/ !real_reallocarray || !real_realloc) {
        fprintf(stderr, "Error in `dlsym`: %s\n", dlerror());
        fflush(stderr);
    }
}
// Use constructor to get addresses immediately
Use constructor to get addresses immediately
Use constructor to get addresses immediately
static void __attribute__((constructor)) preload_init(void)
{
    real_calloc = dlsym(RTLD_NEXT, "calloc");
    real_malloc = dlsym(RTLD_NEXT, "malloc");
    real_free = dlsym(RTLD_NEXT, "free");
    real_reallocarray = dlsym(RTLD_NEXT, "reallocarray");
    real_realloc = dlsym(RTLD_NEXT, "realloc");
    if (!real_malloc || !real_free ||  !real_reallocarray || !real_realloc) {
        fprintf(stderr, "Error in `dlsym`: %s\n", dlerror());
        fflush(stderr);
    }
}
static void __attribute__ ( ( constructor ) ) preload_init ( void ) { real_calloc = dlsym ( RTLD_NEXT , " " ) ; real_malloc = dlsym ( RTLD_NEXT , " " ) ; real_free = dlsym ( RTLD_NEXT , " " ) ; real_reallocarray = dlsym ( RTLD_NEXT , " " ) ; real_realloc = dlsym ( RTLD_NEXT , " " ) ; if ( ! real_malloc || ! real_free || ! real_reallocarray || ! real_realloc ) { fprintf ( stderr , " \n " , dlerror ( ) ) ; fflush ( stderr ) ; } }
Use constructor to get addresses immediately
Use constructor to get addresses immediately
// Put calloc first /*!real_calloc ||*/