OSDN Git Service

[CodeView] Fix cycles in debug info when merging Types with global hashes
authorAlexandre Ganea <alexandre.ganea@ubisoft.com>
Thu, 7 Feb 2019 15:24:18 +0000 (15:24 +0000)
committerAlexandre Ganea <alexandre.ganea@ubisoft.com>
Thu, 7 Feb 2019 15:24:18 +0000 (15:24 +0000)
commit29400a2fb2b2c72ede0da96a8c2908391151b71d
treebcbac77105ce35a1cb2563425b9f490006aa14f1
parentaae528ec39e1d5cb6da9794e349737c1a8df4472
[CodeView] Fix cycles in debug info when merging Types with global hashes

When type streams with forward references were merged using GHashes, cycles
were introduced in the debug info. This was caused by
GlobalTypeTableBuilder::insertRecordAs() not inserting the record on the second
pass, thus yielding an empty ArrayRef at that record slot. Later on, upon PDB
emission, TpiStreamBuilder::commit() would skip that empty record, thus
offseting all indices that came after in the stream.

This solution comes in two steps:

1. Fix the hash calculation, by doing a multiple-step resolution, iff there are
forward references in the input stream.
2. Fix merge by resolving with multiple passes, therefore moving records with
forward references at the end of the stream.

This patch also adds support for llvm-readoj --codeview-ghash.
Finally, fix dumpCodeViewMergedTypes() which previously could reference deleted
memory.

Fixes PR40221

Differential Revision: https://reviews.llvm.org/D57790

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@353412 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/DebugInfo/CodeView/GlobalTypeTableBuilder.h
include/llvm/DebugInfo/CodeView/TypeHashing.h
lib/DebugInfo/CodeView/TypeHashing.cpp
lib/DebugInfo/PDB/Native/TpiStreamBuilder.cpp
test/tools/llvm-readobj/codeview-merging-ghash.test [new file with mode: 0644]
tools/llvm-readobj/COFFDumper.cpp
tools/llvm-readobj/ObjDumper.h
tools/llvm-readobj/llvm-readobj.cpp