Hi guys has anyone run an assembly program on a 64 bit machine im getting the following error:
nasm -f elf hello.asm
ld -s -o hello hello.o
ld: i386 architecture of input file `hello.o’ is incompatible with i386:x86-64 output
Hi guys has anyone run an assembly program on a 64 bit machine im getting the following error:
nasm -f elf hello.asm
ld -s -o hello hello.o
ld: i386 architecture of input file `hello.o’ is incompatible with i386:x86-64 output
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
What kind of 64-bit? x86_64? IA64? Sparc64?
Also did you change the code to work on the 64-bit machine? Register
names, for example, change between x86_32 and x86_64. rip, rsp, rbp…
all of those are used instead of eip, esp, ebp. Also there are more
registers though having the option doesn’t require you to use them.
Posting your hello.asm file would perhaps be useful.
Good luck.
hgallo wrote:
> Hi guys has anyone run an assembly program on a 64 bit machine im
> getting the following error:
>
> nasm -f elf hello.asm
> ld -s -o hello hello.o
> ld: i386 architecture of input file `hello.o’ is incompatible with
> i386:x86-64 output
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iQIcBAEBAgAGBQJLVevsAAoJEF+XTK08PnB5LGsP+wQlFytioowvdQf91U9r0rlK
XzxYXkR48qIDu9i4ZgrjrFnwrbam26ZEq8LZrM2khtfS/DRJbcsuN++3jvsBKEMM
7W7mC3bERfuQcHnKgdxEgu13PwC1C1jeGtK3Cq/RA1jgYid16KigtDXLgbZwwWgb
ywmjlePnu1PAAOYKZm99LrOnW0yci5b1It/2m/6gJeD5Mq0/Ba8EYw//Z9j7bK8q
ujM8AK47+b5wxTI+UR5pb9Nx7k84oL6CoPneU/QR9h24vCrovoy/bx1fYTIlpcYI
aBH7HyAxOp66Dgbpbdxyr86sBfHMv14CKKz9Zp6BxvA8HlsaLb5FwxakthiWETiI
30KtUdfkSx5W3blCTABovo9ZizVOKhMiaamIoNH/KSDotF3tZC+/FZm/613jBbw0
sBnGDrnE3mIQ/tRgIjtf8Bw3tnW0gh6WVME1PzvzXiVxcGN81b+/KLq42Pce/oLl
rS2BrNoWRtCzSQ3xwziccczyPw+kGPPU6dAVac7NblqRHK49i0/Rwl/CLqRRqrGk
12UGoigc1dPtnchaqDbJMMn+7vxZ9YXTcI5B/E+LfxnBU0kuiVWaB+93314wCMPR
nxwkfQl4jn8fEbI7SnN0km3uW/Lvs8acejDV0KnheRGrlStLiGKDCCjwPS2UnziR
D2HYjn4snJICUXR0VrBM
=TAgr
-----END PGP SIGNATURE-----
Create the object file in elf64 format.
nasm -f elf64 hello.asm
ld -s -o hello hello.o
./hello
thank you Hash: SHA1 im running i386:x86-64 and the code is the following:
section .text
global _start ;must be declared for linker (ld)
_start: ;tell linker entry point
mov edx,len ;message length
mov ecx,msg ;message to write
mov ebx,1 ;file descriptor (stdout)
mov eax,4 ;system call number (sys_write)
int 0x80 ;call kernel
mov eax,1 ;system call number (sys_exit)
int 0x80 ;call kernel
section .data
msg db ‘Hello, world!’,0xa ;our dear string
len equ $ - msg ;length of our dear string
its a hello world program I got from online
This program should work on 64 bit machines, if you assemble with elf64 option.
nasm -f elf64 hello.asm
Thank you syampillai you really hit the nail on the head. You guys are great Thanks again…
thanks) It’s very help me!