How can I install objdump on Mac OS X?

I want to get the source code of a small command line tool using objdump on Mac OS X.

I've used arm-linux-objdump on Linux and find it a great tool.

Is there any way to install objdump on OS X? I've searched Google and found information about arm-apple-dawin9-objdump, but failed to find anything to download.

6 Answers

objdump is part of binutils.

5

If you have XCode Tools installed on your Mac, you can use the otool that comes with it. I believe it does pretty much what objdump is capable of.

4

If your file is 64bits, you should use otool instead of gobjdump from binutils. On Mac OSX, gobjdump is for 32bits.

1

You can install it with Homebrew:

$ brew install binutils
==> Downloading
######################################################################## 100.0%
==> Pouring binutils-2.25.yosemite.bottle.tar.gz
🍺 /usr/local/Cellar/binutils/2.25: 107 files, 140M
$ which gobjdump
/usr/local/bin/gobjdump

You should use otool because objdump is a binutils tool for the ELF binary format on Linux and most other UNIX systems. otool is the the disassembler for MacOS's Mach-O binary format. Type $ man otool for instructions on use.

After binutils installation through brew install binutils, if you still can not find gobjdump in your $PATH, the reason perhaps is that homebrew forgot to create soft link to the binary.

$ cd /opt/homebrew/bin
// $ ls -l ../Cellar/binutils/2.37/bin/gobjdump
// lrwxr-xr-x 1 steve admin 7 Jul 19 2021 ../Cellar/binutils/2.37/bin/gobjdump -> objdump
// change this command to fit your objdump binary path
$ link ../Cellar/binutils/2.37/bin/gobjdump gobjdump

My environment:

$ uname -a
Darwin localhost 20.5.0 Darwin Kernel Version 20.5.0: Sat May 8 05:10:31 PDT 2021; root:xnu-7195.121.3~9/RELEASE_ARM64_T8101 arm64
$ brew --version
Homebrew 3.4.3
Homebrew/homebrew-core (git revision 1f841cb3044; last commit 2022-03-27)
Homebrew/homebrew-cask (git revision 60208d8c20; last commit 2022-03-26)

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like