1 Make a DLL that exports a few functions, then make a DLL with PDBs that imports
2 them. Check that the __imp_ pointer and the generated thunks appear in the
5 RUN: yaml2obj %p/Inputs/export.yaml -o %t1.obj
6 RUN: lld-link /out:%t1.dll /dll %t1.obj /implib:%t1.lib \
7 RUN: /export:exportfn1 /export:exportfn2
8 RUN: yaml2obj %p/Inputs/import.yaml -o %t2.obj
9 RUN: lld-link /out:%t2.exe /pdb:%t2.pdb /pdbaltpath:test.pdb \
10 RUN: /debug /entry:main %t2.obj %t1.lib
11 RUN: llvm-pdbutil dump %t2.pdb -all | FileCheck %s
14 CHECK-NEXT: ============================================================
15 CHECK-LABEL: Stream 10 ( 256 bytes): [Module "Import:pdb-publics-import.test.tmp1.dll"]
18 CHECK-NEXT: ============================================================
19 CHECK-NEXT: Mod 0000 | `{{.*}}pdb-publics-import.test.tmp2.obj`:
20 CHECK-NEXT: Mod 0 (debug info not present): [{{.*}}pdb-publics-import.test.tmp2.obj]
21 CHECK-NEXT: Mod 0001 | `pdb-publics-import.test.tmp1.dll`:
22 CHECK-NEXT: Mod 1 (debug info not present): [pdb-publics-import.test.tmp1.dll]
23 CHECK-NEXT: Mod 0002 | `Import:pdb-publics-import.test.tmp1.dll`:
24 CHECK-NEXT: Stream 10, 256 bytes
27 CHECK-NEXT: ============================================================
28 CHECK-NEXT: Mod 0000 | `{{.*}}pdb-publics-import.test.tmp2.obj`:
29 CHECK-NEXT: SC[.text] | mod = 0, 0001:0000, size = 8, data crc = 0, reloc crc = 0
30 CHECK-NEXT: IMAGE_SCN_CNT_CODE | IMAGE_SCN_ALIGN_4BYTES | IMAGE_SCN_MEM_EXECUTE |
31 CHECK-NEXT: IMAGE_SCN_MEM_READ
32 CHECK-NEXT: Obj: `{{.*}}pdb-publics-import.test.tmp2.obj`:
33 CHECK-NEXT: debug stream: 65535, # files: 0, has ec info: false
34 CHECK-NEXT: pdb file ni: 0 ``, src file ni: 0 ``
35 CHECK-NEXT: Mod 0001 | `pdb-publics-import.test.tmp1.dll`:
36 CHECK-NEXT: SC[???] | mod = 65535, 65535:0000, size = -1, data crc = 0, reloc crc = 0
38 CHECK-NEXT: Obj: `{{.*}}pdb-publics-import.test.tmp1.lib`:
39 CHECK-NEXT: debug stream: 65535, # files: 0, has ec info: false
40 CHECK-NEXT: pdb file ni: 0 ``, src file ni: 0 ``
41 CHECK-NEXT: Mod 0002 | `Import:pdb-publics-import.test.tmp1.dll`:
42 CHECK-NEXT: SC[.text] | mod = 2, 0001:0032, size = 6, data crc = 0, reloc crc = 0
43 CHECK-NEXT: IMAGE_SCN_CNT_CODE | IMAGE_SCN_MEM_EXECUTE | IMAGE_SCN_MEM_READ
44 CHECK-NEXT: Obj: `{{.*}}pdb-publics-import.test.tmp1.lib`:
45 CHECK-NEXT: debug stream: 10, # files: 0, has ec info: false
46 CHECK-NEXT: pdb file ni: 0 ``, src file ni: 0 ``
47 CHECK-NEXT: Mod 0003 | `* Linker *`:
48 CHECK-NEXT: SC[???] | mod = 65535, 65535:0000, size = -1, data crc = 0, reloc crc = 0
51 CHECK-NEXT: debug stream: 11, # files: 0, has ec info: false
52 CHECK-NEXT: pdb file ni: 1 `{{.*}}pdb-publics-import.test.tmp2.pdb`, src file ni: 0 ``
55 CHECK-NEXT: ============================================================
57 CHECK-NEXT: 112 | S_PUB32 [size = 20] `main`
58 CHECK-NEXT: flags = function, addr = 0001:0000
59 CHECK-NEXT: 64 | S_PUB32 [size = 24] `exportfn1`
60 CHECK-NEXT: flags = function, addr = 0001:0016
61 CHECK-NEXT: 88 | S_PUB32 [size = 24] `exportfn2`
62 CHECK-NEXT: flags = function, addr = 0001:0032
63 CHECK-NEXT: 32 | S_PUB32 [size = 32] `__imp_exportfn2`
64 CHECK-NEXT: flags = none, addr = 0002:0136
65 CHECK-NEXT: 0 | S_PUB32 [size = 32] `__imp_exportfn1`
66 CHECK-NEXT: flags = none, addr = 0002:0128
69 CHECK-NEXT: ============================================================
70 CHECK-NEXT: Mod 0000 | `{{.*}}pdb-publics-import.test.tmp2.obj`:
71 CHECK-NEXT: Error loading module stream 0. The specified stream could not be loaded. Module stream not present
72 CHECK-NEXT: Mod 0001 | `pdb-publics-import.test.tmp1.dll`:
73 CHECK-NEXT: Error loading module stream 1. The specified stream could not be loaded. Module stream not present
74 CHECK-NEXT: Mod 0002 | `Import:pdb-publics-import.test.tmp1.dll`:
75 CHECK-NEXT: 4 | S_OBJNAME [size = 44] sig=0, `pdb-publics-import.test.tmp1.dll`
76 CHECK-NEXT: 48 | S_COMPILE3 [size = 40]
77 CHECK-NEXT: machine = intel x86-x64, Ver = LLVM Linker, language = link
78 CHECK-NEXT: frontend = 0.0.0.0, backend = 14.10.25019.0
79 CHECK-NEXT: flags = none
80 CHECK-NEXT: 88 | S_THUNK32 [size = 36] `exportfn1`
81 CHECK-NEXT: parent = 0, end = 124, next = 0
82 CHECK-NEXT: kind = thunk, size = 6, addr = 0001:0016
83 CHECK-NEXT: 124 | S_END [size = 4]
84 CHECK-NEXT: 128 | S_OBJNAME [size = 44] sig=0, `pdb-publics-import.test.tmp1.dll`
85 CHECK-NEXT: 172 | S_COMPILE3 [size = 40]
86 CHECK-NEXT: machine = intel x86-x64, Ver = LLVM Linker, language = link
87 CHECK-NEXT: frontend = 0.0.0.0, backend = 14.10.25019.0
88 CHECK-NEXT: flags = none
89 CHECK-NEXT: 212 | S_THUNK32 [size = 36] `exportfn2`
90 CHECK-NEXT: parent = 0, end = 248, next = 0
91 CHECK-NEXT: kind = thunk, size = 6, addr = 0001:0032
92 CHECK-NEXT: 248 | S_END [size = 4]
93 CHECK-NEXT: Mod 0003 | `* Linker *`:
94 CHECK-NEXT: 4 | S_OBJNAME [size = 20] sig=0, `* Linker *`
95 CHECK-NEXT: 24 | S_COMPILE3 [size = 40]
96 CHECK-NEXT: machine = intel x86-x64, Ver = LLVM Linker, language = link
97 CHECK-NEXT: frontend = 0.0.0.0, backend = 14.10.25019.0
98 CHECK-NEXT: flags = none
99 CHECK-NEXT: 64 | S_ENVBLOCK [size = {{[0-9]+}}]
100 CHECK: {{[0-9]+}} | S_SECTION [size = 28] `.text`
101 CHECK-NEXT: length = 38, alignment = 12, rva = 4096, section # = 1
102 CHECK-NEXT: characteristics =
104 CHECK-NEXT: execute permissions
105 CHECK-NEXT: read permissions
106 CHECK-NEXT: {{[0-9]+}} | S_COFFGROUP [size = 24] `.text`
107 CHECK-NEXT: length = 8, addr = 0001:0000
108 CHECK-NEXT: characteristics =
110 CHECK-NEXT: execute permissions
111 CHECK-NEXT: read permissions
112 CHECK-NEXT: {{[0-9]+}} | S_SECTION [size = 28] `.rdata`
113 CHECK-NEXT: length = 209, alignment = 12, rva = 8192, section # = 2
114 CHECK-NEXT: characteristics =
115 CHECK-NEXT: initialized data
116 CHECK-NEXT: read permissions
117 CHECK-NEXT: {{[0-9]+}} | S_COFFGROUP [size = 28] `.idata$2`
118 CHECK-NEXT: length = 40, addr = 0002:0061
119 CHECK-NEXT: characteristics =
120 CHECK-NEXT: initialized data
121 CHECK-NEXT: read permissions
122 CHECK-NEXT: write permissions
123 CHECK-NEXT: {{[0-9]+}} | S_COFFGROUP [size = 28] `.idata$4`
124 CHECK-NEXT: length = 24, addr = 0002:0104
125 CHECK-NEXT: characteristics =
126 CHECK-NEXT: initialized data
127 CHECK-NEXT: read permissions
128 CHECK-NEXT: write permissions
129 CHECK-NEXT: {{[0-9]+}} | S_COFFGROUP [size = 28] `.idata$5`
130 CHECK-NEXT: length = 24, addr = 0002:0128
131 CHECK-NEXT: characteristics =
132 CHECK-NEXT: initialized data
133 CHECK-NEXT: read permissions
134 CHECK-NEXT: write permissions
135 CHECK-NEXT: {{[0-9]+}} | S_COFFGROUP [size = 28] `.idata$6`
136 CHECK-NEXT: length = 24, addr = 0002:0152
137 CHECK-NEXT: characteristics =
138 CHECK-NEXT: initialized data
139 CHECK-NEXT: read permissions
140 CHECK-NEXT: write permissions
141 CHECK-NEXT: {{[0-9]+}} | S_COFFGROUP [size = 28] `.idata$7`
142 CHECK-NEXT: length = 33, addr = 0002:0176
143 CHECK-NEXT: characteristics =
144 CHECK-NEXT: initialized data
145 CHECK-NEXT: read permissions
146 CHECK-NEXT: write permissions
148 CHECK: Section Contributions
149 CHECK-NEXT: ============================================================
151 CHECK-NEXT: SC[.text] | mod = 0, 0001:0000, size = 8, data crc = 0, reloc crc = 0
152 CHECK-NEXT: IMAGE_SCN_CNT_CODE | IMAGE_SCN_ALIGN_4BYTES | IMAGE_SCN_MEM_EXECUTE |
153 CHECK-NEXT: IMAGE_SCN_MEM_READ
155 CHECK-NEXT: SC[.text] | mod = 3, 0001:0016, size = 6, data crc = 0, reloc crc = 0
156 CHECK-NEXT: IMAGE_SCN_CNT_CODE | IMAGE_SCN_MEM_EXECUTE | IMAGE_SCN_MEM_READ
158 CHECK-NEXT: SC[.text] | mod = 3, 0001:0032, size = 6, data crc = 0, reloc crc = 0
159 CHECK-NEXT: IMAGE_SCN_CNT_CODE | IMAGE_SCN_MEM_EXECUTE | IMAGE_SCN_MEM_READ
160 .rdata debug directory data chunks
161 CHECK-NEXT: SC[.rdata] | mod = 3, 0002:0000, size = 28, data crc = 0, reloc crc = 0
162 CHECK-NEXT: IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ
163 CHECK-NEXT: SC[.rdata] | mod = 3, 0002:0028, size = 33, data crc = 0, reloc crc = 0
164 CHECK-NEXT: IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ
165 CHECK-NEXT: SC[.rdata] | mod = 3, 0002:0061, size = 20, data crc = 0, reloc crc = 0
166 CHECK-NEXT: IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ
167 CHECK-NEXT: SC[.rdata] | mod = 3, 0002:0081, size = 20, data crc = 0, reloc crc = 0
168 CHECK-NEXT: IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ
169 CHECK-NEXT: SC[.rdata] | mod = 3, 0002:0104, size = 8, data crc = 0, reloc crc = 0
170 CHECK-NEXT: IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ
171 CHECK-NEXT: SC[.rdata] | mod = 3, 0002:0112, size = 8, data crc = 0, reloc crc = 0
172 CHECK-NEXT: IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ
173 CHECK-NEXT: SC[.rdata] | mod = 3, 0002:0120, size = 8, data crc = 0, reloc crc = 0
174 CHECK-NEXT: IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ
175 CHECK-NEXT: SC[.rdata] | mod = 3, 0002:0128, size = 8, data crc = 0, reloc crc = 0
176 CHECK-NEXT: IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ
177 CHECK-NEXT: SC[.rdata] | mod = 3, 0002:0136, size = 8, data crc = 0, reloc crc = 0
178 CHECK-NEXT: IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ
179 CHECK-NEXT: SC[.rdata] | mod = 3, 0002:0144, size = 8, data crc = 0, reloc crc = 0
180 CHECK-NEXT: IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ
181 CHECK-NEXT: SC[.rdata] | mod = 3, 0002:0152, size = 12, data crc = 0, reloc crc = 0
182 CHECK-NEXT: IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ
183 CHECK-NEXT: SC[.rdata] | mod = 3, 0002:0164, size = 12, data crc = 0, reloc crc = 0
184 CHECK-NEXT: IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ
185 CHECK-NEXT: SC[.rdata] | mod = 3, 0002:0176, size = 33, data crc = 0, reloc crc = 0
186 CHECK-NEXT: IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ