[ELF] Support --wrap option
Audit RequiredrL228906

Description

[ELF] Support --wrap option

Use a wrapper function for symbol. Any undefined reference to symbol will be
resolved to "wrap_symbol". Any undefined reference to "real_symbol" will be
resolved to symbol.

This can be used to provide a wrapper for a system function. The wrapper
function should be called "wrap_symbol". If it wishes to call the system
function, it should call "
real_symbol".

Here is a trivial example:

void * __wrap_malloc (size_t c)
{

printf ("malloc called with %zu\n", c);
return __real_malloc (c);

}

If you link other code with this file using --wrap malloc, then all calls
to "malloc" will call the function "wrap_malloc" instead. The call to
"
real_malloc" in "__wrap_malloc" will call the real "malloc" function.

Details

Auditors
Bigcheese
Committed
shankareFeb 11 2015, 9:02 PM
Parents
rL228905: [ELF] Add LinkingContext to the ELFReader.
Branches
Unknown
Tags
Unknown