czytałem this artykuł, iw pewnym momencie daje mi ten program nasm:nasm/gcc problem na 64-bitowym systemie Mac OS X Lion
; tiny.asm
BITS 32
GLOBAL main
SECTION .text
main:
mov eax, 42
ret
i mówi mi, aby uruchomić następujące polecenia:
$ nasm -f elf tiny.asm
$ gcc -Wall -s tiny.o
mam następujący błąd:
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
zaryzykowałem przypuszczenie co co może być przyczyną problemu, i zmienił linię bitów do odczytu:
BITS 64
Ale kiedy biegnę nasm -f elf tiny.asm
uzyskać:
tiny.asm:2: error: `64' is not a valid segment size; must be 16 or 32
Jak zmodyfikować kod, aby pracować na moim komputerze?
Edit:
Wziąłem porady Alexa z uwagami i pobrać nowszą wersję. Jednak
./nasm-2.09.10/nasm -f elf tiny.asm
narzeka
tiny.asm:2: error: elf32 output format does not support 64-bit code
Z drugiej strony,
./nasm-2.09.10/nasm -f elf64 tiny.asm
gcc -Wall -s tiny.o
narzeka
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
Sprawdź, czy masz najnowszą nasm i wypróbuj '-f elf64'. –
@Alex elf64 dał mi "nierozpoznany format wyjściowy". Jeśli chodzi o wersję, nasm -v dał mi "wersję NASM 0.98.40 (Apple Computer, Inc. build 11) skompilowaną 3 listopada 2011 r." 0.98 wygląda na starą wersję, ale została skompilowana w 2011 roku, więc nie może być tak stara prawda? Dlaczego firma Apple ma przestarzałe oprogramowanie? Domyślny asembler, który nie może złożyć 64-bitowego kodu na platformie 64-bitowej? – math4tots
Twoje jest strasznie nieaktualne. Mine prints "NASM wersja 2.09.10 skompilowana 15 lipca 2011". Nowsza wersja to [tutaj] (http://www.nasm.us/pub/nasm/releasebuilds/2.09.10/). –