summaryrefslogtreecommitdiffstats
path: root/llvm/tools/yaml2obj/yaml2macho.cpp
diff options
context:
space:
mode:
authorSteven Wu <stevenwu@apple.com>2017-01-23 20:07:55 +0000
committerSteven Wu <stevenwu@apple.com>2017-01-23 20:07:55 +0000
commit5b54a42c0f1178dbb367866f92cd4efe88710bd6 (patch)
tree55464f3be2aa42cdf522652eb39e7969d85a5c24 /llvm/tools/yaml2obj/yaml2macho.cpp
parentcddeb751a11ce5771bedaa36f04775fb0aa56212 (diff)
downloadbcm5719-llvm-5b54a42c0f1178dbb367866f92cd4efe88710bd6.tar.gz
bcm5719-llvm-5b54a42c0f1178dbb367866f92cd4efe88710bd6.zip
Add LC_BUILD_VERSION load command
Summary: Add a new load command LC_BUILD_VERSION. It is a generic version of LC_*_VERSION_MIN load_command used on Apple platforms. Instead of having a seperate load command for each platform, LC_BUILD_VERSION is recording platform info as an enum. It also records SDK version, min_os, and tools that used to build the binary. rdar://problem/29781291 Reviewers: enderby Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D29044 llvm-svn: 292824
Diffstat (limited to 'llvm/tools/yaml2obj/yaml2macho.cpp')
-rw-r--r--llvm/tools/yaml2obj/yaml2macho.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/llvm/tools/yaml2obj/yaml2macho.cpp b/llvm/tools/yaml2obj/yaml2macho.cpp
index 6a27a7f64c0..92b736e5298 100644
--- a/llvm/tools/yaml2obj/yaml2macho.cpp
+++ b/llvm/tools/yaml2obj/yaml2macho.cpp
@@ -180,6 +180,21 @@ size_t writeLoadCommandData<MachO::rpath_command>(MachOYAML::LoadCommand &LC,
return writePayloadString(LC, OS);
}
+template <>
+size_t writeLoadCommandData<MachO::build_version_command>(
+ MachOYAML::LoadCommand &LC, raw_ostream &OS, bool IsLittleEndian) {
+ size_t BytesWritten = 0;
+ for (const auto &T : LC.Tools) {
+ struct MachO::build_tool_version tool = T;
+ if (IsLittleEndian != sys::IsLittleEndianHost)
+ MachO::swapStruct(tool);
+ OS.write(reinterpret_cast<const char *>(&tool),
+ sizeof(MachO::build_tool_version));
+ BytesWritten += sizeof(MachO::build_tool_version);
+ }
+ return BytesWritten;
+}
+
void ZeroFillBytes(raw_ostream &OS, size_t Size) {
std::vector<uint8_t> FillData;
FillData.insert(FillData.begin(), Size, 0);
OpenPOWER on IntegriCloud