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: R: does LD_PRELOAD work under cygwin? (solved)


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


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