[PATCH] D12282: [MachO] Introduce MinVersion API
Davide Italiano via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 24 08:38:26 PDT 2015
davide created this revision.
davide added reviewers: grosbach, rafael.
davide added a subscriber: llvm-commits.
davide set the repository for this revision to rL LLVM.
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.
Repository:
rL LLVM
http://reviews.llvm.org/D12282
Files:
include/llvm/Object/MachO.h
lib/Object/MachOObjectFile.cpp
Index: lib/Object/MachOObjectFile.cpp
===================================================================
--- lib/Object/MachOObjectFile.cpp
+++ lib/Object/MachOObjectFile.cpp
@@ -2001,6 +2001,21 @@
return getStruct<MachO::version_min_command>(this, L.Ptr);
}
+uint32_t
+MachOObjectFile::getVersionMinMajor(MachO::version_min_command &C) const {
+ return (C.version >> 16) & 0xffff;
+}
+
+uint32_t
+MachOObjectFile::getVersionMinMinor(MachO::version_min_command &C) const {
+ return (C.version >> 8) & 0xffff;
+}
+
+uint32_t
+MachOObjectFile::getVersionMinUpdate(MachO::version_min_command &C) const {
+ return C.version & 0xff;
+}
+
MachO::dylib_command
MachOObjectFile::getDylibIDLoadCommand(const LoadCommandInfo &L) const {
return getStruct<MachO::dylib_command>(this, L.Ptr);
Index: include/llvm/Object/MachO.h
===================================================================
--- include/llvm/Object/MachO.h
+++ include/llvm/Object/MachO.h
@@ -344,6 +344,12 @@
getLinkerOptionLoadCommand(const LoadCommandInfo &L) const;
MachO::version_min_command
getVersionMinLoadCommand(const LoadCommandInfo &L) const;
+ uint32_t
+ getVersionMinMajor(MachO::version_min_command &C) const;
+ uint32_t
+ getVersionMinMinor(MachO::version_min_command &C) const;
+ uint32_t
+ getVersionMinUpdate(MachO::version_min_command &C) const;
MachO::dylib_command
getDylibIDLoadCommand(const LoadCommandInfo &L) const;
MachO::dyld_info_command
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D12282.32959.patch
Type: text/x-patch
Size: 1464 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150824/01f742f8/attachment.bin>
More information about the llvm-commits
mailing list