Skip to content

Commit

Permalink
Correctly handle skewed streams in drop_front() method.
Browse files Browse the repository at this point in the history
When calling BinaryStreamArray::drop_front(), if the stream
is skewed it means we must never drop the first bytes of the
stream since offsets which occur in records assume the existence
of those bytes.  So if we want to skip the first record in a
stream, then what we really want to do is just set the begin
pointer to the next record.  But we shouldn't actually remove
those bytes from the underlying view of the data.

llvm-svn: 349066
  • Loading branch information
Zachary Turner committed Dec 13, 2018
1 parent 046d100 commit a05ae9d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion lld/COFF/PDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,10 @@ PDBLinker::mergeDebugT(ObjFile *File, CVIndexMap *ObjectIndexMap) {

// Drop LF_PRECOMP record from the input stream, as it needs to be replaced
// with the precompiled headers object type stream.
Types.drop_front();
// Note that we can't just call Types.drop_front(), as we explicitly want to
// rebase the stream.
Types.setUnderlyingStream(
Types.getUnderlyingStream().drop_front(FirstType->RecordData.size()));
}

// Fill in the temporary, caller-provided ObjectIndexMap.
Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/Support/BinaryStreamArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class VarStreamArray {
this->Skew = Skew;
}

void drop_front() { Stream = Stream.drop_front(begin()->length()); }
void drop_front() { Skew += begin()->length(); }

private:
BinaryStreamRef Stream;
Expand Down

0 comments on commit a05ae9d

Please sign in to comment.