This is the mail archive of the cygwin@sources.redhat.com 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]

Re: crash using _environ from libmsvcrt20/40.a


> MSVCRT*.DLL and Cygwin1.dll are mutually exclusive.  You can't mix them.
> 
> If you want to use MSVCRT*.DLL use the -mno-cygwin option when you compile
> and link.

Thanks, I've added that, and objdump -p confirms that the binary does
not use cygwin.dll, BUT the program still faults in the same way.

To re-iterate, the instructions that try to load the address for
_environ are loading the first 4 bytes from:
(objdump -d -S a.exe)
00401298 <__environ>:
  401298:	ff 25 d0 30 40 00    	jmp    *0x4030d0

and using this value causes the access violation. If I manually change
it every time to 0x4030d0, the program can actually execute, although
_environ seems to point to garbage.
At this point, I'm just a bit confused about what's going on. I don't
understand why the 2 bytes for the jmp opcode are there, or
alternatively why the main progam code that tries to load the address
for _environ, accidentally gets 2 bytes of the opcode for jmp and
therefore faults.
The link.map suggests that the address 0x4030d0 is the right place:
 .idata$5       0x004030d0        0x4 /usr/lib/libmsvcrt40.a(ds00128.o)
                0x004030d0                _imp___environ

The progam works when compiled with msvc, which suggests to me either
there is a problem in the import library, or perhaps have I done the
build incorrectly?

Nigel

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com


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