Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我为 x86 编写了一些汇编代码,并希望仅使用 Mac 的默认汇编程序('as')将其汇编成普通的二进制文件(不是 Mach-O)。经过几次谷歌搜索和尝试,我失败了。
虽然我知道如何使用 NASM(使用选项:-f 二进制)来做到这一点,但我不想这样做。因为我的代码是用写的,而且我习惯了 AT&T 的语法。
使用objcopy(它是 binutils 的一部分as)并--output-target设置为binary.
objcopy
as
--output-target
binary
as --64 test.s -o test.o objcopy -O binary test.o test.bin
并反汇编输出:
objdump -D -m i386:x86-64:intel -b binary test.bin
(替换--32和删除x86-64:32 位版本)
--32
x86-64: