delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2011/01/21/17:14:36

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-0.8 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,T_TO_NO_BRKTS_FREEMAIL
X-Spam-Check-By: sourceware.org
MIME-Version: 1.0
In-Reply-To: <AANLkTinXKb+2m3LFYnaCergTDz5CpPyM1P2d_y=JPVOo@mail.gmail.com>
References: <AANLkTinXKb+2m3LFYnaCergTDz5CpPyM1P2d_y=JPVOo AT mail DOT gmail DOT com>
Date: Fri, 21 Jan 2011 23:14:09 +0100
Message-ID: <AANLkTi=BWd4EprvnKZhQXYwo=fdhKNym5n7d3ss-MhqY@mail.gmail.com>
Subject: Re: use of LD_PRELOAD (and RTLD_NEXT?)
From: marco atzeri <marco DOT atzeri AT gmail DOT com>
To: cygwin AT cygwin DOT com
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

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 {
> =A0 =A0[prefix code]
> =A0 =A0[call through to the "real" foo() function]
> =A0 =A0[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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019