(If you like articles title longer that the article itself, you’re on the right place.)
As the subject of the article, here’s a brief piece of code to define a library with a function whose name is also in libc. In the example we want to call the libc time() function inside our time() function.
adsense
You can note the use of dlsym() function with the use of the flag RTDL_NEXT, that (from the man page) will find the next occurrence of a function in the search order after the current library. This allows one to provide a wrapper around a function in another shared library.
The code on my github.com.
Please note that you can find the gcc commands inside the branch, file compile.sh.
0 Comments Leave a comment