Skip to content

Commit

Permalink
Revert "[AIX][BigArchive] Treat the archive is empty if the first chi…
Browse files Browse the repository at this point in the history
…ld 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.
  • Loading branch information
hctim committed Jan 30, 2023
1 parent 934650b commit 09a3aef
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 19 deletions.
4 changes: 3 additions & 1 deletion llvm/include/llvm/Object/Archive.h
Expand Up @@ -410,7 +410,9 @@ class BigArchive : public Archive {
BigArchive(MemoryBufferRef Source, Error &Err);
uint64_t getFirstChildOffset() const override { return FirstChildOffset; }
uint64_t getLastChildOffset() const { return LastChildOffset; }
bool isEmpty() const override { return getFirstChildOffset() == 0; }
bool isEmpty() const override {
return Data.getBufferSize() == sizeof(FixLenHdr);
};
};

} // end namespace object
Expand Down
10 changes: 1 addition & 9 deletions llvm/lib/Object/Archive.cpp
Expand Up @@ -949,15 +949,7 @@ Archive::child_iterator Archive::child_begin(Error &Err,
return child_iterator::itr(
Child(this, FirstRegularData, FirstRegularStartOfFile), Err);

uint64_t FirstChildOffset = getFirstChildOffset();
const char *Loc = Data.getBufferStart() + FirstChildOffset;
if (Loc >= Data.getBufferEnd()) {
Err = malformedError("First member offset " + Twine(FirstChildOffset) +
" is beyond the data buffer which has size of " +
Twine(Data.getBufferSize()));
return child_end();
}

const char *Loc = Data.getBufferStart() + getFirstChildOffset();
Child C(this, Loc, &Err);
if (Err)
return child_end();
Expand Down
7 changes: 0 additions & 7 deletions llvm/test/Object/archive-big-malformed-first-member.test

This file was deleted.

4 changes: 2 additions & 2 deletions llvm/test/Object/archive-big-read-empty-with-freelist.test
@@ -1,3 +1,3 @@
# Test reading an empty archive with free list in it.
# RUN: llvm-ar tv %p/Inputs/aix-empty-big-archive-with-freelist.a 2>&1 \
# RUN: | not grep 'truncated or malformed archive'
# RUN: not llvm-ar tv %p/Inputs/aix-empty-big-archive-with-freelist.a 2>&1 \
# RUN: | grep 'truncated or malformed archive'

0 comments on commit 09a3aef

Please sign in to comment.