From: Rafael Espindola Date: Fri, 18 Dec 2015 16:07:17 +0000 (+0000) Subject: Handle archives with paths in the names. X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=commitdiff_plain;h=ec08d99feee1ebbc5176d01e1c6cb021ade1eb37 Handle archives with paths in the names. We always create archives with just he filename as the member name, but other archives can put a more complicated path in there. This patches handles it by computing just the filename as we do when adding a new member. If storing the path is important for some reason, we should probably have an orthogonal option for doing that and do it for both old and new members. Fixes pr25877. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256001 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Object/ArchiveWriter.cpp b/lib/Object/ArchiveWriter.cpp index f207dfb0876..c7343fdc171 100644 --- a/lib/Object/ArchiveWriter.cpp +++ b/lib/Object/ArchiveWriter.cpp @@ -415,8 +415,10 @@ llvm::writeArchive(StringRef ArcName, ErrorOr Size = OldMember.getSize(); if (std::error_code EC = Size.getError()) return std::make_pair("", EC); - printMemberHeader(Out, Kind, Thin, I.getName(), StringMapIndexIter, - ModTime, UID, GID, Perms, Size.get()); + StringRef FileName = I.getName(); + printMemberHeader(Out, Kind, Thin, sys::path::filename(FileName), + StringMapIndexIter, ModTime, UID, GID, Perms, + Size.get()); } if (!Thin) diff --git a/test/Object/Inputs/pr25877.lib b/test/Object/Inputs/pr25877.lib new file mode 100644 index 00000000000..401cbeb172a Binary files /dev/null and b/test/Object/Inputs/pr25877.lib differ diff --git a/test/Object/pr25877.test b/test/Object/pr25877.test new file mode 100644 index 00000000000..c323d6259fa --- /dev/null +++ b/test/Object/pr25877.test @@ -0,0 +1,9 @@ +; RUN: echo create %t.a > %t.mri +; RUN: echo addlib %p/Inputs/pr25877.lib >> %t.mri +; RUN: echo save >> %t.mri +; RUN: echo end >> %t.mri + +; RUN: llvm-ar -M < %t.mri +; RUN: llvm-ar t %t.a | FileCheck %s + +; CHECK: foo.obj