This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Possible bug with dlsym and LD_PRELOAD


Hi Ángel,

On 08/22/2012 12:20 AM, Ángel González wrote:
Have you tried simply replacing dlsym() ?
There you could place yourself in front of any call.

No, I hadn't thought of that.


Although this solves the immediate problem of intercepting these calls, it introduces a new problem; specifically, the code now can't call dlsym(RTLD_NEXT, ...) in the wrapping library. Any attempt to call this function is mapping (by LD_PRELOAD) to the intercepting implementation in the wrapping library.

Currently, although the code intercepts generic functions, like read(2) and write(2), it fakes only those calls that involve a socket. Those involving stdin/stdout/stderr and opened files are passed onto the underlying OS. This helps keep down the complexity.

With a custom dlsym function, the code intercepting write(2) now can't call the real write(2) but must always deliver a fake reply. This greatly increases the complexity of the system: the library now needs to provide a fairly complete POSIX implementation.

So, although this solves the problem, I think I'll carry on looking for alternatives.

Cheers,

Paul.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]