Page MenuHomePhabricator

[llvm-readobj] add support for macho universal binary
ClosedPublic

Authored by chilledheart on Mar 9 2015, 2:48 AM.

Details

Summary

MachO Universal Binary is a commonly used format in OS X and iOS, e.g.
frameworks in Apple's iOS SDK. Adding support for MachO Universal Binary
makes llvm-readobj a more convenient tool for the daily use.

And because MachO Universal Binary is rather a container format than binary
format, this patch adds support for handling this format in the same way as
in Archive files, i.e., dumping required information for MachO Objects in it
one by one.

Diff Detail

Event Timeline

chilledheart retitled this revision from to [llvm-readobj] add support for macho universal binary.
chilledheart updated this object.
chilledheart edited the test plan for this revision. (Show Details)
chilledheart added reviewers: friss, kledzik.
chilledheart added a subscriber: Unknown Object (MLST).
rafael added inline comments.
tools/llvm-readobj/llvm-readobj.cpp
326

Pity we don't have ' objects() to use with range loop. Would you mind adding it?

331

Why? Do we really get universal binaries with non Object Members?

add MachOUniversalBinary::objects() method and remove unnecessary checks for non-object members

I am not sure if explicit initialization of MachOUniversalBinary::Objects is good enough. Maybe we need to change the MachOUniversalBinary::object_iterator to typedef ObjectForArch* object_iterator and related code as well to use MachOUniversalBinary::Objects directly?

tools/llvm-readobj/llvm-readobj.cpp
331

Sorry, I'll remove the dead code in the next patch.

rafael added inline comments.Mar 12 2015, 10:08 AM
include/llvm/Object/MachOUniversal.h
117

Please don't add this. You can use iterator_range to implement objects().

use llvm::iterator_range

improve code style

rafael added inline comments.Mar 12 2015, 3:16 PM
tools/llvm-readobj/llvm-readobj.cpp
329

This now ignores every error. Shouldn't we call reportError for every error instead?

report error if any

report error if any

include/llvm/Object/MachOUniversal.h
117

Thanks for pointing it out. It should be corrected in the next patch.

tools/llvm-readobj/llvm-readobj.cpp
329

reportError code is added back

rafael accepted this revision.Mar 13 2015, 6:11 AM
rafael added a reviewer: rafael.

LGTM, thanks!

This revision is now accepted and ready to land.Mar 13 2015, 6:11 AM

You're welcome.

Hi rafael,

If everything is okay, could you commit this patch for me? I don't have the commit permission to the source tree yet.

Cheers,

Chilledheart

Thank you, rafael!

chilledheart closed this revision.Mar 25 2015, 9:44 AM

"Committed as r233107"