Reading Mach-O objects under Linux

Programming, for all ages and all languages.
Post Reply
User avatar
NickJohnson
Member
Member
Posts: 1249
Joined: Tue Mar 24, 2009 8:11 pm
Location: Sunnyvale, California

Reading Mach-O objects under Linux

Post 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.
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Re: Reading Mach-O objects under Linux

Post 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).
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
User avatar
NickJohnson
Member
Member
Posts: 1249
Joined: Tue Mar 24, 2009 8:11 pm
Location: Sunnyvale, California

Re: Reading Mach-O objects under Linux

Post 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.
User avatar
turdus
Member
Member
Posts: 496
Joined: Tue Feb 08, 2011 1:58 pm

Re: Reading Mach-O objects under Linux

Post 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.
User avatar
Owen
Member
Member
Posts: 1700
Joined: Fri Jun 13, 2008 3:21 pm
Location: Cambridge, United Kingdom
Contact:

Re: Reading Mach-O objects under Linux

Post 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.
Post Reply