| delorie.com/archives/browse.cgi | search |
| X-Recipient: | archive-cygwin AT delorie DOT com |
| X-SWARE-Spam-Status: | No, hits=-1.9 required=5.0 tests=AWL,BAYES_00 |
| X-Spam-Check-By: | sourceware.org |
| Message-ID: | <4B18E28B.8030203@mozdev.org> |
| Date: | Fri, 04 Dec 2009 18:20:59 +0800 |
| From: | basic <basic AT mozdev DOT org> |
| User-Agent: | Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.4pre) Gecko/20090928 Thunderbird/3.0b4 |
| MIME-Version: | 1.0 |
| To: | cygwin AT cygwin DOT com |
| Subject: | Re: R: does LD_PRELOAD work under cygwin? (solved) |
| References: | <991032 DOT 65593 DOT qm AT web25505 DOT mail DOT ukl DOT yahoo DOT com> <4B18CEF9 DOT 4040309 AT mozdev DOT org> |
| In-Reply-To: | <4B18CEF9.4040309@mozdev.org> |
| X-IsSubscribed: | yes |
| Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
| List-Id: | <cygwin.cygwin.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 12/04/2009 04:57 PM, basic wrote:
> On 12/04/2009 03:05 PM, Marco Atzeri wrote:
>> --- Ven 4/12/09, basic ha scritto:
>>
>>> Hi,
>>> Does LD_PRELOAD work under cygwin? I've tried the
>>> following without success:
>>
>> LDPRELOAD works with few peculiarites for multiple dll's
>> but this is not your case.
>>
>>>
>>> gcc test.c
>>> gcc -shared testlib.c -o testlib.dll
>>
>> see documentation
>> http://cygwin.com/cygwin-ug-net/dll.html
>> on how to build and link dll's
> I've read the document, but I do not see what I'm doing is any different from it. Any hints?
After searching the mailing lists more, I found
http://sourceware.org/ml/cygwin/2008-03/msg00547.html
I got it to work by adding a call to cygwin_internal (CW_HOOK, "open", open); to a DllMain
function in testlib.c.
>
>>
>>>
>>> LD_PRELOAD=$HOME/testlib.dll ./a.exe
>>>
>>> where test.c is:
>>>
>>> #include <fcntl.h>
>>>
>>> int main()
>>> {
>>> open("", 1);
>>> return 0;
>>> }
>>>
>>>
>>> and testlib.c is:
>>>
>>> #include <stdio.h>
>>>
>>> int open(const char *s, int i, ...)
>>> {
>>> puts("test");
>>> return 0;
>>> }
>>>
>>> Is there anything I'm doing wrong? Or is it just not
>>> supported?
>>>
>>> --
>>> basic
>>>
>> regards
>> Marco
>>
>>
>>
>>
>
>
> --
> basic
>
> --
> 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
>
--
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
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |