Ali Bahrami wrote: > I can't think of any facility in the Solaris ld that > can do that as described. > > The closest thing would be to preload a sharable object > that provided the wrapper functions, which then use dlsym > at runtime to find and call the real function. > > I assume that the obvious idea of doing this at compile time > with macros has been rejected? > > #define malloc __wrap_malloc
The problem with doing this at compile time is then you have to compile two versions of the objects - one for production, one for testing. Xorg is using this to call the same .o's and *.so's used in production from the test harness, just wrapping input/output functions to control the input and then validate the output is as expected - this is described a bit more, with links to some examples, at: http://lists.x.org/archives/xorg-devel/2009-June/001099.html You could imagine doing something similar to test functions in any shared library - for instance, a test for the new asprintf function added recently to libc might wrap malloc to make sure it's mallocing the expected size before calling the wrapped malloc to do the actual allocation, or may return 0 to make sure it handles allocation failure correctly. I'll file an RFE for consideration for this in the Solaris ld, since I think most of the runtime side is there in the existing interposer functionality, would just need the linker to do the grunt work of defining the interposers for you. -- -Alan Coopersmith- alan.coopersmith at sun.com Sun Microsystems, Inc. - X Window System Engineering