Mail Archives: cygwin/2004/02/17/13:11:47
Williams, Gerald S (Jerry) wrote:
>> I wanted to test some of my linux assembler code on my
>> Windows-Cygwin box.
>> Is it possible at all?
> I don't know about using BIOS calls, etc., but I've
> assembled and linked a few NASM assembly functions.
What about Linux syscalls? Will Cygwin emulation layer match it? On the
Linux box that I used to work, there was a big /usr/inlude/asm directory. My
Cygwin /usr/include/asm contains only three files (byteorder.h socket.h
types.h). Does it have anything to do?
> I didn't use ELF format, though. There's a gnuwin32
> format that works with Cygwin.
And that's why ld produced corrupted executable. Thanks - with gnuwin32 at
least I get a proper binary.
> I've only ever linked them as functions called via
> the C environment, but if you take the following:
It works fine, thank you.
With gnuwin32 I get:
bash-2.05b$ nasm -f gnuwin32 hello.asm
bash-2.05b$ gcc hello.o -o hello.exe
/usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/../../../libcygwin.a(libcmain.o)(.text
+0x7c):
undefined reference to `_WinMain AT 16'
collect2: ld returned 1 exit status
bash-2.05b$ ld hello.o -o hello.exe
ld: warning: cannot find entry symbol _mainCRTStartup; defaulting to
00401000
bash-2.05b$ ./hello
bash-2.05b$
So I changed _start function name to _main:
bash-2.05b$ cat hello.asm
section .data
t db 'Hello world',0
len equ 13
section .text
global _main
_main: mov edx,len
mov ecx,t
mov ebx,1
mov eax,4
int 0x80
mov ebx,0
mov eax,1
int 0x80
bash-2.05b$ nasm -f gnuwin32 hello.asm
bash-2.05b$ ld hello.o -o hello.exe
ld: warning: cannot find entry symbol _mainCRTStartup; defaulting to
00401000
bash-2.05b$ ./hello.exe
bash-2.05b$ gcc hello.o -o hello.exe
bash-2.05b$ ./hello.exe
Segmentation fault (core dumped)
Is there a way I could force Cygwin's ld to work the way Linux ld used to?
Regards
Krzysztof Duleba
--
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/
- Raw text -