I made my own implementation of _init, malloc, free (and others).
Inside these functions, I use the dlfcn.h library (dlopen, dlsym, etc.) to call real standard versions. I put it in a single file and compiled them as a shared library (memory.so). When I want to run the executable and make it call my versions of these functions, I simply set LD_PRELOAD = memory.so.
The problem is that I have a number of other modules that memory.c depends on. These include a file containing functions for scanning elf files (symbol.c) and my own implementation of the hash table (hashtable.c), which I use to track memory leaks among others.
My question is, is there a way to separately compile hashtable.c and symbols.c, so any malloc links are resolved using the standard library, and not those included in .c memory. I could, of course, use the dlfcn.h libraries in everything that depends on memory.c, but I would prefer that there be a way to avoid this.
I still do not quite understand how the links work, so any help would be appreciated.
thanks
source share