Wednesday, April 21, 2010

objdump (disassemble) on Mac OS X

There are two possible ways to disassemble a binary in Mac OS X: (1) install GNU binutils; (2) use otool.

(1) Install GNU binutils from the source (download), or from the MacPort.

(2) Use otool, the Mac OS X native utility. I summarize the usage of otool in the following:

otool -V -s <segment> <section> <file>
disassemble a specific segment and a segment, e.g., otool -V -s __text __TEXT /bin/ls (= objdump -d /bin/ls)

otool -L <file>
print out shared library dependencies (= ldd /bin/ls)

otool -tV <file>
disassemble the text section (= objdump -j .text -d /bin/ls)

otool -dv <file>
dump the contents of the data section (= objdump -j .data -s /bin/ls)


My photo
Hi, I am a PhD candidate at CMU. I was one of the founding members of PPP (Plaid Parliament of Pwning). I like programming in OCaml, F#, Haskell, and C++.