Question

Can someone here tell me if there is something similar to LD_PRELOAD on recent versions of AIX? More specifically I need to intercept calls from my binary to time(), returning a constant time, for testing purposes.

Was it helpful?

Solution

AIX 5.3 introduced the LDR_PRELOAD (for 32-bit programs) and LDR_PRELOAD64 (for 64-bit programs) variables. They are analoguous to LD_PRELOAD on Linux. Both are colon-separated lists of libraries, and symbols will be pre-emptively loaded from the listed shared objects before anything else.

For example, if you have a shared object foo.so:

 LDR_PRELOAD=foo.so

If you use archives, use the AIX style to specify the object within the archive:

 LDR_PRELOAD="bar.a(shr.so)"

And separate multiple entries with a colon:

 LDR_PRELOAD="foo.so:bar.a(shr.so)"

OTHER TIPS

AIX 5L uses the LDR_PRELOAD variable.

Not that I'm aware of. Closest thing we've done (with malloc/free for debugging) is to

  • create a new library file with just the functions desired (same name as original).
  • place it in a different directory to the original.
  • make a dependency from our library file to the original.
  • change the LD_LIBRARY_PATH (or SHLIB_PATH?) to put our library first in the search chain.

That way, our functions got picked up first by the loader, any we didn't supply were provided by the original.

This was a while ago. AIX 5L is supposed to be much more like Linux (hence the L) so it may be able to do exactly what you require.

Alternatively, if you have the source, munge the calls to time() with mytime() and provide your function. You're not testing exactly the same software but the differences for that sort of minimal change shouldn't matter.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top