[AIX] fixed llvm-ar can not read empty big archive correctly.
authorzhijian <zhijian@ca.ibm.com>
Mon, 16 May 2022 18:29:37 +0000 (14:29 -0400)
committerzhijian <zhijian@ca.ibm.com>
Mon, 16 May 2022 18:29:37 +0000 (14:29 -0400)
Summary:

llvm-ar can not read empty big archive correctly. it output error as
error: unable to load 'empty.a': truncated or malformed archive (characters in size field in archive member header are not all decimal numbers: '<bigaf>'

Reviewers: James Henderson
Differential Revision: https://reviews.llvm.org/D124017

llvm/include/llvm/Object/Archive.h
llvm/test/tools/llvm-ar/display-empty.test
llvm/test/tools/llvm-ar/full-path-option.test
llvm/test/tools/llvm-ar/quick-append.test
llvm/test/tools/llvm-lipo/create-archive-input.test
llvm/test/tools/llvm-size/archive.test

index a6e336b..1f4a274 100644 (file)
@@ -359,7 +359,7 @@ public:
   // check if a symbol is in the archive
   Expected<Optional<Child>> findSym(StringRef name) const;
 
-  bool isEmpty() const;
+  virtual bool isEmpty() const;
   bool hasSymbolTable() const;
   StringRef getSymbolTable() const { return SymbolTable; }
   StringRef getStringTable() const { return StringTable; }
@@ -412,6 +412,9 @@ public:
   BigArchive(MemoryBufferRef Source, Error &Err);
   uint64_t getFirstChildOffset() const override { return FirstChildOffset; }
   uint64_t getLastChildOffset() const { return LastChildOffset; }
+  bool isEmpty() const override {
+    return Data.getBufferSize() == sizeof(FixLenHdr);
+  };
 };
 
 } // end namespace object
index ba04e0e..22310c8 100644 (file)
@@ -3,7 +3,7 @@
 # RUN: rm -rf %t && mkdir -p %t
 
 ## Display empty archive:
-# RUN: llvm-ar cr --format=gnu %t/empty.a
+# RUN: llvm-ar cr %t/empty.a
 # RUN: llvm-ar tv %t/empty.a 2>&1 | count 0
 
 ## Display empty thin archive:
index 3f1a6d9..2ed7b76 100644 (file)
@@ -27,7 +27,7 @@ DISPLAY-NOT-FOUND: 'a/foo.txt' was not found
 
 # Deleting will fail with P because the members exist as foo.txt, not a/foo.txt.
 RUN: rm -f del1.a
-RUN: llvm-ar rcS --format=gnu del1.a foo.txt
+RUN: llvm-ar rcS del1.a foo.txt
 RUN: llvm-ar dP del1.a a/foo.txt
 RUN: llvm-ar t del1.a a/foo.txt | FileCheck %s --check-prefix=DISPLAY-FOUND --match-full-lines
 RUN: llvm-ar d del1.a a/foo.txt
index a589c5d..60c3508 100644 (file)
@@ -1,4 +1,3 @@
-# XFAIL: system-aix
 ## Test quick append 
 
 # RUN: rm -rf %t && mkdir -p %t
index a1c7321..5558797 100644 (file)
@@ -4,7 +4,7 @@
 # RUN: llvm-as %p/Inputs/armv7-ios.ll -o %t-ir-armv7.o
 # RUN: llvm-as %p/Inputs/x64-osx.ll -o %t-ir-x86_64.o
 
-# RUN: llvm-ar cr --format=gnu %t.empty.a
+# RUN: llvm-ar cr %t.empty.a
 # RUN: not llvm-lipo %t.empty.a -create -output /dev/null 2>&1 | FileCheck --check-prefix=EMPTY-ARCHIVE %s
 
 # RUN: llvm-ar cr %t.different_architectures.a %t-i386.o %t-x86_64.o
index b404e0e..23c4cd1 100644 (file)
@@ -5,7 +5,7 @@
 
 ## Case 1: Empty archive. No output expected.
 # RUN: rm -f %t1.a
-# RUN: llvm-ar rc --format=gnu %t1.a
+# RUN: llvm-ar rc %t1.a
 
 # RUN: llvm-size -B %t1.a | count 0
 # RUN: llvm-size -A %t1.a | count 0