[LLD][COFF] Fix TypeServerSource matcher with more than one collision
[llvm-project.git] / lld / test / COFF / pdb-global-gc.yaml
blob5351ef545df87ced31f44bdcd69e6f2d897a313a
1 # REQUIRES: x86
2 # RUN: yaml2obj %s -o %t.obj
3 # RUN: llvm-mc %S/Inputs/pdb-global-gc.s -triple x86_64-windows-msvc -filetype=obj -o %t2.obj
4 # RUN: lld-link %t.obj %t2.obj -debug -entry:main \
5 # RUN:          -nodefaultlib -opt:ref -out:%t.exe -pdb:%t.pdb -verbose
6 # RUN: llvm-pdbutil dump -symbols -globals %t.pdb | FileCheck %s
8 # This tests the case where an __imp_ chunk is discarded by linker GC. The debug
9 # info may refer to the __imp_ symbol still.
11 # Compile this code with MSVC to regenerate the test case:
12 #   extern char __declspec(dllimport) __wc_mb_cur;
13 #   int discarded() { return __wc_mb_cur; }
14 #   int main() { return g2; }
16 # CHECK:                             Global Symbols
17 # CHECK-NEXT: ============================================================
18 # CHECK-NEXT:   Records
19 # CHECK-NEXT:       20 | S_GDATA32 [size = 28] `__wc_mb_cur`
20 # CHECK-NEXT:            type = 0x0070 (char), addr = 0000:0000
22 # CHECK:                                Symbols
23 # CHECK:      ============================================================
24 # CHECK-NEXT:   Mod 0000 | `{{.*}}pdb-global-gc.yaml.tmp.obj`:
25 # CHECK-NEXT:   Mod 0001 | `{{.*}}pdb-global-gc.yaml.tmp2.obj`:
26 # CHECK-NEXT:   Error loading module stream 1.  The specified stream could not be loaded. Module stream not present
27 # CHECK-NEXT:   Mod 0002 | `* Linker *`:
29 --- !COFF
30 header:
31   Machine:         IMAGE_FILE_MACHINE_AMD64
32   Characteristics: [  ]
33 sections:
34   - Name:            '.debug$S'
35     Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ]
36     Alignment:       1
37     Subsections:
38       - !Symbols
39         Records:
40           - Kind:            S_GDATA32
41             DataSym:
42               Type:            112
43               DisplayName:     __wc_mb_cur
44       - !StringTable
45         Strings:
46     Relocations:
47       - VirtualAddress:  20
48         SymbolName:      __wc_mb_cur
49         Type:            IMAGE_REL_AMD64_SECREL
50       - VirtualAddress:  24
51         SymbolName:      __wc_mb_cur
52         Type:            IMAGE_REL_AMD64_SECTION
53   - Name:            '.text$mn'
54     Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_LNK_COMDAT, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
55     Alignment:       16
56     SectionData:     0FBE0500000000C3
57     Relocations:
58       - VirtualAddress:  3
59         SymbolName:      __wc_mb_cur
60         Type:            IMAGE_REL_AMD64_REL32
61   - Name:            '.text$mn'
62     Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_LNK_COMDAT, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
63     Alignment:       16
64     SectionData:     B82A000000C3
65 symbols:
66   - Name:            '.debug$S'
67     Value:           0
68     SectionNumber:   1
69     SimpleType:      IMAGE_SYM_TYPE_NULL
70     ComplexType:     IMAGE_SYM_DTYPE_NULL
71     StorageClass:    IMAGE_SYM_CLASS_STATIC
72     SectionDefinition:
73       Length:          240
74       NumberOfRelocations: 2
75       NumberOfLinenumbers: 0
76       CheckSum:        0
77       Number:          0
78   - Name:            '.text$mn'
79     Value:           0
80     SectionNumber:   2
81     SimpleType:      IMAGE_SYM_TYPE_NULL
82     ComplexType:     IMAGE_SYM_DTYPE_NULL
83     StorageClass:    IMAGE_SYM_CLASS_STATIC
84     SectionDefinition:
85       Length:          11
86       NumberOfRelocations: 1
87       NumberOfLinenumbers: 0
88       CheckSum:        2906070869
89       Number:          0
90       Selection:       IMAGE_COMDAT_SELECT_NODUPLICATES
91   - Name:            '.text$mn'
92     Value:           0
93     SectionNumber:   3
94     SimpleType:      IMAGE_SYM_TYPE_NULL
95     ComplexType:     IMAGE_SYM_DTYPE_NULL
96     StorageClass:    IMAGE_SYM_CLASS_STATIC
97     SectionDefinition:
98       Length:          6
99       NumberOfRelocations: 0
100       NumberOfLinenumbers: 0
101       CheckSum:        2139436471
102       Number:          0
103       Selection:       IMAGE_COMDAT_SELECT_NODUPLICATES
104   - Name:            discarded
105     Value:           0
106     SectionNumber:   2
107     SimpleType:      IMAGE_SYM_TYPE_NULL
108     ComplexType:     IMAGE_SYM_DTYPE_FUNCTION
109     StorageClass:    IMAGE_SYM_CLASS_EXTERNAL
110   - Name:            main
111     Value:           0
112     SectionNumber:   3
113     SimpleType:      IMAGE_SYM_TYPE_NULL
114     ComplexType:     IMAGE_SYM_DTYPE_FUNCTION
115     StorageClass:    IMAGE_SYM_CLASS_EXTERNAL
116   - Name:            __wc_mb_cur
117     Value:           0
118     SectionNumber:   0
119     SimpleType:      IMAGE_SYM_TYPE_NULL
120     ComplexType:     IMAGE_SYM_DTYPE_NULL
121     StorageClass:    IMAGE_SYM_CLASS_EXTERNAL