Nasm, macho and Macos problem
- From: Giuseppe Cognetti <spamtrap@xxxxxxxxxx>
- Date: Wed, 21 Nov 2007 03:40:34 -0800 (PST)
I'm a Mac user, I work on MAC OS X 10.4.11.
I can't execute a binary file create with NASM (macho output). Sistem
say me:"cannot execute".
I've installed NASM
nasm -v
NASM version 0.98.40 compiled on Nov 21 2007
So I've also macho to work on a valid output file for MACOS
nasm -hf
valid output formats for -f are (`*' denotes default):
macho NeXTstep/OpenStep/Rhapsody/Darwin/MacOS X object files
I've compiled a "hello world" sample file.
Hello.asm
---------------------start code--------------------
section .text ; start of the code indicator
global _start ; make the main function
externally visible
section .data ; beginning of our data
section
msg db "Hello, World!",0xa ; string with a carriage-
return
len equ $ - msg ; string length in bytes
_syscall: ; declaring a kernel call function
int 0x80 ; make the system call
ret ; return to the caller
_start: ; entry point for linker
; write our string to standard output
push dword len ; message length
push dword msg ; message to write
push dword 1 ; file descriptor value
mov eax, 0x4 ; system call number (sys_write)
call _syscall ; call the kernel
add esp, 12 ; clean the stack
push dword 0 ; exit code
mov eax, 0x1 ; system call number (sys_exit)
call _syscall ; make the system call
---------------------end--------------------
So, I do
nasm -f macho hello.asm
I've now an hello.o file
I create Linker:
ld -e _start -o hello hello.o
Now, I should have a executable file.
But if I do:
../hello
Sistem answers me:
-bash: ./hello: cannot execute binary file
What's my damn problem??
Have u ideas?
(sorry for my bad english)
Tnx,
Giuseppe
.
- Follow-Ups:
- Re: Nasm, macho and Macos problem
- From: Keith Kanios
- Re: Nasm, macho and Macos problem
- Prev by Date: Re: converting an unsigned 64 bit in a FPU double
- Next by Date: Re: converting an unsigned 64 bit in a FPU double
- Previous by thread: converting an unsigned 64 bit in a FPU double
- Next by thread: Re: Nasm, macho and Macos problem
- Index(es):
Relevant Pages
|
|