Quantcast
Channel: Intel® C++ Compiler
Viewing all articles
Browse latest Browse all 1616

Redefining memory functions in libirc?

$
0
0

Hello,

I am linking my application with various Intel libraries. In my application I need to control any call to malloc() and friends. That is, I don't want to use the system's malloc() but want to use my own memory allocator. For the MKL libraries I can redirect the memory allocation using i_malloc and friends as described here https://software.intel.com/sites/products/documentation/doclib/iss/2013/mkl/mkl_userguide_lnx/GUID-751CE7F1-BA6A-475F-8B59-CB801F9F1AC3.htm.

I checked the other libraries I am linking with and none of them seems to have reference to memory allocation functions, with the single exception of libirc.a. This library apparently references malloc() etc. to define functions like _mm_malloc(). Is there a way to redefine the memory functions there in a similar way to the MKL libraries? I am not using any of the _mm_malloc() functions in my code (I need libirc.a for other purposes) so my code would not generate references to them. But I am not sure whether other functions in Intel libraries would call those functions?

In summary, I need to make sure one way or the other that linking with libirc.a does not produce direct calls to malloc() at runtime.

A few more notes:

  • It is not an option to use LD_PRELOAD or similar techniques to replace references to malloc() at runtime
  • All libraries must be linked statically
  • I could do something like 'objcopy --redefine-sym malloc=my_malloc libirc.a mylibirc.a' and then link with mylibirc.a but I am not sure whether this would violate any licenses? Also, this is rather ugly and I would like to avoid doing that. Similarly, using ld's --wrap=malloc feature could come to my rescue, but again, this is not something I like to do.

Thank you for any help or hints,

Daniel


Viewing all articles
Browse latest Browse all 1616

Trending Articles



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