From ec08d99feee1ebbc5176d01e1c6cb021ade1eb37 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Fri, 18 Dec 2015 16:07:17 +0000 Subject: [PATCH] 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 --- lib/Object/ArchiveWriter.cpp | 6 ++++-- test/Object/Inputs/pr25877.lib | Bin 0 -> 774 bytes test/Object/pr25877.test | 9 +++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 test/Object/Inputs/pr25877.lib create mode 100644 test/Object/pr25877.test 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 0000000000000000000000000000000000000000..401cbeb172a90e0c701299f608c5b79113fc175d GIT binary patch literal 774 zcmb7BOHRWu5FN*WkYU9M!UY_c=F^T6ZKw`@gSaivX z6$fC(v5S)~5F^h{A3S;zY&CaFmU@xU%EGHDN9QfZ_To;omB$ zQ_qEwuu=?At0(rCql@9M)~e7|bzjxX`BE>6sH|&QPi{d(JJ&7OYG!HT&RSflG(~T5 z<_zXy_IQZy0M5|piRl1jQ*0XB(?%ISyqVe%u5&rljqc&w-aH2NDktl858fLeh_~qq z9wTepW1`+z-gSAW$oa(eZMhtG;=SQc-d*`UT`z|Ne6}5Z>&Re!dOE?GJ13qNLEHPu z1H-|`t_Z=u=%pq{+{u`?gdoRDOkOx6A5_oq@=geHytH&zoKapnPn`DlN}OCV2q7@Z FegKyfRq+4- literal 0 HcmV?d00001 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 -- 2.34.1