tags:

views:

42

answers:

1

Hi,

I have an ELF shared object, and i want to modify it so that calls to the system function memcpy are actually routed through to a custom version of memcpy.

Ive been researching and i have read about PLT Redirection and ELF Infection, but im still not sure how i can accomplish my goal

Can anyone give me some hint and tips, or elaborate on the PLT Redirection and ELF Infection

Regards

Paul

A: 

Have you tried the -wrap option to ld when you link your executable? It should redirect the symbol so that all calls to the original function, including those inside libraries, will go to your replacement.

See this example.

[Edit: The above commenter is correct in pointing out that if the library inlined calls to memcpy, you have no recourse short of rebuilding the library.]