| delorie.com/archives/browse.cgi | search | 
| X-Recipient: | archive-cygwin AT delorie DOT com | 
| X-Spam-Check-By: | sourceware.org | 
| Date: | Sat, 22 Mar 2008 22:08:59 -0400 | 
| From: | Christopher Faylor <cgf-use-the-mailinglist-please AT cygwin DOT com> | 
| To: | cygwin AT cygwin DOT com | 
| Subject: | Re: Usage of LD_PRELOAD | 
| Message-ID: | <20080323020858.GA31503@ednor.casa.cgf.cx> | 
| Reply-To: | cygwin AT cygwin DOT com | 
| Mail-Followup-To: | cygwin AT cygwin DOT com | 
| References: | <loom DOT 20080305T083145-971 AT post DOT gmane DOT org> | 
| MIME-Version: | 1.0 | 
| In-Reply-To: | <loom.20080305T083145-971@post.gmane.org> | 
| User-Agent: | Mutt/1.5.16 (2007-06-09) | 
| 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 Wed, Mar 05, 2008 at 08:47:13AM +0000, Matthieu CASTET wrote:
>Hi,
>
>I am trying to use LD_PRELOAD on cygwin, but I don't manage to make work.
>I suppose I do something wrong when creating my library.
>
>What I do is :
>
>$ cat << EOF > /tmp/toto1.c 
>#include <sys/stat.h>
>int chmod(const char *path, mode_t mode)
>{
>  printf("123\n");
>  return -1;
>}
>EOF
>
>$ module=toto1 gcc -shared -o /tmp/cyg${module}.dll    
>-Wl,--out-implib=lib${module}.dll.a     -Wl,--export-all-symbols    
>-Wl,--enable-auto-import -Wl,--whole-archive /tmp/toto1.c -Wl,--no-whole-archive
>
>$ export LD_PRELOAD=/tmp/cygtoto1.dll
>
>$ chmod a+w /tmp/toto1.c <-- chmod isn't redirected here (but the 
>library is loaded).
>
>
>Any idea why it doesn't work ?
Sorry for the delay. I had to research this to refresh my memory.
Cygwin requires that you hook the symbol using something like the following:
cygwin_internal (CW_HOOK, symname, sym);
Where "symname" is the name of the symbol and sym is the address of the
hook function.
cgf
--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/
| webmaster | delorie software privacy | 
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |