Page 1 of 1

Reading Mach-O objects under Linux

Posted: Sun Nov 20, 2011 1:24 pm
by NickJohnson
Pretty straightforward question: do there exist tools analogous to readelf/objdump that will allow me to read and disassemble Mach-O binaries under a Linux machine? It seems that binutils doesn't support Mach-O, and I don't actually own a Mac. ndisasm seems to at least not choke on Mach-O binaries, but it also doesn't read the symbol tables or separate sections, which makes it inadequate for my purposes.

Re: Reading Mach-O objects under Linux

Posted: Sun Nov 20, 2011 1:43 pm
by Brynet-Inc
I believe you're looking for otool, which is part of Apple's cctools.

It's open source, but you'll probably have to do the neccessary porting work (..and from the look of it, obtain the relevant mach-o header files).

Re: Reading Mach-O objects under Linux

Posted: Sun Nov 20, 2011 2:53 pm
by NickJohnson
Looks like it will work. Now I just have to find those Mach-O C headers...

If I get this working, I'll post a patch here.

Re: Reading Mach-O objects under Linux

Posted: Sun Nov 20, 2011 3:49 pm
by turdus
Use this tool: http://www.agner.org/optimize/#objconv
You can convert Mach-O to ELF and vice-versa with it, and includes a disassembler too.

Re: Reading Mach-O objects under Linux

Posted: Mon Nov 21, 2011 7:34 am
by Owen
turdus wrote:Use this tool: http://www.agner.org/optimize/#objconv
You can convert Mach-O to ELF and vice-versa with it, and includes a disassembler too.
Generally Mach-Os can't be translated to ELF or any other format. The relocations are not representable.