title: How Linux decides what `malloc` to use?
body: <p>I know how to replace <code>malloc</code> with <code>LD_PRELOAD</code>; library that preloaded gets priority, so if we preload <code>jemalloc</code>, executable gets its <code>malloc</code> version.
  However, when we build application with <code>-ljemalloc</code>, we also link it against <code>glibc</code>. How Linux knows that it has to use <code>jemalloc</code> <code>malloc</code> and not <code>glibc</code> one? What if I will link both <code>jemalloc</code> and <code>tcmalloc</code>, we'll have 3 <code>malloc</code> now, what and why Linux (or may be the linker, I am not sure) will select?</p>