another LoadLibrary question / crash (sorry)

Mike Giancola
Fri Dec 4 19:25:00 GMT 2015


I apologize for asking the same question that has been asked so many
times - but I'm stuck.

I have a DLL built in Cygwin that I'm trying to call from a program
compiled in Visual Studio 2012. When I call LoadLibrary it's
successful, however calls to the APIs crash the program.

>From what I've read, I understand I need to allocate "4k of scratch
space at the bottom of the stack" and call the  cygwin_dll_init first.
(From section 6.19).

I haven't been able to find the how-cygtls-works.txt nor
winsup/testsuite/cygload - most of the links in old mail archives are
dead (some messages go back to 2007). That said, I've found

Here, the code attempts to use some assembly to set the stack size:

#ifdef __GNUC__
  __asm__ (
    "movl %%fs:4, %0"
        mov eax, fs:[4];
        mov stackbase, eax;

However these lines crash the program. I've downloaded these exact
files (the .cc & .h) and compiled them using VS2012. When debugged /
run i get an access violation and crash. Note - i'm trying to run this
program as is, unmodified.

Is there a specific compiler flag i need to set in order to allow
these operations? I've turned off DEP, i've tried both set the entry
point to be cygloadCRTStartup then going back - reseting the entry
point and uncommenting the construction of the padding object line.
Both fail.

Does anyone happen to have a simple example - simply calling a
"fooapi" within a dll available? Is there any updated documentation

Thanks for the help!


Problem reports:
Unsubscribe info:

More information about the Cygwin mailing list