c - preventing "ld -wrap " circular references -


I am using GNU Lead's "-WAP" option to block calls in applications, but a scenario Where the code implementing code is indirectly calling the wrapped function to create a spherical reference.

Example

The goal is to call the reader, which is in the program Foo. This code can be compiled / replayed again, but has not been modified.

Program Foo

  main () {... read (fd, buf, size);  

Cover
   

Here the wrapper program will block the call to read libc when using "frame".

External int __real_read (...); Int __wrap_read (...) {bar (); __real_read (...); }

However, the library bar called wrapper requires the use of the library's reading () function without the cover (thus due to circular dependence) without using .

Use the library __real_read () to change the time of all wrapped routines in the Library Bar (zero) {read (fd, buf, size)}

There is no option because the level of induction in the additional calls of extra libraries in the Library Bar is irregular.

Avoid the Flag

One way to solve this is to use a per-thread flag to prevent reading the library bar to re-enroll the library bar, although I I would not like to use the solution, I am open to suggestions as to how it can be implemented with the minimum code change in the cover and bar libraries.

Ideal Solution

? ?? This is the reason I am asking questions :)

thanks ... -n

As Nathan says, it is possible to wrap only read () calls for specific object files. Not sure about Linux, but imported functions in a DLL will not affect the imported function in other modules in windows that are wrapped, so putting the separate DLL in the bar with the opening will solve the problem.


Comments