我在運行32位程序集的64位mac上運行os x 10.9.5時出現問題。我也安裝了NASM 2.11.08。我目前正在閱讀Jeff Duntemann撰寫的「彙編語言一步一步」。在這本書中,他爲linux操作系統中的32位程序集指定了指令。我如何在我的64位Mac OS X電腦上運行此程序。在64位處理器上運行32位程序集與mac os x
; eatsyscall.asm
SECTION .data ; Section containing initialised data
EatMsg: db "Eat at Joes!",10
EatLen: equ $-EatMsg
SECTION .bss ; Section containing uninitialized data
SECTION .text ; Section containing code
global _start ; Linker needs this to find the entry point!
_start:
nop ; This no-op keeps gdb happy...
mov eax,4 ; Specify sys_write call
mov ebx,1 ; Specify File Descriptor 1: Standard Output
mov ecx,EatMsg ; Pass offset of the message
mov edx,EatLen ; Pass the length of the message
int 80H ; Make kernel call
MOV eax,1 ; Code for Exit Syscall
mov ebx,0 ; Return a code of zero
int 80H ; Make kernel call
我試圖與
nasm -f elf -g -F stabs eatsyscall.asm
組裝它,然後我試圖把它與
ld -o eatsyscall eatsyscall.o
鏈接,但我得到這個錯誤
ld: warning: -arch not specified
ld: warning: -macosx_version_min not specified, assuming 10.6
ld: warning: ignoring file eatsyscall.o, file was built for unsupported file format (0x7F 0x45 0x4C 0x46 0x01 0x01 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00) which is not the architecture being linked (x86_64): eatsyscall.o
Undefined symbols for architecture x86_64:
"start", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for inferred architecture x86_64
這應該運行,對?我認爲英特爾的64位處理器能夠運行32位程序。還是沒有辦法在64位的Mac上運行爲32位Linux系統編寫的彙編程序?
我是否需要安裝一些32位庫以便能夠鏈接此文件?我應該使用NASM以外的其他產品,例如GCC嗎?或者程序本身寫入不正確。謝謝您的幫助!