Quantcast
Viewing all articles
Browse latest Browse all 22130

Linux gcc wrap option: issue in linked library

Good morning,I have the following situation:

  • I have a library middleware.so that provide a wrapper for a external library boughtLib.so
  • makefile of middleware.so link dynamic library boughtLib.so and cannot be modified
  • I need to write a test case to be sure that middleware.so uses the functions in boughtLib.so (in order to be sure no one replaced the optimized implementation of boughtLib.so with a low performancecustom one).

I approached the issue as follow:

  • in my GTEST I defined the wrap implementation of boughtLib.so library function(i.e.

    void __wrap_firstBoughtLib(){  //Some action to be trapped by gtest testcase}

) and I modified the make file of my gtest based test suite using

-Wl,--wrap=firstBoughtLib()

Now when I invoke the firstBoughtLib() directly from the testcase, the invoked function is __wrap_firstBoughtLib(), not the original one in boughtLib.so . However, each call to firstBoughtLib() performed in middleware.so still uses the functions in boughtLib.so.I tried removing from LD_LOAD_LIBRARY the folder containing the boughtLib.so, so that middleware.so didn't find it, but then at start time the SW complain about missing library.

If you have some suggestion about how to approach the issue, I would really appreciate.


Viewing all articles
Browse latest Browse all 22130

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>