How to wrap a system call (libc function) in Linux demonstrates LD_PRELOAD and ld --wrap techniques.
Generic Library Interception for Improved Performance Measurement and Insight describes creation of wrappers for arbitrary C/C++ libraries in Score-P. See the library_wrapper_generator source code, which uses Clang under the hood.