简体   繁体   中英

Is it possible to produce a plain binary file only using GNU Assembler on Mac OS X?

I wrote some assembly code for x86, and wanted to assemble it into plain binary file (not Mach-O) by just using Mac's default assembler (the 'as'). After several googlings and tries, I failed.

Though I know how to do it with NASM (using option: -f binary), I don't want to do so. Because my code was written in and I was used to AT&T syntax.

Use objcopy (which is part of binutils as is as ) with --output-target set to binary .

as --64 test.s -o test.o
objcopy -O binary test.o test.bin

And to disassemble the output:

objdump -D -m i386:x86-64:intel -b binary test.bin

(Substitute --32 and remove x86-64: for 32-bit versions)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM