diff options
author | Pete Cooper <peter_cooper@apple.com> | 2016-02-04 02:45:23 +0000 |
---|---|---|
committer | Pete Cooper <peter_cooper@apple.com> | 2016-02-04 02:45:23 +0000 |
commit | 40576fa0e924f8f6e56cf09ac19e76379720b6c7 (patch) | |
tree | fe8739dfc470c85e5ea3cf326da2d785666af5d2 /lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp | |
parent | 0e05d6eb9c50728c73f4386dce31b7b582f7e941 (diff) | |
download | bcm5719-llvm-40576fa0e924f8f6e56cf09ac19e76379720b6c7.tar.gz bcm5719-llvm-40576fa0e924f8f6e56cf09ac19e76379720b6c7.zip |
Add support for the source_version cmdline option.
This is of the form A.B.C.D.E and to match ld64's behaviour, is
always output to files, even when the version is 0.
rdar://problem/24472630
llvm-svn: 259746
Diffstat (limited to 'lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp')
-rw-r--r-- | lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp b/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp index 0eb2b11eaaa..4e303dd8b97 100644 --- a/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp +++ b/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp @@ -467,6 +467,10 @@ uint32_t MachOFileLayout::loadCommandsSize(uint32_t &count) { ++count; } + // Add LC_SOURCE_VERSION + size += sizeof(source_version_command); + ++count; + // If main executable add LC_MAIN if (_file.fileType == llvm::MachO::MH_EXECUTE) { size += sizeof(entry_point_command); @@ -915,6 +919,17 @@ std::error_code MachOFileLayout::writeLoadCommands() { // LC_VERSION_MIN_TVOS writeVersionMinLoadCommand(_file, _swap, lc); + // Add LC_SOURCE_VERSION + { + source_version_command* sv = reinterpret_cast<source_version_command*>(lc); + sv->cmd = LC_SOURCE_VERSION; + sv->cmdsize = sizeof(source_version_command); + sv->version = _file.sourceVersion; + if (_swap) + swapStruct(*sv); + lc += sizeof(source_version_command); + } + // If main executable, add LC_MAIN. if (_file.fileType == llvm::MachO::MH_EXECUTE) { // Build LC_MAIN load command. |