diff options
author | David Callahan <dcallahan@fb.com> | 2016-11-30 22:32:58 +0000 |
---|---|---|
committer | David Callahan <dcallahan@fb.com> | 2016-11-30 22:32:58 +0000 |
commit | 5cb34077e879c03d460dedad7aaa421bd2bd08a3 (patch) | |
tree | d3677f3af106f0e2c59bd218bf6cb51d4a953d11 /llvm/lib/Object/ArchiveWriter.cpp | |
parent | 75818bc8f76b317ae79fdf69428ee6a2e1630fb2 (diff) | |
download | llvm-5cb34077e879c03d460dedad7aaa421bd2bd08a3.zip llvm-5cb34077e879c03d460dedad7aaa421bd2bd08a3.tar.gz llvm-5cb34077e879c03d460dedad7aaa421bd2bd08a3.tar.bz2 |
Only computeRelativePath() on new members
Summary:
When using thin archives, and processing the same archive multiple times, we were mangling existing entries. The root cause is that we were calling computeRelativePath() more than once. Here, we only call it when adding new members to an archive.
Note that D27218 changes the way thin archives are printed, and will break the new unit test included here. Depending on which one lands first, the other will need to be slightly modified.
Reviewers: rafael, davide
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D27217
llvm-svn: 288280
Diffstat (limited to 'llvm/lib/Object/ArchiveWriter.cpp')
-rw-r--r-- | llvm/lib/Object/ArchiveWriter.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/llvm/lib/Object/ArchiveWriter.cpp b/llvm/lib/Object/ArchiveWriter.cpp index 64d04a0..f8e3c5a 100644 --- a/llvm/lib/Object/ArchiveWriter.cpp +++ b/llvm/lib/Object/ArchiveWriter.cpp @@ -45,6 +45,7 @@ NewArchiveMember::getOldMember(const object::Archive::Child &OldMember, return BufOrErr.takeError(); NewArchiveMember M; + assert(M.IsNew == false); M.Buf = MemoryBuffer::getMemBuffer(*BufOrErr, false); if (!Deterministic) { auto ModTimeOrErr = OldMember.getLastModified(); @@ -93,6 +94,7 @@ Expected<NewArchiveMember> NewArchiveMember::getFile(StringRef FileName, return errorCodeToError(std::error_code(errno, std::generic_category())); NewArchiveMember M; + M.IsNew = true; M.Buf = std::move(*MemberBufferOrErr); if (!Deterministic) { M.ModTime = std::chrono::time_point_cast<std::chrono::seconds>( @@ -231,9 +233,12 @@ static void writeStringTable(raw_fd_ostream &Out, StringRef ArcName, } StringMapIndexes.push_back(Out.tell() - StartOffset); - if (Thin) - Out << computeRelativePath(ArcName, Path); - else + if (Thin) { + if (M.IsNew) + Out << computeRelativePath(ArcName, Path); + else + Out << M.Buf->getBufferIdentifier(); + } else Out << Name; Out << "/\n"; |