From 167af8c16c958aaea6d7cc48b791ea2bcc4dea8e Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Wed, 15 Jul 2015 23:15:33 +0000 Subject: [PATCH] llvm-ar: Don't write the directory in the string table. We were already doing the right thing for short file names, but not long ones. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242354 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Object/ArchiveWriter.cpp | 2 +- test/Object/archive-format.test | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/Object/ArchiveWriter.cpp b/lib/Object/ArchiveWriter.cpp index bd372c37b8f..fd06c6e8687 100644 --- a/lib/Object/ArchiveWriter.cpp +++ b/lib/Object/ArchiveWriter.cpp @@ -160,7 +160,7 @@ static void writeStringTable(raw_fd_ostream &Out, bool Thin) { unsigned StartOffset = 0; for (const NewArchiveIterator &I : Members) { - StringRef Name = I.getName(); + StringRef Name = sys::path::filename(I.getName()); if (!useStringTable(Thin, Name)) continue; if (StartOffset == 0) { diff --git a/test/Object/archive-format.test b/test/Object/archive-format.test index 376eb053c6d..e40ec332734 100644 --- a/test/Object/archive-format.test +++ b/test/Object/archive-format.test @@ -6,17 +6,26 @@ RUN: cd %t RUN: echo -n bar. > 0123456789abcde RUN: echo -n zed. > 0123456789abcdef +RUN: mkdir -p foo +RUN: echo -n bar2 > foo/0123456789abcde +RUN: echo -n zed2 > foo/0123456789abcdef RUN: rm -f %t.a -RUN: llvm-ar --format=gnu rc %t.a 0123456789abcde 0123456789abcdef +RUN: llvm-ar --format=gnu rc %t.a 0123456789abcde 0123456789abcdef foo/0123456789abcde foo/0123456789abcdef RUN: cat %t.a | FileCheck -strict-whitespace %s CHECK: ! -CHECK-NEXT: // 18 ` +CHECK-NEXT: // 36 ` +CHECK-NEXT: 0123456789abcdef/ CHECK-NEXT: 0123456789abcdef/ CHECK-NEXT: 0123456789abcde/0 0 0 644 4 ` -CHECK-NEXT: bar./0 0 0 0 644 4 ` +CHECK-NEXT: bar. +CHECK-SAME: /0 0 0 0 644 4 ` CHECK-NEXT: zed. +CHECK-SAME: 0123456789abcde/0 0 0 644 4 ` +CHECK-NEXT: bar2 +CHECK-SAME: /18 0 0 0 644 4 ` +CHECK-NEXT: zed2 RUN: rm -f %t.a RUN: llvm-ar --format=bsd rc %t.a 0123456789abcde 0123456789abcdef