This is the mail archive of the cygwin mailing list for the Cygwin 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: use of LD_PRELOAD (and RTLD_NEXT?)


On Fri, Jan 21, 2011 at 9:10 PM, David Boyce  wrote:
> I'm trying to port to Cygwin a tool which makes heavy use of
> LD_PRELOAD (in other words, LD_PRELOAD is not used as a quick hack or
> workaround but is a core part of how the tool works). From my web
> searching, it seems that LD_PRELOAD support has been present for many
> years but the semantics are (a) different from POSIX or Linux and (b)
> undocumented AFAICT, so I'm looking for pointers to further knowledge.
>

LD_PRELOAD is working

with two advises if you try to load more than 1 dlls

1) the separator is only ":" , using a space doesn't work
2) if the dlls  have a dependency between them, the order is important

http://cygwin.com/ml/cygwin/2009-05/msg00823.html


> Specifically, searches of mailing list archives turn up sample
> programs showing how to "hook" a function but not how to gain "full
> control". Consider the following interposed function:
>
> int foo {
> ? ?[prefix code]
> ? ?[call through to the "real" foo() function]
> ? ?[suffix code]
> }
>
> What I call full control is when any or all of these steps may be
> elided, such that one can completely replace the function, change its
> return code, etc. The standard Linux/POSIX/SysV semantics support this
> by use of RTLD_NEXT which appears to be semi-unimplemented in Cygwin
> (a grep through the sources shows code for RTLD_NEXT in newlib but not
> in winsup). So my specific questions become:
>
> - Can the above functionality supported in the current implementation,
> and is the CW_HOOK method documented in detail anywhere?
> - What's the status of RTLD_NEXT? Is its presence in newlib just an
> historical artifact, or does it mean I can use it now with the right
> voodoo?
>
> BTW in 2004 someone asked about RTLD_DEFAULT and RTLD_NEXT, then
> contributed a patch implementing RTLD_DEFAULT only without saying why
> RTLD_NEXT had fallen off
> (<http://cygwin.com/ml/cygwin/2004-09/msg00288.html>). I'm guessing
> the main problem is that EnumProcessModules does not guarantee an
> order?
>
> Thanks,
> David Boyce
>
> --

Sorry, no clue about RTLD_DEFAULT and RTLD_NEXT

Marco

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


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