title: Question about overriding C standard library functions and how to link everything together
body: <p>I made my own implementation of _init , malloc , free ( and others ). </p>
  
  <p>Inside these functions I use the dlfcn.h (dlopen , dlsym etc) library to call the actual standard versions. I put then in a single file and compile them as a shared library ( memory.so ). When I wish to run an executable and make it call my versions of these functions I simply set LD_PRELOAD=memory.so .</p>
  
  <p>The problem is that I have a number of other modules which memory.c depends on. These include  a file containing functions to scan elf files ( symbols.c ) and my own implementation of a hash table ( hashtable.c ) which I use to keep track of memory leaks among others. </p>
  
  <p>My question is if there is a way to separately compile hashtable.c &amp; symbols.c so any malloc references are resolved with the standard library and not with the ones included on memory.c. I could of course use the dlfcn.h libraries on everything that memory.c depends on but I would prefer it if there was a way to avoid that. </p>
  
  <p>I still haven't completely figured out how linking works so any help would be appreciated. </p>
  
  <p>Thank you</p>