Is it possible to create a simple binary only using the GNU Assembler on Mac OS X?

I wrote the build code for x86 and wanted to build it into a regular binary (not Mach-O), just using the default assembler of Mac ("how"). After several googling and trying, I failed.

Although I know how to do this with NASM (using the option: -f binary), I don't want to do this. Since my code was written and I was used for AT & T syntax

+4
source share
1 answer

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 parse the output:

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

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

+4
source

Source: https://habr.com/ru/post/1379147/


All Articles