Skip to content

Commit 09a3aef

Browse files
committed
Revert "[AIX][BigArchive] Treat the archive is empty if the first child member offset is zero"
This reverts commit 7f0003c. Reason: This broke the ASan buildbot, see the comments in https://reviews.llvm.org/D138986 for more information.
1 parent 934650b commit 09a3aef

File tree

4 files changed

+6
-19
lines changed

4 files changed

+6
-19
lines changed

llvm/include/llvm/Object/Archive.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,9 @@ class BigArchive : public Archive {
410410
BigArchive(MemoryBufferRef Source, Error &Err);
411411
uint64_t getFirstChildOffset() const override { return FirstChildOffset; }
412412
uint64_t getLastChildOffset() const { return LastChildOffset; }
413-
bool isEmpty() const override { return getFirstChildOffset() == 0; }
413+
bool isEmpty() const override {
414+
return Data.getBufferSize() == sizeof(FixLenHdr);
415+
};
414416
};
415417

416418
} // end namespace object

llvm/lib/Object/Archive.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -949,15 +949,7 @@ Archive::child_iterator Archive::child_begin(Error &Err,
949949
return child_iterator::itr(
950950
Child(this, FirstRegularData, FirstRegularStartOfFile), Err);
951951

952-
uint64_t FirstChildOffset = getFirstChildOffset();
953-
const char *Loc = Data.getBufferStart() + FirstChildOffset;
954-
if (Loc >= Data.getBufferEnd()) {
955-
Err = malformedError("First member offset " + Twine(FirstChildOffset) +
956-
" is beyond the data buffer which has size of " +
957-
Twine(Data.getBufferSize()));
958-
return child_end();
959-
}
960-
952+
const char *Loc = Data.getBufferStart() + getFirstChildOffset();
961953
Child C(this, Loc, &Err);
962954
if (Err)
963955
return child_end();

llvm/test/Object/archive-big-malformed-first-member.test

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Test reading an empty archive with free list in it.
2-
# RUN: llvm-ar tv %p/Inputs/aix-empty-big-archive-with-freelist.a 2>&1 \
3-
# RUN: | not grep 'truncated or malformed archive'
2+
# RUN: not llvm-ar tv %p/Inputs/aix-empty-big-archive-with-freelist.a 2>&1 \
3+
# RUN: | grep 'truncated or malformed archive'

0 commit comments

Comments
 (0)