problema nasm / gcc no Mac OS X Lion de 64 bits
Eu estava lendoest article e, a certa altura, ele me dá este programa nasm:
; tiny.asm
BITS 32
GLOBAL main
SECTION .text
main:
mov eax, 42
ret
E me diz para executar os seguintes comandos:
$ nasm -f elf tiny.asm
$ gcc -Wall -s tiny.o
Eu recebi o seguinte erro:
ld: warning: option -s is obsolete and being ignored
ld: warning: ignoring file tiny.o, file was built for unsupported file format which is not the architecture being linked (x86_64)
Undefined symbols for architecture x86_64:
"_main", referenced from:
start in crt1.10.6.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
Eu arrisquei um palpite sobre o que poderia ser o problema e alterei a linha do BITS para ler:
BITS 64
Mas quando eu corronasm -f elf tiny.asm
Eu recebo
tiny.asm:2: error: `64' is not a valid segment size; must be 16 or 32
Como modifico o código para funcionar na minha máquina?
Editar
Aceitei o conselho de Alex nos comentários e baixei uma versão mais recente. Contudo
./nasm-2.09.10/nasm -f elf tiny.asm
reclama
tiny.asm:2: error: elf32 output format does not support 64-bit code
Por outro lado
./nasm-2.09.10/nasm -f elf64 tiny.asm
gcc -Wall -s tiny.o
reclama
ld: warning: ignoring file tiny.o, file was built for unsupported file format which is not the architecture being linked (x86_64)
Undefined symbols for architecture x86_64:
"_main", referenced from:
start in crt1.10.6.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status