Is it possible to disassemble C code into intel assembly using an m1 mac?

1.3k views Asked by At

I've been trying to disassemble C code into intel assembly code on my m1 macbook pro but can't find any way to do it (i've tried to look up how to do it using gdb, lldb, objdump, but no succes so far). So my question is: is it possible and if so, how and with which library/program? Would it also be possible to do with an IDE like CLion or Xcode?

Thanks in advance!

2

There are 2 answers

1
Ross Wen On

I have solution, you can use brew install x86_64-elf-binutils, then you will have a set of tools which are same with what you normally used in x86 platform linux such as x86_64-elf-gcc, and x86_64-elf-objdump is one of them. Then you can easily use it as what you use objdump in x86 linux enviroment.

4
elichka On

Yes, I did it on a M1 Mac.

First build your .c file with

clang -arch x86_64 -O0 -g file.c -o out

To get your x86 assembly output you can use one of the following commands

objdump -Sd out > asm.s

objdump -drwC -Mintel out > asm.s