summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
Diffstat (limited to 'llvm')
-rw-r--r--llvm/include/llvm/Object/Archive.h1
-rw-r--r--llvm/test/Object/archive-extract.test3
-rw-r--r--llvm/tools/llvm-ar/llvm-ar.cpp5
3 files changed, 9 insertions, 0 deletions
diff --git a/llvm/include/llvm/Object/Archive.h b/llvm/include/llvm/Object/Archive.h
index 0745eaf5c6e..e461564ace8 100644
--- a/llvm/include/llvm/Object/Archive.h
+++ b/llvm/include/llvm/Object/Archive.h
@@ -183,6 +183,7 @@ public:
};
Kind kind() const { return (Kind)Format; }
+ bool isThin() const { return IsThin; }
child_iterator child_begin(bool SkipInternal = true) const;
child_iterator child_end() const;
diff --git a/llvm/test/Object/archive-extract.test b/llvm/test/Object/archive-extract.test
index 606fc753c33..c1ddcf71725 100644
--- a/llvm/test/Object/archive-extract.test
+++ b/llvm/test/Object/archive-extract.test
@@ -45,3 +45,6 @@ CHECK: 1465 2004-11-19 03:01:31.000000000 very_long_bytecode_file_name.bc
RUN: not llvm-ar x %p/Inputs/GNU.a foo.o 2>&1 | FileCheck --check-prefix=NOTFOUND %s
NOTFOUND: foo.o was not found
+
+RUN: not llvm-ar x %p/Inputs/thin.a foo.o 2>&1 | FileCheck %s --check-prefix=THINEXTRACT
+THINEXTRACT: extracting from a thin archive is not supported
diff --git a/llvm/tools/llvm-ar/llvm-ar.cpp b/llvm/tools/llvm-ar/llvm-ar.cpp
index 50ddf598efe..c87606d7826 100644
--- a/llvm/tools/llvm-ar/llvm-ar.cpp
+++ b/llvm/tools/llvm-ar/llvm-ar.cpp
@@ -391,6 +391,11 @@ static bool shouldCreateArchive(ArchiveOperation Op) {
static void performReadOperation(ArchiveOperation Operation,
object::Archive *OldArchive) {
+ if (Operation == Extract && OldArchive->isThin()) {
+ errs() << "extracting from a thin archive is not supported\n";
+ std::exit(1);
+ }
+
bool Filter = !Members.empty();
for (const object::Archive::Child &C : OldArchive->children()) {
ErrorOr<StringRef> NameOrErr = C.getName();
OpenPOWER on IntegriCloud