如何使用-no-pie在MacOS上编译和运行x86-64程序集?

问题描述

我目前正在上一门汇编课程,并且在Mac上用于编译和运行代码的Linux虚拟机非常慢且容易出错。因此,我尝试使用gcc编译器在本机MacOS终端上对其进行编译,但始终收到有关32位寻址模式的错误

以下是我在终端中尝试编译时发生的情况。我们正在使用AT&T汇编语法,并且$c处的变量定义为c: .asciz "%c"。通常,在Linux终端中,我们使用类似于gcc -no-pie -o fileName /Directory/fileName.s的命令来编译代码,然后通过键入./fileName来运行它。

如何使用-no-pie在Mac上编译并运行x86-64 AT&T程序集?

 ^
~/Desktop/assignments/3> gcc -fno-pie decoder.s
decoder.s:39:2: error: 32-bit absolute addressing is not supported in 64-bit mode
 movq $c,%rdi # copy string format to RDI
 ^
decoder.s:66:2: error: 32-bit absolute addressing is not supported in 64-bit mode
 movq $MESSAGE,%rdi # first parameter: address of the message
 ^

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)