Sample Header Ad - 728x90

Trying to assemble and run x86_64 assembly on M1

1 vote
0 answers
386 views
For a university course i need to use x86_64 assembly (AT&T syntax) and I was wondering if there is a way to run this through rosetta 2. So far I've set the OG terminal to run through Rosetta 2, and managed to install gcc and gdb. Despite this, when I try to run the binary I either get:
zsh: exec format error: ./helloworld
when I run it directly through the terminal; or:
./helloworld: ./helloworld: cannot execute binary file
when I try to run it as follows:
arch -x86_64 ./heloworld
I've read the "cannot execute binary file" is an error when trying to run a binary through the wrong architecture, but I hoped that Rosetta could fix this... Is there anything that I'm missing? Any solution for running this binaries (other than a VM)? Edits:
$ lipo -detailed_info helloworld
input file helloworld is not a fat file
Non-fat file: helloworld is architecture: x86_64
$ file helloworld
helloworld: Mach-O 64-bit object x86_64
I created
by assembling it through:
arch -x86_64 gcc -no-pie -c -g -o helloworld helloWorld.s
Asked by Max M (11 rep)
Sep 7, 2023, 02:00 PM
Last activity: Sep 7, 2023, 03:21 PM