I have an example assembly file that I am compiling with nasm:
nasm -f elf syscall.asm
This creates the syscall.o file . I am trying to associate it with ld:
ld -o syscall syscall.o
The ld command fails with the following error:
ld: i386 architecture of input file `syscall.o' is incompatible with i386:x86-64 output
However, if I do
ld -o syscall syscall.o -melf_i386
the command succeeds and I get the syscall executable .
Finding out that nasm is not generating object code in x86-64 format, I added the "BITS 64" directive to the top of the syscall.asm file.
Then trying to build syscall.asm with nasm gave the following error:
error: elf output format does not support 64-bit code
This seems strange, because doing "file / usr / bin / nasm" on my terminal gives:
/usr/bin/nasm: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, stripped
My 64-bit Fedora Core 11 has the latest nasm installed, and my processor is an Intel Core 2 Duo E7200.
[EDIT]
, nasm , i386: x86-64.