shadow/shadow — Issue #37: Use syscall() instead of dlsym() for system functions
Author: robgjansen
Created: 2012-01-21 21:17:25+00:00
State: open
Labels: feature

When we preload functions, we use dlsym() to lookup our intercepted function, and the system functions if we are not wanting to intercept it.

This could be done a little differently to make things smoother:

1. The preload lib calls into shadow, e.g. shadow_getInterceptedFunctions(), to obtain a structure of pointers to all of our intercepted functions. This would require preload to do a lookup for "shadow_getInterceptedFunctions", but once it does that it never calls dlsym again. It can save the pointer and use this structure to make future calls.

2. For cases where we want to call the system version of a function, we can use syscall(), using the IDs from /usr/include/bits/syscall.h. This way we avoid storing pointers to everything.

This new approach should drastically simplify the process of finding the correct function to call, and should make the preload library cleaner and could be made to work for multiple threads.