Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Date: Fri, 16 May 2003 20:14:42 +0300 From: RomikB Reply-To: RomikB Organization: RBG X-Priority: 3 (Normal) Message-ID: <179567448.20030516201442@mail.ru> To: Ronald Landheer-Cieslak CC: cygwin AT cygwin DOT com Subject: Re[2]: DLL creating problem In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hello Ronald, Wednesday, May 14, 2003, 1:29:21 PM, you wrote: I'll try to create a dll using your hint, but i still have nothing. Created dll is incorrect >> It have a >> "mov edi,bss_data+something" instead of "mov edi,bss_data" I ask people at nasm.sf.net, they say that is possible a mingw(cygwin) problem of incorrect using coff and win32 format. ----------------------------------------------------------------------- The issue is that .bss sections to not seem to behave properly, using either '-f coff' or '-f win32' formats, when linked against MinGW32 and probably Cygwin. No testing has been done against Cygwin. I added a new format to outcoff.c called 'gnuwin32', specifically to deal with these problems. I assume cygwin uses the same object format as mingw32, hence the gnuwin32 format name. It's based on the differences I found in the mingw32 gcc output objects, relative to the 'Notes on COFF' in the top of outcoff.c ... (4) Both standard COFF and Win32 COFF seem to use the DWORD field directly after the section name in the section header table for something strange: they store what the address of the section start point _would_ be, if you laid all the sections end to end starting at zero. Dunno why. Microsoft's documentation lists this field as "Virtual Size of Section", which doesn't seem to fit at all. In fact, Win32 even includes non-linked sections such as .drectve in this calculation. ----------------------------------------------------------------------- RLC> ELF is a Linux format - that won't work in any case. RLC> (remember: Cygwin is a DLL that allows Windows programs to use POSIX RLC> functions, but they're still Windows programs) I'll find a way to create a dll using a elf file format nasm -f elf -o file_asm.o file_asm.asm gcc -c -o file_c.o file_c.c dllwrap -o file.dll file_asm.o file_c.o --def file.def strip file.dll I know that is wrong way, but it working :) RLC> You'll also have to use the -mno-cygwin switch to disable the use of the RLC> Cygwin DLL as a runtime library, and make sure your calling conventions in RLC> asm match those in the CRT you use (if using -mno-cygwin, the CRT would be RLC> MSVCRT). RLC> Now, without having tested this, that should boil down to: RLC> $ nasm -f win32 -o file_asm.o file_asm.asm RLC> $ gcc -c file_c.c -o file_c.o RLC> $ gcc -mno-cygwin -shared -o file_dll.dll RLC> -Wl,--out-implib=libfile_dll.dll.a RLC> -Wl,--export-all-symbols RLC> -Wl,--enable-auto-import RLC> -Wl,--whole-archive file_asm.o file_c.o RLC> -Wl,--no-whole-archive RLC> -Wl,--output-def=libfile_dll.dll.def >> ------file_asm.asm------- >> global _function_asm >> extern _printf >> section .text >> _function_asm: >> push dword str >> call _printf >> add esp,0x04 >> mov ecx,0x1000 >> mov edi,bss_data >> rep stosd >> ret >> section .data >> str db "String2print",0 >> section .bss >> bss_data resd 0x1000 >> ------file_c.c------ >> void function_c(void){ >> } >> -------------------- >> other creates a "wrong" dll. It has a section size problem and not >> working under the windowsXP or 2k. ( format == elf ) >> or create a "incorrect" dll. It have a >> mov edi,bss_data+something instead of mov edi,bss_data >> (format == win32 or coff) -- Best regards, RomikB mailto:romikb AT mail DOT ru -- 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/