Files
clang-p2996/llvm/test/tools/llvm-readobj/codeview-merging-ghash.test
Alexandre Ganea 120366edc7 [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 

llvm-svn: 353412
2019-02-07 15:24:18 +00:00

133 lines
4.5 KiB
Plaintext

# RUN: yaml2obj %s -o=%t.obj
# RUN: llvm-readobj -codeview-merged-types %t.obj | FileCheck %s --check-prefix=MERGED
# RUN: llvm-readobj -codeview-merged-types -codeview-ghash %t.obj | FileCheck %s --check-prefix=MERGED
# MERGED: Format: COFF-x86-64
# MERGED-NEXT: Arch: x86_64
# MERGED-NEXT: AddressSize: 64bit
# MERGED-NEXT: MergedTypeStream [
# MERGED-NEXT: ArgList (0x1000) {
# MERGED-NEXT: TypeLeafKind: LF_ARGLIST (0x1201)
# MERGED-NEXT: NumArgs: 0
# MERGED-NEXT: Arguments [
# MERGED-NEXT: ]
# MERGED-NEXT: }
# MERGED-NEXT: Modifier (0x1001) {
# MERGED-NEXT: TypeLeafKind: LF_MODIFIER (0x1001)
# MERGED-NEXT: ModifiedType: void (0x3)
# MERGED-NEXT: Modifiers [ (0x3)
# MERGED-NEXT: Const (0x1)
# MERGED-NEXT: Volatile (0x2)
# MERGED-NEXT: ]
# MERGED-NEXT: }
# MERGED-NEXT: Procedure (0x1002) {
# MERGED-NEXT: TypeLeafKind: LF_PROCEDURE (0x1008)
# MERGED-NEXT: ReturnType: void (0x3)
# MERGED-NEXT: CallingConvention: NearC (0x0)
# MERGED-NEXT: FunctionOptions [ (0x0)
# MERGED-NEXT: ]
# MERGED-NEXT: NumParameters: 0
# MERGED-NEXT: ArgListType: () (0x1000)
# MERGED-NEXT: }
# MERGED-NEXT: Pointer (0x1003) {
# MERGED-NEXT: TypeLeafKind: LF_POINTER (0x1002)
# MERGED-NEXT: PointeeType: const volatile void (0x1001)
# MERGED-NEXT: PtrType: Near64 (0xC)
# MERGED-NEXT: PtrMode: Pointer (0x0)
# MERGED-NEXT: IsFlat: 0
# MERGED-NEXT: IsConst: 1
# MERGED-NEXT: IsVolatile: 0
# MERGED-NEXT: IsUnaligned: 0
# MERGED-NEXT: IsRestrict: 0
# MERGED-NEXT: IsThisPtr&: 0
# MERGED-NEXT: IsThisPtr&&: 0
# MERGED-NEXT: SizeOf: 8
# MERGED-NEXT: }
# MERGED-NEXT: Pointer (0x1004) {
# MERGED-NEXT: TypeLeafKind: LF_POINTER (0x1002)
# MERGED-NEXT: PointeeType: const volatile void* const (0x1003)
# MERGED-NEXT: PtrType: Near64 (0xC)
# MERGED-NEXT: PtrMode: Pointer (0x0)
# MERGED-NEXT: IsFlat: 0
# MERGED-NEXT: IsConst: 1
# MERGED-NEXT: IsVolatile: 0
# MERGED-NEXT: IsUnaligned: 0
# MERGED-NEXT: IsRestrict: 0
# MERGED-NEXT: IsThisPtr&: 0
# MERGED-NEXT: IsThisPtr&&: 0
# MERGED-NEXT: SizeOf: 8
# MERGED-NEXT: }
# MERGED-NEXT: Pointer (0x1005) {
# MERGED-NEXT: TypeLeafKind: LF_POINTER (0x1002)
# MERGED-NEXT: PointeeType: const volatile void* const* const (0x1004)
# MERGED-NEXT: PtrType: Near64 (0xC)
# MERGED-NEXT: PtrMode: Pointer (0x0)
# MERGED-NEXT: IsFlat: 0
# MERGED-NEXT: IsConst: 1
# MERGED-NEXT: IsVolatile: 0
# MERGED-NEXT: IsUnaligned: 0
# MERGED-NEXT: IsRestrict: 0
# MERGED-NEXT: IsThisPtr&: 0
# MERGED-NEXT: IsThisPtr&&: 0
# MERGED-NEXT: SizeOf: 8
# MERGED-NEXT: }
# MERGED-NEXT: Pointer (0x1006) {
# MERGED-NEXT: TypeLeafKind: LF_POINTER (0x1002)
# MERGED-NEXT: PointeeType: const volatile void* const* const* const (0x1005)
# MERGED-NEXT: PtrType: Near64 (0xC)
# MERGED-NEXT: PtrMode: Pointer (0x0)
# MERGED-NEXT: IsFlat: 0
# MERGED-NEXT: IsConst: 1
# MERGED-NEXT: IsVolatile: 0
# MERGED-NEXT: IsUnaligned: 0
# MERGED-NEXT: IsRestrict: 0
# MERGED-NEXT: IsThisPtr&: 0
# MERGED-NEXT: IsThisPtr&&: 0
# MERGED-NEXT: SizeOf: 8
# MERGED-NEXT: }
# MERGED-NEXT: ]
# MERGED-NEXT: MergedIDStream [
# MERGED-NEXT: ]
--- !COFF
header:
Machine: IMAGE_FILE_MACHINE_AMD64
Characteristics: [ ]
sections:
- Name: '.debug$T'
Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ]
Alignment: 1
Types:
- Kind: LF_PROCEDURE
Procedure:
ReturnType: 3
CallConv: NearC
Options: [ None ]
ParameterCount: 0
ArgumentList: 4097
- Kind: LF_ARGLIST
ArgList:
ArgIndices: [ ]
- Kind: LF_POINTER
Pointer:
ReferentType: 4099
Attrs: 66572
- Kind: LF_POINTER
Pointer:
ReferentType: 4100
Attrs: 66572
- Kind: LF_POINTER
Pointer:
ReferentType: 4101
Attrs: 66572
- Kind: LF_MODIFIER
Modifier:
ModifiedType: 3
Modifiers: [ None, Const, Volatile ]
- Kind: LF_POINTER
Pointer:
ReferentType: 4098
Attrs: 66572
symbols:
...