Always set -ldl for linking.
Ask GCC not to optimize the lib
Add traces for every function

Quit using system malloc & free. The reason behind is that dlsym isn't thread-safe and thus can deadlock.
Move to mmap instead, which will offer a few more features