How to disassemble a x86-64 GNU/Linux binary in macOS Sequoia 15.4
By sborrazas on 2025-04-19
I am learning x86-64 assembler in Linux. Doing this in macOS is fairly easy using Docker thanks to Rancher Desktop. You can also virtualize GNU/Linux using UTM or OrbStack.
However, when trying to debug the compiled code using GDB it didn’t work. It seems to be related to a limitation in Rosetta virtualization. Here are the commands to debug a x86-64 GNU/Linux program using GDB running under Rosetta.
I used these OrbStack instructions about debugging with GDB/LLDB. I used them in a regular Docker container using Rancher Desktop and they work fine there as well:
sudo apt install qemu-user-static
qemu-x86_64-static -g 1234 ./hello # ./hello is the program we wish to debug
# in another terminal
gdb ./hello
target remote :1234
continue
Instead of OrbStack I used the following command to start the container in Rancher Desktop:
docker run -it --platform linux/amd64 --name my_ubuntu_container -p 2222:22 ubuntu
then in the container I run
apt update && apt upgrade --yes
&& ln -snf /usr/share/zoneinfo/UTC /etc/localtime && echo UTC > /etc/timezone
&& apt install qemu-user-static gdb build-essential vim tmux openssh-server --yes
&& mkdir /var/run/sshd && echo "root:password" | chpasswd
&& echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config
&& service ssh start
Later I connect to the container with
docker exec -it my_ubuntu_container bash # run `docker start my_ubuntu_container` if is stopped
I can also ssh into it:
ssh -p 2222 root@localhost # user `root`, password `password`
After you are connected, you run:
qemu-x86_64-static -g 1234 ./hello # ./hello is the program we wish to debug
And in another terminal you run:
gdb ./hello
target remote :1234
continue # normally you use `run` command, but it's already loaded thanks to qemu-x86_64-static
Remember to run qemu-x86_64-static -g 1234 ./hello
again if you hit the end of the program in GDB.
In Rancher Desktop remember to use emulation VZ (Apple Virtualization) in Preferences/Virtual Machine/Emulation and enable Rosetta support.
External links with more information: