全局数据在64位模式下有关32位地址的错误

时间:2018-03-24 07:57:06

标签: assembly 64-bit nasm mach-o mach

我正在尝试使用nasm在mac上编写一个简单的x64汇编程序。这是我的计划:

global start

section .text
start:
    mov r10, 3; Store 3 to r10
    mov r9, 4; Store 4 to r9
    mov rax, r10; Move 3 to rax because multiply needs an arg in rax
    mul r9; Multiply 3*4. Result in rax.
    mov r9, rax; Move result back to r9.
    mov [myVar], r9; Store result to global
    mov r11, [myVar]; Load global result into r11
    mov rdi, r11; Move result into rax, the argument for syscall
    mov rax, 0x02000001; Select exit system call
    syscall

section .bss
myVar:
    resq 1

我正在使用此命令进行汇编:

nasm -fmacho64 test.s

我收到此错误:

test.s:10: error: Mach-O 64-bit format does not support 32-bit absolute addresses
test.s:11: error: Mach-O 64-bit format does not support 32-bit absolute addresses

我错过了什么?我只想要一个可以读取和写入的64位全局变量。

0 个答案:

没有答案