Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit f2343bd

Browse files
committed
Fix reading archive members with / in the name.
This is important for thin archives. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242082 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 045b217 commit f2343bd

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

lib/Object/Archive.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,10 @@ ErrorOr<StringRef> Archive::Child::getName() const {
162162
+ Parent->StringTable->getSize()))
163163
return object_error::parse_failed;
164164

165-
// GNU long file names end with a /.
165+
// GNU long file names end with a "/\n".
166166
if (Parent->kind() == K_GNU || Parent->kind() == K_MIPS64) {
167-
StringRef::size_type End = StringRef(addr).find('/');
168-
return StringRef(addr, End);
167+
StringRef::size_type End = StringRef(addr).find('\n');
168+
return StringRef(addr, End - 1);
169169
}
170170
return StringRef(addr);
171171
} else if (name.startswith("#1/")) {

test/Object/archive-toc.test

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,9 @@ THIN-NEXT: rw-r--r-- 1000/1000 2280 2014-12-16 00:56:27.000000000 IsNAN.o
3838
Test reading an archive with just a symbol table. We use to reject them.
3939
RUN: llvm-ar tv %p/Inputs/symtab-only.a | FileCheck --allow-empty --check-prefix=EMPTY %s
4040
EMPTY-NOT: {{.}}
41+
42+
Test reading a thin archive with directory names.
43+
RUN: env TZ=GMT llvm-ar tv %p/Inputs/thin-path.a | FileCheck %s --check-prefix=THINPATH -strict-whitespace
44+
45+
THINPATH: rw-r--r-- 0/0 1224 1970-01-01 00:00:00.000000000 test.o
46+
THINPATH-NEXT: rw-r--r-- 0/0 1224 1970-01-01 00:00:00.000000000 t/test2.o

0 commit comments

Comments
 (0)