Few days ago, during my spare times, I wrote an article for an ezine named Echo zine. The article describe about how one could intercept a library call toward the usual libc library. For example, instead of calling normal rand() function of glibc, it will end up executing your own defined rand(). The trick is to utilize LD_PRELOAD environment variable so your library has higher priority to be linked into the ELF executable.
Without further ado, here's the link: