This is an archive of the discontinued LLVM Phabricator instance.

[MachO] Introduce MinVersion API
ClosedPublic

Authored by davide on Aug 24 2015, 8:38 AM.

Details

Summary

Hi,
while introducing support for MinVersionLoadCommand in llvm-readobj I noticed there's no API to extract Major/Minor/Update components conveniently. Currently consumers do the bit twiddling on their own. I think this level of coupling is not necessary. Consumers shouldn't be aware of how version is represented. So, I propose to introduce the following API. I think it can be extended introducing another argument IsSDK (or, simply SDK) so that we can retrieve SDK version components easily as well, without introducing new functions. Comments welcome.

Diff Detail

Event Timeline

davide updated this revision to Diff 32959.Aug 24 2015, 8:38 AM
davide retitled this revision from to [MachO] Introduce MinVersion API.
davide updated this object.
davide added reviewers: grosbach, rafael.
davide set the repository for this revision to rL LLVM.
davide added a subscriber: llvm-commits.
davide added a subscriber: davide.Aug 24 2015, 8:39 AM

+ Kevin Enderby (not on phab).

rafael edited edge metadata.Aug 24 2015, 4:44 PM

Can you include an example of it being used?

davide updated this revision to Diff 33072.Aug 25 2015, 6:50 AM
davide edited edge metadata.
davide removed rL LLVM as the repository for this revision.

-> Added usage example, as per Rafael request.
-> Modified the API a little bit.

rafael accepted this revision.Aug 25 2015, 7:13 AM
rafael edited edge metadata.

LGTM with a nit.

include/llvm/Object/MachO.h
347

These can be static, no?

This revision is now accepted and ready to land.Aug 25 2015, 7:13 AM
davide closed this revision.Aug 25 2015, 8:04 AM
grosbach edited edge metadata.Aug 25 2015, 9:57 AM

Would it be better for these function to be in the header since they're trivial accessors?

Sure. I want to point out that large part of the functions in
MachOObjectFile.cpp can be static'ized and moved to the header as they
are very similar to these one.
If nobody else takes care of this task -- I'll audit them and fix once
I'm done with macho-dump removal.