NASMは問題なくコンパイルされますが、YASMを使用すると、次のエラーが発生します。
hello.asm:12:エラー:マッチョ:申し訳ありませんが、64ビットモードでは32ビットの絶対再配置を適用できません。memアクセスには「[_symbolwrt rip]」、ポインタには「qword」と「dq_foo」を検討してください。
Makefile
test: hello
./hello
hello:
yasm -f macho64 hello.asm
ld -o hello hello.o
clean:
rm *.o *.core hello
system.inc
%define stdin 0
%define stdout 1
%define stderr 2
%define SYS_nosys 0
%define SYS_exit 1
%define SYS_fork 2
%define SYS_read 3
%define SYS_write 4
section .text
align 4
access.the.osx.kernel:
syscall
ret
%macro system 1
mov rax, %1
call access.the.osx.kernel
%endmacro
%macro sys.exit 0
system SYS_exit
%endmacro
%macro sys.write 0
system SYS_write
%endmacro
hello.asm
%include 'system.inc'
section .data
hello db 'Hello, World!', 0Ah
hbytes equ $-hello
section .text
global start
start:
mov rax, 0x2000004
mov rdi, stdout
mov rsi, hello
mov rdx, hbytes
syscall
;sys.write
xor rdi, rdi
mov rax, 0x2000001
syscall
;sys.exit
誰が何が起こっているのか知っていますか?そして、NASMが機能する理由を説明できても、YASMが機能しない場合は、それはボーナスになります。