[PATCH] D12282: [MachO] Introduce MinVersion API

Davide Italiano via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 24 08:39:23 PDT 2015


+ Kevin Enderby (not on phab).

On Mon, Aug 24, 2015 at 8:38 AM, Davide Italiano <dccitaliano at gmail.com> wrote:
> 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
>
>


More information about the llvm-commits mailing list