Linking to multiple libraries, one of which includes a set of system calls

So this is the scenario I'm looking at:

I have 3 libraries - A, B and C.

  • Library A implements the foo() function and provides it as an API.
  • The foo() function calls the POSIX write() call to write some data.
  • Library B writes the shell to the write() call of glibc using the linker -wrap option.
  • Library C refers to A and B.

Any call to write() that the C make library will be intercepted by the B library shell. But, my question is, if the C library calls foo() , the write() call inside foo () will be intercepted by B?

+6
source share
1 answer

If A is associated with -wrap=write , foo will invoke the shell. If not, it will not.

The same can be said for write calls in C There is no difference between A and C regarding the write call.

+2
source

Source: https://habr.com/ru/post/925954/


All Articles