llvm.org GIT mirror llvm / fb30f09
[readobj] Expand CodeView dumping functionality This rewrites and expands the existing codeview dumping functionality in llvm-readobj using techniques similar to those in lib/Object. This defines a number of new records and enums useful for reading memory mapped codeview sections in COFF objects. The dumper is intended as a testing tool for LLVM as it grows more codeview output capabilities. Reviewers: majnemer Differential Revision: http://reviews.llvm.org/D16104 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@257658 91177308-0d34-0410-b5e6-96231b3b80d8 Reid Kleckner 4 years ago
20 changed file(s) with 3030 addition(s) and 553 deletion(s). Raw diff Collapse all Expand all
1414 namespace llvm {
1515 namespace codeview {
1616
17 /// These values correspond to the CV_CPU_TYPE_e enumeration, and are documented
18 /// here: https://msdn.microsoft.com/en-us/library/b2fc64ek.aspx
19 enum class CPUType : uint16_t {
20 Intel8080 = 0x0,
21 Intel8086 = 0x1,
22 Intel80286 = 0x2,
23 Intel80386 = 0x3,
24 Intel80486 = 0x4,
25 Pentium = 0x5,
26 PentiumPro = 0x6,
27 Pentium3 = 0x7,
28 MIPS = 0x10,
29 MIPS16 = 0x11,
30 MIPS32 = 0x12,
31 MIPS64 = 0x13,
32 MIPSI = 0x14,
33 MIPSII = 0x15,
34 MIPSIII = 0x16,
35 MIPSIV = 0x17,
36 MIPSV = 0x18,
37 M68000 = 0x20,
38 M68010 = 0x21,
39 M68020 = 0x22,
40 M68030 = 0x23,
41 M68040 = 0x24,
42 Alpha = 0x30,
43 Alpha21164 = 0x31,
44 Alpha21164A = 0x32,
45 Alpha21264 = 0x33,
46 Alpha21364 = 0x34,
47 PPC601 = 0x40,
48 PPC603 = 0x41,
49 PPC604 = 0x42,
50 PPC620 = 0x43,
51 PPCFP = 0x44,
52 PPCBE = 0x45,
53 SH3 = 0x50,
54 SH3E = 0x51,
55 SH3DSP = 0x52,
56 SH4 = 0x53,
57 SHMedia = 0x54,
58 ARM3 = 0x60,
59 ARM4 = 0x61,
60 ARM4T = 0x62,
61 ARM5 = 0x63,
62 ARM5T = 0x64,
63 ARM6 = 0x65,
64 ARM_XMAC = 0x66,
65 ARM_WMMX = 0x67,
66 ARM7 = 0x68,
67 Omni = 0x70,
68 Ia64 = 0x80,
69 Ia64_2 = 0x81,
70 CEE = 0x90,
71 AM33 = 0xa0,
72 M32R = 0xb0,
73 TriCore = 0xc0,
74 X64 = 0xd0,
75 EBC = 0xe0,
76 Thumb = 0xf0,
77 ARMNT = 0xf4,
78 D3D11_Shader = 0x100,
79 };
80
81 /// These values correspond to the CV_CFL_LANG enumeration, and are documented
82 /// here: https://msdn.microsoft.com/en-us/library/bw3aekw6.aspx
83 enum SourceLanguage : uint8_t {
84 C = 0x00,
85 Cpp = 0x01,
86 Fortran = 0x02,
87 Masm = 0x03,
88 Pascal = 0x04,
89 Basic = 0x05,
90 Cobol = 0x06,
91 Link = 0x07,
92 Cvtres = 0x08,
93 Cvtpgd = 0x09,
94 CSharp = 0x0a,
95 VB = 0x0b,
96 ILAsm = 0x0c,
97 Java = 0x0d,
98 JScript = 0x0e,
99 MSIL = 0x0f,
100 HLSL = 0x10
101 };
102
103 /// These values correspond to the CV_call_e enumeration, and are documented
104 /// at the following locations:
105 /// https://msdn.microsoft.com/en-us/library/b2fc64ek.aspx
106 /// https://msdn.microsoft.com/en-us/library/windows/desktop/ms680207(v=vs.85).aspx
107 ///
17108 enum class CallingConvention : uint8_t {
18109 NearC = 0x00, // near right to left push, caller pops stack
19110 FarC = 0x01, // far right to left push, caller pops stack
139230 Other = 0x03
140231 };
141232
233 /// Source-level access specifier. (CV_access_e)
142234 enum class MemberAccess : uint8_t {
143235 None = 0,
144236 Private = 1,
146238 Public = 3
147239 };
148240
241 /// Part of member attribute flags. (CV_methodprop_e)
149242 enum class MethodKind : uint8_t {
150243 Vanilla = 0x00,
151244 Virtual = 0x01,
156249 PureIntroducingVirtual = 0x06
157250 };
158251
252 /// Equivalent to CV_fldattr_t bitfield.
159253 enum class MethodOptions : uint16_t {
160254 None = 0x0000,
255 AccessMask = 0x0003,
256 MethodKindMask = 0x001c,
161257 Pseudo = 0x0020,
258 NoInherit = 0x0040,
259 NoConstruct = 0x0080,
162260 CompilerGenerated = 0x0100,
163261 Sealed = 0x0200
164262 };
177275 return static_cast(~static_cast(a));
178276 }
179277
278 /// Equivalent to CV_modifier_t.
180279 enum class ModifierOptions : uint16_t {
181280 None = 0x0000,
182281 Const = 0x0001,
206305 FrameData = 0xf5,
207306 InlineeLines = 0xf6,
208307 CrossScopeImports = 0xf7,
209 CrossScopeExports = 0xf8
210 };
211
308 CrossScopeExports = 0xf8,
309
310 // These appear to relate to .Net assembly info.
311 ILLines = 0xf9,
312 FuncMDTokenMap = 0xfa,
313 TypeMDTokenMap = 0xfb,
314 MergedAssemblyInput = 0xfc,
315
316 CoffSymbolRVA = 0xfd,
317 };
318
319 /// Equivalent to CV_ptrtype_e.
212320 enum class PointerKind : uint8_t {
213321 Near16 = 0x00, // 16 bit pointer
214322 Far16 = 0x01, // 16:16 far pointer
225333 Near64 = 0x0c // 64 bit pointer
226334 };
227335
336 /// Equivalent to CV_ptrmode_e.
228337 enum class PointerMode : uint8_t {
229338 Pointer = 0x00, // "normal" pointer
230339 LValueReference = 0x01, // "old" reference
233342 RValueReference = 0x04 // r-value reference
234343 };
235344
345 /// Equivalent to misc lfPointerAttr bitfields.
236346 enum class PointerOptions : uint32_t {
237347 None = 0x00000000,
238348 Flat32 = 0x00000100,
257367 return static_cast(~static_cast(a));
258368 }
259369
370 /// Equivalent to CV_pmtype_e.
260371 enum class PointerToMemberRepresentation : uint16_t {
261372 Unknown = 0x00, // not specified (pre VC8)
262373 SingleInheritanceData = 0x01, // member data, single inheritance
7373 NearPointer128 = 0x00000700 // 128 bit near pointer
7474 };
7575
76 /// A 32-bit type reference. Types are indexed by their order of appearance in
77 /// .debug$T plus 0x1000. Type indices less than 0x1000 are "simple" types,
78 /// composed of a SimpleTypeMode byte followed by a SimpleTypeKind byte.
7679 class TypeIndex {
7780 public:
7881 static const uint32_t FirstNonSimpleIndex = 0x1000;
8992
9093 uint32_t getIndex() const { return Index; }
9194 bool isSimple() const { return Index < FirstNonSimpleIndex; }
95
96 bool isNoType() const { return Index == 0; }
9297
9398 SimpleTypeKind getSimpleKind() const {
9499 assert(isSimple());
143148 static TypeIndex Float64() { return TypeIndex(SimpleTypeKind::Float64); }
144149
145150 private:
146 uint32_t Index;
151 ulittle32_t Index;
147152 };
148153
149154 inline bool operator==(const TypeIndex &A, const TypeIndex &B) {
1010 #define LLVM_DEBUGINFO_PDB_PDBTYPES_H
1111
1212 #include "llvm/Config/llvm-config.h"
13 #include "llvm/DebugInfo/CodeView/CodeView.h"
1314 #include "llvm/Support/Endian.h"
1415 #include
1516 #include
107108
108109 /// These values correspond to the CV_CPU_TYPE_e enumeration, and are documented
109110 /// here: https://msdn.microsoft.com/en-us/library/b2fc64ek.aspx
110 enum class PDB_Cpu {
111 Intel8080 = 0x0,
112 Intel8086 = 0x1,
113 Intel80286 = 0x2,
114 Intel80386 = 0x3,
115 Intel80486 = 0x4,
116 Pentium = 0x5,
117 PentiumPro = 0x6,
118 Pentium3 = 0x7,
119 MIPS = 0x10,
120 MIPS16 = 0x11,
121 MIPS32 = 0x12,
122 MIPS64 = 0x13,
123 MIPSI = 0x14,
124 MIPSII = 0x15,
125 MIPSIII = 0x16,
126 MIPSIV = 0x17,
127 MIPSV = 0x18,
128 M68000 = 0x20,
129 M68010 = 0x21,
130 M68020 = 0x22,
131 M68030 = 0x23,
132 M68040 = 0x24,
133 Alpha = 0x30,
134 Alpha21164 = 0x31,
135 Alpha21164A = 0x32,
136 Alpha21264 = 0x33,
137 Alpha21364 = 0x34,
138 PPC601 = 0x40,
139 PPC603 = 0x41,
140 PPC604 = 0x42,
141 PPC620 = 0x43,
142 PPCFP = 0x44,
143 PPCBE = 0x45,
144 SH3 = 0x50,
145 SH3E = 0x51,
146 SH3DSP = 0x52,
147 SH4 = 0x53,
148 SHMedia = 0x54,
149 ARM3 = 0x60,
150 ARM4 = 0x61,
151 ARM4T = 0x62,
152 ARM5 = 0x63,
153 ARM5T = 0x64,
154 ARM6 = 0x65,
155 ARM_XMAC = 0x66,
156 ARM_WMMX = 0x67,
157 ARM7 = 0x68,
158 Omni = 0x70,
159 Ia64 = 0x80,
160 Ia64_2 = 0x81,
161 CEE = 0x90,
162 AM33 = 0xa0,
163 M32R = 0xb0,
164 TriCore = 0xc0,
165 X64 = 0xd0,
166 EBC = 0xe0,
167 Thumb = 0xf0,
168 ARMNT = 0xf4,
169 D3D11_Shader = 0x100,
170 };
111 typedef codeview::CPUType PDB_Cpu;
171112
172113 enum class PDB_Machine {
173114 Invalid = 0xffff,
199140 /// https://msdn.microsoft.com/en-us/library/b2fc64ek.aspx
200141 /// https://msdn.microsoft.com/en-us/library/windows/desktop/ms680207(v=vs.85).aspx
201142 ///
202 enum class PDB_CallingConv {
203 NearCdecl = 0x00,
204 FarCdecl = 0x01,
205 NearPascal = 0x02,
206 FarPascal = 0x03,
207 NearFastcall = 0x04,
208 FarFastcall = 0x05,
209 Skipped = 0x06,
210 NearStdcall = 0x07,
211 FarStdcall = 0x08,
212 NearSyscall = 0x09,
213 FarSyscall = 0x0a,
214 Thiscall = 0x0b,
215 MipsCall = 0x0c,
216 Generic = 0x0d,
217 Alphacall = 0x0e,
218 Ppccall = 0x0f,
219 SuperHCall = 0x10,
220 Armcall = 0x11,
221 AM33call = 0x12,
222 Tricall = 0x13,
223 Sh5call = 0x14,
224 M32R = 0x15,
225 Clrcall = 0x16,
226 Inline = 0x17,
227 NearVectorcall = 0x18,
228 Reserved = 0x19,
229 };
143 typedef codeview::CallingConvention PDB_CallingConv;
230144
231145 /// These values correspond to the CV_CFL_LANG enumeration, and are documented
232146 /// here: https://msdn.microsoft.com/en-us/library/bw3aekw6.aspx
233 enum class PDB_Lang {
234 C = 0x00,
235 Cpp = 0x01,
236 Fortran = 0x02,
237 Masm = 0x03,
238 Pascal = 0x04,
239 Basic = 0x05,
240 Cobol = 0x06,
241 Link = 0x07,
242 Cvtres = 0x08,
243 Cvtpgd = 0x09,
244 CSharp = 0x0a,
245 VB = 0x0b,
246 ILAsm = 0x0c,
247 Java = 0x0d,
248 JScript = 0x0e,
249 MSIL = 0x0f,
250 HLSL = 0x10
251 };
147 typedef codeview::SourceLanguage PDB_Lang;
252148
253149 /// These values correspond to the DataKind enumeration, and are documented
254150 /// here: https://msdn.microsoft.com/en-us/library/b2x2t313.aspx
673673 DEBUG_INDEX_SUBSECTION = 0xF4,
674674
675675 // Symbol subsections are split into records of different types.
676 DEBUG_SYMBOL_TYPE_LOCAL_PROC_START = 0x1146,
676677 DEBUG_SYMBOL_TYPE_PROC_START = 0x1147,
677678 DEBUG_SYMBOL_TYPE_PROC_END = 0x114F
678679 };
172172 endianness endian,
173173 std::size_t alignment>
174174 struct packed_endian_specific_integral {
175 packed_endian_specific_integral() = default;
176
177 explicit packed_endian_specific_integral(value_type val) { *this = val; }
178
175179 operator value_type() const {
176180 return endian::read(
177181 (const void*)Value.buffer);
198198 return;
199199 assert(FI.End && "Don't know where the function ends?");
200200
201 StringRef GVName = GV->getName();
202201 StringRef FuncName;
203202 if (auto *SP = getDISubprogram(GV))
204203 FuncName = SP->getDisplayName();
207206 // "namespace_foo::bar" function, see PR21528. Luckily, dbghelp.dll is trying
208207 // to demangle display names anyways, so let's just put a mangled name into
209208 // the symbols subsection until Clang gives us what we need.
210 if (GVName.startswith("\01?"))
211 FuncName = GVName.substr(1);
209 if (FuncName.empty())
210 FuncName = GlobalValue::getRealLinkageName(GV->getName());
212211 // Emit a symbol subsection, required by VS2012+ to find function boundaries.
213212 MCSymbol *SymbolsBegin = Asm->MMI->getContext().createTempSymbol(),
214213 *SymbolsEnd = Asm->MMI->getContext().createTempSymbol();
4242 raw_ostream &llvm::operator<<(raw_ostream &OS, const PDB_CallingConv &Conv) {
4343 OS << "__";
4444 switch (Conv) {
45 CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, NearCdecl, "cdecl", OS)
46 CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, FarCdecl, "cdecl", OS)
47 CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, NearPascal, "pascal", OS)
48 CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, FarPascal, "pascal", OS)
49 CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, NearFastcall, "fastcall", OS)
50 CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, FarFastcall, "fastcall", OS)
51 CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, Skipped, "skippedcall", OS)
52 CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, NearStdcall, "stdcall", OS)
53 CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, FarStdcall, "stdcall", OS)
54 CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, NearSyscall, "syscall", OS)
55 CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, FarSyscall, "syscall", OS)
56 CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, Thiscall, "thiscall", OS)
57 CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, MipsCall, "mipscall", OS)
58 CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, Generic, "genericcall", OS)
59 CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, Alphacall, "alphacall", OS)
60 CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, Ppccall, "ppccall", OS)
61 CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, SuperHCall, "superhcall", OS)
62 CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, Armcall, "armcall", OS)
63 CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, AM33call, "am33call", OS)
64 CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, Tricall, "tricall", OS)
65 CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, Sh5call, "sh5call", OS)
66 CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, M32R, "m32rcall", OS)
67 CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, Clrcall, "clrcall", OS)
68 CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, Inline, "inlinecall", OS)
69 CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, NearVectorcall, "vectorcall",
70 OS)
45 CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, NearC , "cdecl", OS)
46 CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, FarC , "cdecl", OS)
47 CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, NearPascal , "pascal", OS)
48 CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, FarPascal , "pascal", OS)
49 CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, NearFast , "fastcall", OS)
50 CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, FarFast , "fastcall", OS)
51 CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, NearStdCall, "stdcall", OS)
52 CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, FarStdCall , "stdcall", OS)
53 CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, NearSysCall, "syscall", OS)
54 CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, FarSysCall , "syscall", OS)
55 CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, ThisCall , "thiscall", OS)
56 CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, MipsCall , "mipscall", OS)
57 CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, Generic , "genericcall", OS)
58 CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, AlphaCall , "alphacall", OS)
59 CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, PpcCall , "ppccall", OS)
60 CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, SHCall , "superhcall", OS)
61 CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, ArmCall , "armcall", OS)
62 CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, AM33Call , "am33call", OS)
63 CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, TriCall , "tricall", OS)
64 CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, SH5Call , "sh5call", OS)
65 CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, M32RCall , "m32rcall", OS)
66 CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, ClrCall , "clrcall", OS)
67 CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, Inline , "inlinecall", OS)
68 CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, NearVector , "vectorcall", OS)
7169 default:
7270 OS << "unknowncall";
7371 }
9595 ; OBJ32-NEXT: ]
9696 ; OBJ32: CodeViewDebugInfo [
9797 ; OBJ32: Subsection [
98 ; OBJ32-NEXT: Type: 0xF1
98 ; OBJ32-NEXT: SubSectionType: Symbols (0xF1)
9999 ; OBJ32-NOT: ]
100100 ; OBJ32: ProcStart {
101 ; OBJ32-NEXT: DisplayName: f
102 ; OBJ32-NEXT: Section: _f
103 ; OBJ32-NEXT: CodeSize: 0x6
104 ; OBJ32-NEXT: }
105 ; OBJ32-NEXT: ProcEnd
101 ; OBJ32: CodeSize: 0x6
102 ; OBJ32: DisplayName: f
103 ; OBJ32: LinkageName: _f
104 ; OBJ32: }
105 ; OBJ32: ProcEnd
106106 ; OBJ32-NEXT: ]
107107 ; OBJ32: FunctionLineTable [
108108 ; OBJ32-NEXT: Name: _f
227227 ; OBJ64-NEXT: 0x48 IMAGE_REL_AMD64_SECTION f
228228 ; OBJ64-NEXT: ]
229229 ; OBJ64: Subsection [
230 ; OBJ64-NEXT: Type: 0xF1
230 ; OBJ64-NEXT: SubSectionType: Symbols (0xF1)
231231 ; OBJ64-NOT: ]
232232 ; OBJ64: ProcStart {
233 ; OBJ64-NEXT: DisplayName: f
234 ; OBJ64-NEXT: Section: f
235 ; OBJ64-NEXT: CodeSize: 0xE
236 ; OBJ64-NEXT: }
233 ; OBJ64: CodeSize: 0xE
234 ; OBJ64: DisplayName: f
235 ; OBJ64: LinkageName: f
236 ; OBJ64: }
237237 ; OBJ64-NEXT: ProcEnd
238238 ; OBJ64-NEXT: ]
239239 ; OBJ64: FunctionLineTable [
99
1010 ; CHECK: ProcStart {
1111 ; FIXME: The display name should in fact be "foo::bar", see PR21528
12 ; CHECK-NEXT: DisplayName: ?bar@foo@@YAHH@Z
13 ; CHECK-NEXT: Section: ?bar@foo@@YAHH@Z
12 ; CHECK: DisplayName: ?bar@foo@@YAHH@Z
13 ; CHECK-NEXT: LinkageName: ?bar@foo@@YAHH@Z
1414
1515 ; Function Attrs: nounwind
1616 define i32 @"\01?bar@foo@@YAHH@Z"(i32 %x) #0 {
121121 ; OBJ32-NEXT: 0x48 IMAGE_REL_I386_SECTION _f
122122 ; OBJ32-NEXT: ]
123123 ; OBJ32: Subsection [
124 ; OBJ32-NEXT: Type: 0xF1
124 ; OBJ32-NEXT: SubSectionType: Symbols (0xF1)
125125 ; OBJ32-NOT: ]
126126 ; OBJ32: ProcStart {
127 ; OBJ32-NEXT: DisplayName: f
128 ; OBJ32-NEXT: Section: _f
129 ; OBJ32-NEXT: CodeSize: 0x10
130 ; OBJ32-NEXT: }
127 ; OBJ32: CodeSize: 0x10
128 ; OBJ32: DisplayName: f
129 ; OBJ32: LinkageName: _f
130 ; OBJ32: }
131131 ; OBJ32-NEXT: ProcEnd
132132 ; OBJ32-NEXT: ]
133133 ; OBJ32: FunctionLineTable [
297297 ; OBJ64-NEXT: 0x48 IMAGE_REL_AMD64_SECTION f
298298 ; OBJ64-NEXT: ]
299299 ; OBJ64: Subsection [
300 ; OBJ64-NEXT: Type: 0xF1
300 ; OBJ64-NEXT: SubSectionType: Symbols (0xF1)
301301 ; OBJ64-NOT: ]
302302 ; OBJ64: ProcStart {
303 ; OBJ64-NEXT: DisplayName: f
304 ; OBJ64-NEXT: Section: f
305 ; OBJ64-NEXT: CodeSize: 0x18
306 ; OBJ64-NEXT: }
307 ; OBJ64-NEXT: ProcEnd
303 ; OBJ64: CodeSize: 0x18
304 ; OBJ64: DisplayName: f
305 ; OBJ64: LinkageName: f
306 ; OBJ64: }
307 ; OBJ64: ProcEnd
308308 ; OBJ64-NEXT: ]
309309 ; OBJ64: FunctionLineTable [
310310 ; OBJ64-NEXT: Name: f
220220 ; OBJ32-NEXT: 0x128 IMAGE_REL_I386_SECTION _f
221221 ; OBJ32-NEXT: ]
222222 ; OBJ32: Subsection [
223 ; OBJ32-NEXT: Type: 0xF1
223 ; OBJ32-NEXT: SubSectionType: Symbols (0xF1)
224224 ; OBJ32-NOT: ]
225225 ; OBJ32: ProcStart {
226 ; OBJ32-NEXT: DisplayName: x
227 ; OBJ32-NEXT: Section: _x
228 ; OBJ32-NEXT: CodeSize: 0x6
229 ; OBJ32-NEXT: }
230 ; OBJ32-NEXT: ProcEnd
226 ; OBJ32: CodeSize: 0x6
227 ; OBJ32: DisplayName: x
228 ; OBJ32: LinkageName: _x
229 ; OBJ32: }
230 ; OBJ32: ProcEnd
231231 ; OBJ32-NEXT: ]
232232 ; OBJ32: Subsection [
233 ; OBJ32-NEXT: Type: 0xF2
233 ; OBJ32-NEXT: SubSectionType: Lines (0xF2)
234234 ; OBJ32: ]
235235 ; OBJ32: Subsection [
236 ; OBJ32-NEXT: Type: 0xF1
236 ; OBJ32-NEXT: SubSectionType: Symbols (0xF1)
237237 ; OBJ32-NOT: ]
238238 ; OBJ32: ProcStart {
239 ; OBJ32-NEXT: DisplayName: y
240 ; OBJ32-NEXT: Section: _y
241 ; OBJ32-NEXT: CodeSize: 0x6
242 ; OBJ32-NEXT: }
243 ; OBJ32-NEXT: ProcEnd
239 ; OBJ32: CodeSize: 0x6
240 ; OBJ32: DisplayName: y
241 ; OBJ32: LinkageName: _y
242 ; OBJ32: }
243 ; OBJ32: ProcEnd
244244 ; OBJ32-NEXT: ]
245245 ; OBJ32: Subsection [
246 ; OBJ32-NEXT: Type: 0xF2
246 ; OBJ32-NEXT: SubSectionType: Lines (0xF2)
247247 ; OBJ32: ]
248248 ; OBJ32: Subsection [
249 ; OBJ32-NEXT: Type: 0xF1
249 ; OBJ32-NEXT: SubSectionType: Symbols (0xF1)
250250 ; OBJ32-NOT: ]
251251 ; OBJ32: ProcStart {
252 ; OBJ32-NEXT: DisplayName: f
253 ; OBJ32-NEXT: Section: _f
254 ; OBJ32-NEXT: CodeSize: 0x10
255 ; OBJ32-NEXT: }
256 ; OBJ32-NEXT: ProcEnd
252 ; OBJ32: CodeSize: 0x10
253 ; OBJ32: DisplayName: f
254 ; OBJ32: LinkageName: _f
255 ; OBJ32: }
256 ; OBJ32: ProcEnd
257257 ; OBJ32-NEXT: ]
258258 ; OBJ32: Subsection [
259 ; OBJ32-NEXT: Type: 0xF2
259 ; OBJ32-NEXT: SubSectionType: Lines (0xF2)
260260 ; OBJ32: ]
261261 ; OBJ32: FunctionLineTable [
262262 ; OBJ32-NEXT: Name: _x
563563 ; OBJ64-NEXT: 0x140 IMAGE_REL_AMD64_SECTION f
564564 ; OBJ64-NEXT: ]
565565 ; OBJ64: Subsection [
566 ; OBJ64-NEXT: Type: 0xF1
566 ; OBJ64-NEXT: SubSectionType: Symbols (0xF1)
567567 ; OBJ64-NOT: ]
568568 ; OBJ64: ProcStart {
569 ; OBJ64-NEXT: DisplayName: x
570 ; OBJ64-NEXT: Section: x
571 ; OBJ64-NEXT: CodeSize: 0xE
572 ; OBJ64-NEXT: }
573 ; OBJ64-NEXT: ProcEnd
569 ; OBJ64: CodeSize: 0xE
570 ; OBJ64: DisplayName: x
571 ; OBJ64: LinkageName: x
572 ; OBJ64: }
573 ; OBJ64: ProcEnd
574574 ; OBJ64-NEXT: ]
575575 ; OBJ64: Subsection [
576 ; OBJ64-NEXT: Type: 0xF2
576 ; OBJ64-NEXT: SubSectionType: Lines (0xF2)
577577 ; OBJ64: ]
578578 ; OBJ64: Subsection [
579 ; OBJ64-NEXT: Type: 0xF1
579 ; OBJ64-NEXT: SubSectionType: Symbols (0xF1)
580580 ; OBJ64-NOT: ]
581581 ; OBJ64: ProcStart {
582 ; OBJ64-NEXT: DisplayName: y
583 ; OBJ64-NEXT: Section: y
584 ; OBJ64-NEXT: CodeSize: 0xE
585 ; OBJ64-NEXT: }
586 ; OBJ64-NEXT: ProcEnd
582 ; OBJ64: CodeSize: 0xE
583 ; OBJ64: DisplayName: y
584 ; OBJ64: LinkageName: y
585 ; OBJ64: }
586 ; OBJ64: ProcEnd
587587 ; OBJ64-NEXT: ]
588588 ; OBJ64: Subsection [
589 ; OBJ64-NEXT: Type: 0xF2
589 ; OBJ64-NEXT: SubSectionType: Lines (0xF2)
590590 ; OBJ64: ]
591591 ; OBJ64: Subsection [
592 ; OBJ64-NEXT: Type: 0xF1
592 ; OBJ64-NEXT: SubSectionType: Symbols (0xF1)
593593 ; OBJ64-NOT: ]
594594 ; OBJ64: ProcStart {
595 ; OBJ64-NEXT: DisplayName: f
596 ; OBJ64-NEXT: Section: f
597 ; OBJ64-NEXT: CodeSize: 0x18
598 ; OBJ64-NEXT: }
599 ; OBJ64-NEXT: ProcEnd
595 ; OBJ64: CodeSize: 0x18
596 ; OBJ64: DisplayName: f
597 ; OBJ64: LinkageName: f
598 ; OBJ64: }
599 ; OBJ64: ProcEnd
600600 ; OBJ64-NEXT: ]
601601 ; OBJ64: Subsection [
602 ; OBJ64-NEXT: Type: 0xF2
602 ; OBJ64-NEXT: SubSectionType: Lines (0xF2)
603603 ; OBJ64: ]
604604 ; OBJ64: FunctionLineTable [
605605 ; OBJ64-NEXT: LinkageName: x
8888 ; OBJ32-NEXT: 0x48 IMAGE_REL_I386_SECTION _f
8989 ; OBJ32-NEXT: ]
9090 ; OBJ32: Subsection [
91 ; OBJ32-NEXT: Type: 0xF1
91 ; OBJ32-NEXT: SubSectionType: Symbols (0xF1)
9292 ; OBJ32-NOT: ]
9393 ; OBJ32: ProcStart {
94 ; OBJ32-NEXT: DisplayName: f
95 ; OBJ32-NEXT: Section: _f
96 ; OBJ32-NEXT: CodeSize: 0x6
97 ; OBJ32-NEXT: }
94 ; OBJ32: CodeSize: 0x6
95 ; OBJ32: DisplayName: f
96 ; OBJ32: LinkageName: _f
97 ; OBJ32: }
9898 ; OBJ32-NEXT: ProcEnd
9999 ; OBJ32-NEXT: ]
100100 ; OBJ32: FunctionLineTable [
206206 ; OBJ64-NEXT: 0x48 IMAGE_REL_AMD64_SECTION f
207207 ; OBJ64-NEXT: ]
208208 ; OBJ64: Subsection [
209 ; OBJ64-NEXT: Type: 0xF1
209 ; OBJ64-NEXT: SubSectionType: Symbols (0xF1)
210210 ; OBJ64-NOT: ]
211211 ; OBJ64: ProcStart {
212 ; OBJ64-NEXT: DisplayName: f
213 ; OBJ64-NEXT: Section: f
214 ; OBJ64-NEXT: CodeSize: 0xE
215 ; OBJ64-NEXT: }
212 ; OBJ64: CodeSize: 0xE
213 ; OBJ64: DisplayName: f
214 ; OBJ64: LinkageName: f
215 ; OBJ64: }
216216 ; OBJ64-NEXT: ProcEnd
217217 ; OBJ64-NEXT: ]
218218 ; OBJ64: FunctionLineTable [
2727 RUN: | FileCheck %s -check-prefix MFUN64
2828
2929 MFUN32: CodeViewDebugInfo [
30 MFUN32-NEXT: Section: .debug$S (2)
3031 MFUN32-NEXT: Magic: 0x4
3132 MFUN32-NEXT: Subsection [
32 MFUN32-NEXT: Type: 0xF1
33 MFUN32-NEXT: PayloadSize: 0x52
34 MFUN32: ]
35 MFUN32-NEXT: Subsection [
36 MFUN32-NEXT: Type: 0xF5
37 MFUN32-NEXT: PayloadSize: 0x24
38 MFUN32: ]
39 MFUN32-NEXT: Subsection [
40 MFUN32-NEXT: Type: 0xF1
41 MFUN32-NEXT: PayloadSize: 0x4B
33 MFUN32-NEXT: SubSectionType: Symbols (0xF1)
34 MFUN32-NEXT: SubSectionSize: 0x52
35 MFUN32: ]
36 MFUN32: Subsection [
37 MFUN32-NEXT: SubSectionType: FrameData (0xF5)
38 MFUN32-NEXT: SubSectionSize: 0x24
39 MFUN32: ]
40 MFUN32-NEXT: Subsection [
41 MFUN32-NEXT: SubSectionType: Symbols (0xF1)
42 MFUN32-NEXT: SubSectionSize: 0x4B
4243 MFUN32: ProcStart {
43 MFUN32-NEXT: DisplayName: x
44 MFUN32-NEXT: Section: _x
45 MFUN32-NEXT: CodeSize: 0xA
46 MFUN32-NEXT: }
47 MFUN32-NEXT: ProcEnd
48 MFUN32: ]
49 MFUN32-NEXT: Subsection [
50 MFUN32-NEXT: Type: 0xF2
51 MFUN32-NEXT: PayloadSize: 0x30
44 MFUN32: CodeSize: 0xA
45 MFUN32: DisplayName: x
46 MFUN32: LinkageName: _x
47 MFUN32: }
48 MFUN32: ProcEnd
49 MFUN32: ]
50 MFUN32-NEXT: Subsection [
51 MFUN32-NEXT: SubSectionType: Lines (0xF2)
52 MFUN32-NEXT: SubSectionSize: 0x30
5253 MFUN32: LinkageName: _x
5354 MFUN32-NEXT: ]
5455 MFUN32-NEXT: Subsection [
55 MFUN32-NEXT: Type: 0xF5
56 MFUN32-NEXT: PayloadSize: 0x24
57 MFUN32: ]
58 MFUN32-NEXT: Subsection [
59 MFUN32-NEXT: Type: 0xF1
60 MFUN32-NEXT: PayloadSize: 0x4B
56 MFUN32-NEXT: SubSectionType: FrameData (0xF5)
57 MFUN32-NEXT: SubSectionSize: 0x24
58 MFUN32: ]
59 MFUN32-NEXT: Subsection [
60 MFUN32-NEXT: SubSectionType: Symbols (0xF1)
61 MFUN32-NEXT: SubSectionSize: 0x4B
6162 MFUN32: ProcStart {
62 MFUN32-NEXT: DisplayName: y
63 MFUN32-NEXT: Section: _y
64 MFUN32-NEXT: CodeSize: 0xA
65 MFUN32-NEXT: }
66 MFUN32-NEXT: ProcEnd
67 MFUN32: ]
68 MFUN32-NEXT: Subsection [
69 MFUN32-NEXT: Type: 0xF2
70 MFUN32-NEXT: PayloadSize: 0x30
63 MFUN32: CodeSize: 0xA
64 MFUN32: DisplayName: y
65 MFUN32: LinkageName: _y
66 MFUN32: }
67 MFUN32: ProcEnd
68 MFUN32: ]
69 MFUN32-NEXT: Subsection [
70 MFUN32-NEXT: SubSectionType: Lines (0xF2)
71 MFUN32-NEXT: SubSectionSize: 0x30
7172 MFUN32: LinkageName: _y
7273 MFUN32-NEXT: ]
7374 MFUN32-NEXT: Subsection [
74 MFUN32-NEXT: Type: 0xF5
75 MFUN32-NEXT: PayloadSize: 0x24
76 MFUN32: ]
77 MFUN32-NEXT: Subsection [
78 MFUN32-NEXT: Type: 0xF1
79 MFUN32-NEXT: PayloadSize: 0x4B
75 MFUN32-NEXT: SubSectionType: FrameData (0xF5)
76 MFUN32-NEXT: SubSectionSize: 0x24
77 MFUN32: ]
78 MFUN32-NEXT: Subsection [
79 MFUN32-NEXT: SubSectionType: Symbols (0xF1)
80 MFUN32-NEXT: SubSectionSize: 0x4B
8081 MFUN32: ProcStart {
81 MFUN32-NEXT: DisplayName: f
82 MFUN32-NEXT: Section: _f
83 MFUN32-NEXT: CodeSize: 0x14
84 MFUN32-NEXT: }
85 MFUN32-NEXT: ProcEnd
86 MFUN32: ]
87 MFUN32-NEXT: Subsection [
88 MFUN32-NEXT: Type: 0xF2
89 MFUN32-NEXT: PayloadSize: 0x40
82 MFUN32: CodeSize: 0x14
83 MFUN32: DisplayName: f
84 MFUN32: LinkageName: _f
85 MFUN32: }
86 MFUN32: ProcEnd
87 MFUN32: ]
88 MFUN32-NEXT: Subsection [
89 MFUN32-NEXT: SubSectionType: Lines (0xF2)
90 MFUN32-NEXT: SubSectionSize: 0x40
9091 MFUN32: LinkageName: _f
9192 MFUN32-NEXT: ]
9293 MFUN32-NEXT: Subsection [
93 MFUN32-NEXT: Type: 0xF4
94 MFUN32-NEXT: PayloadSize: 0x18
95 MFUN32: ]
96 MFUN32-NEXT: Subsection [
97 MFUN32-NEXT: Type: 0xF3
98 MFUN32-NEXT: PayloadSize: 0x46
99 MFUN32: ]
100 MFUN32-NEXT: Subsection [
101 MFUN32-NEXT: Type: 0xF1
102 MFUN32-NEXT: PayloadSize: 0x8
94 MFUN32-NEXT: SubSectionType: FileChecksums (0xF4)
95 MFUN32-NEXT: SubSectionSize: 0x18
96 MFUN32: ]
97 MFUN32-NEXT: Subsection [
98 MFUN32-NEXT: SubSectionType: StringTable (0xF3)
99 MFUN32-NEXT: SubSectionSize: 0x46
100 MFUN32: ]
101 MFUN32-NEXT: Subsection [
102 MFUN32-NEXT: SubSectionType: Symbols (0xF1)
103 MFUN32-NEXT: SubSectionSize: 0x8
103104 MFUN32: ]
104105 MFUN32-NEXT: FunctionLineTable [
105106 MFUN32-NEXT LinkageName: _x
180181 MFUN32-NEXT ]
181182 MFUN32-NEXT ]
182183 MFUN32-NEXT ]
183 MFUN32-NEXT ]
184 MFUN32: ]
184185
185186 MFUN64: CodeViewDebugInfo [
186 MFUN64-NEXT: Magic: 0x4
187 MFUN64-NEXT: Subsection [
188 MFUN64-NEXT: Type: 0xF1
189 MFUN64-NEXT: PayloadSize: 0x52
190 MFUN64: ]
191 MFUN64-NEXT: Subsection [
192 MFUN64-NEXT: Type: 0xF1
193 MFUN64-NEXT: PayloadSize: 0x4B
187 MFUN64: Magic: 0x4
188 MFUN64-NEXT: Subsection [
189 MFUN64-NEXT: SubSectionType: Symbols (0xF1)
190 MFUN64-NEXT: SubSectionSize: 0x52
191 MFUN64: ]
192 MFUN64: Subsection [
193 MFUN64-NEXT: SubSectionType: Symbols (0xF1)
194 MFUN64-NEXT: SubSectionSize: 0x4B
194195 MFUN64: ProcStart {
195 MFUN64-NEXT: DisplayName: x
196 MFUN64-NEXT: Section: x
197 MFUN64-NEXT: CodeSize: 0xE
198 MFUN64-NEXT: }
199 MFUN64-NEXT: ProcEnd
200 MFUN64: ]
201 MFUN64-NEXT: Subsection [
202 MFUN64-NEXT: Type: 0xF2
203 MFUN64-NEXT: PayloadSize: 0x30
196 MFUN64: CodeSize: 0xE
197 MFUN64: DisplayName: x
198 MFUN64: LinkageName: x
199 MFUN64: }
200 MFUN64: ProcEnd
201 MFUN64: ]
202 MFUN64-NEXT: Subsection [
203 MFUN64-NEXT: SubSectionType: Lines (0xF2)
204 MFUN64-NEXT: SubSectionSize: 0x30
204205 MFUN64: LinkageName: x
205206 MFUN64-NEXT: ]
206207 MFUN64-NEXT: Subsection [
207 MFUN64-NEXT: Type: 0xF1
208 MFUN64-NEXT: PayloadSize: 0x4B
208 MFUN64-NEXT: SubSectionType: Symbols (0xF1)
209 MFUN64-NEXT: SubSectionSize: 0x4B
209210 MFUN64: ProcStart {
210 MFUN64-NEXT: DisplayName: y
211 MFUN64-NEXT: Section: y
212 MFUN64-NEXT: CodeSize: 0xE
213 MFUN64-NEXT: }
214 MFUN64-NEXT: ProcEnd
215 MFUN64: ]
216 MFUN64-NEXT: Subsection [
217 MFUN64-NEXT: Type: 0xF2
218 MFUN64-NEXT: PayloadSize: 0x30
211 MFUN64: CodeSize: 0xE
212 MFUN64: DisplayName: y
213 MFUN64: LinkageName: y
214 MFUN64: }
215 MFUN64: ProcEnd
216 MFUN64: ]
217 MFUN64-NEXT: Subsection [
218 MFUN64-NEXT: SubSectionType: Lines (0xF2)
219 MFUN64-NEXT: SubSectionSize: 0x30
219220 MFUN64: LinkageName: y
220221 MFUN64-NEXT: ]
221222 MFUN64-NEXT: Subsection [
222 MFUN64-NEXT: Type: 0xF1
223 MFUN64-NEXT: PayloadSize: 0x4B
223 MFUN64-NEXT: SubSectionType: Symbols (0xF1)
224 MFUN64-NEXT: SubSectionSize: 0x4B
224225 MFUN64: ProcStart {
225 MFUN64-NEXT: DisplayName: f
226 MFUN64-NEXT: Section: f
227 MFUN64-NEXT: CodeSize: 0x18
228 MFUN64-NEXT: }
229 MFUN64-NEXT: ProcEnd
230 MFUN64: ]
231 MFUN64-NEXT: Subsection [
232 MFUN64-NEXT: Type: 0xF2
233 MFUN64-NEXT: PayloadSize: 0x40
226 MFUN64: CodeSize: 0x18
227 MFUN64: DisplayName: f
228 MFUN64: LinkageName: f
229 MFUN64: }
230 MFUN64: ProcEnd
231 MFUN64: ]
232 MFUN64-NEXT: Subsection [
233 MFUN64-NEXT: SubSectionType: Lines (0xF2)
234 MFUN64-NEXT: SubSectionSize: 0x40
234235 MFUN64: LinkageName: f
235236 MFUN64-NEXT: ]
236237 MFUN64-NEXT: Subsection [
237 MFUN64-NEXT: Type: 0xF4
238 MFUN64-NEXT: PayloadSize: 0x18
239 MFUN64: ]
240 MFUN64-NEXT: Subsection [
241 MFUN64-NEXT: Type: 0xF3
242 MFUN64-NEXT: PayloadSize: 0xD
243 MFUN64: ]
244 MFUN64-NEXT: Subsection [
245 MFUN64-NEXT: Type: 0xF1
246 MFUN64-NEXT: PayloadSize: 0x8
238 MFUN64-NEXT: SubSectionType: FileChecksums (0xF4)
239 MFUN64-NEXT: SubSectionSize: 0x18
240 MFUN64: ]
241 MFUN64-NEXT: Subsection [
242 MFUN64-NEXT: SubSectionType: StringTable (0xF3)
243 MFUN64-NEXT: SubSectionSize: 0xD
244 MFUN64: ]
245 MFUN64-NEXT: Subsection [
246 MFUN64-NEXT: SubSectionType: Symbols (0xF1)
247 MFUN64-NEXT: SubSectionSize: 0x8
247248 MFUN64: ]
248249 MFUN64-NEXT: FunctionLineTable [
249250 MFUN64-NEXT: LinkageName: x
324325 MFUN64-NEXT: ]
325326 MFUN64-NEXT: ]
326327 MFUN64-NEXT: ]
327 MFUN64-NEXT: ]
328 MFUN64: ]
328329
329330 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
330331 ; The following two object files were generated using the following command:
351352 RUN: | FileCheck %s -check-prefix MFILE64
352353
353354 MFILE32: CodeViewDebugInfo [
354 MFILE32-NEXT: Magic: 0x4
355 MFILE32: Magic: 0x4
355356 MFILE32-NEXT: Subsection [
356 MFILE32-NEXT: Type: 0xF1
357 MFILE32-NEXT: PayloadSize: 0x51
357 MFILE32-NEXT: SubSectionType: Symbols (0xF1)
358 MFILE32-NEXT: SubSectionSize: 0x51
359 MFILE32: ]
360 MFILE32: Subsection [
361 MFILE32-NEXT: SubSectionType: FrameData (0xF5)
362 MFILE32-NEXT: SubSectionSize: 0x24
358363 MFILE32: ]
359364 MFILE32-NEXT: Subsection [
360 MFILE32-NEXT: Type: 0xF5
361 MFILE32-NEXT: PayloadSize: 0x24
365 MFILE32-NEXT: SubSectionType: Symbols (0xF1)
366 MFILE32-NEXT: SubSectionSize: 0x4B
367 MFILE32: ProcStart {
368 MFILE32: CodeSize: 0x14
369 MFILE32: DisplayName: f
370 MFILE32: LinkageName: _f
371 MFILE32: }
372 MFILE32: ProcEnd
362373 MFILE32: ]
363374 MFILE32-NEXT: Subsection [
364 MFILE32-NEXT: Type: 0xF1
365 MFILE32-NEXT: PayloadSize: 0x4B
366 MFILE32: ProcStart {
367 MFILE32-NEXT: DisplayName: f
368 MFILE32-NEXT: Section: _f
369 MFILE32-NEXT: CodeSize: 0x14
370 MFILE32-NEXT: }
371 MFILE32-NEXT: ProcEnd
372 MFILE32: ]
373 MFILE32-NEXT: Subsection [
374 MFILE32-NEXT: Type: 0xF2
375 MFILE32-NEXT: PayloadSize: 0x64
375 MFILE32-NEXT: SubSectionType: Lines (0xF2)
376 MFILE32-NEXT: SubSectionSize: 0x64
376377 MFILE32: LinkageName: _f
377378 MFILE32-NEXT: ]
378379 MFILE32-NEXT: Subsection [
379 MFILE32-NEXT: Type: 0xF4
380 MFILE32-NEXT: PayloadSize: 0x28
380 MFILE32-NEXT: SubSectionType: FileChecksums (0xF4)
381 MFILE32-NEXT: SubSectionSize: 0x28
381382 MFILE32: ]
382383 MFILE32-NEXT: Subsection [
383 MFILE32-NEXT: Type: 0xF3
384 MFILE32-NEXT: PayloadSize: 0x57
384 MFILE32-NEXT: SubSectionType: StringTable (0xF3)
385 MFILE32-NEXT: SubSectionSize: 0x57
385386 MFILE32: ]
386387 MFILE32-NEXT: Subsection [
387 MFILE32-NEXT: Type: 0xF1
388 MFILE32-NEXT: PayloadSize: 0x8
388 MFILE32-NEXT: SubSectionType: Symbols (0xF1)
389 MFILE32-NEXT: SubSectionSize: 0x8
389390 MFILE32: ]
390391 MFILE32-NEXT: FunctionLineTable [
391392 MFILE32-NEXT: LinkageName: _f
429430 MFILE32-NEXT: ]
430431 MFILE32-NEXT: ]
431432 MFILE32-NEXT: ]
432 MFILE32-NEXT: ]
433 MFILE32: ]
433434
434435 MFILE64: CodeViewDebugInfo [
435 MFILE64-NEXT: Magic: 0x4
436 MFILE64: Magic: 0x4
436437 MFILE64-NEXT: Subsection [
437 MFILE64-NEXT: Type: 0xF1
438 MFILE64-NEXT: PayloadSize: 0x51
438 MFILE64-NEXT: SubSectionType: Symbols (0xF1)
439 MFILE64-NEXT: SubSectionSize: 0x51
440 MFILE64: ]
441 MFILE64: Subsection [
442 MFILE64-NEXT: SubSectionType: Symbols (0xF1)
443 MFILE64-NEXT: SubSectionSize: 0x4B
444 MFILE64: ProcStart {
445 MFILE64: CodeSize: 0x18
446 MFILE64: DisplayName: f
447 MFILE64: LinkageName: f
448 MFILE64: }
449 MFILE64: ProcEnd
439450 MFILE64: ]
440451 MFILE64-NEXT: Subsection [
441 MFILE64-NEXT: Type: 0xF1
442 MFILE64-NEXT: PayloadSize: 0x4B
443 MFILE64: ProcStart {
444 MFILE64-NEXT: DisplayName: f
445 MFILE64-NEXT: Section: f
446 MFILE64-NEXT: CodeSize: 0x18
447 MFILE64-NEXT: }
448 MFILE64-NEXT: ProcEnd
449 MFILE64: ]
450 MFILE64-NEXT: Subsection [
451 MFILE64-NEXT: Type: 0xF2
452 MFILE64-NEXT: PayloadSize: 0x64
452 MFILE64-NEXT: SubSectionType: Lines (0xF2)
453 MFILE64-NEXT: SubSectionSize: 0x64
453454 MFILE64: LinkageName: f
454455 MFILE64-NEXT: ]
455456 MFILE64-NEXT: Subsection [
456 MFILE64-NEXT: Type: 0xF4
457 MFILE64-NEXT: PayloadSize: 0x28
457 MFILE64-NEXT: SubSectionType: FileChecksums (0xF4)
458 MFILE64-NEXT: SubSectionSize: 0x28
458459 MFILE64: ]
459460 MFILE64-NEXT: Subsection [
460 MFILE64-NEXT: Type: 0xF3
461 MFILE64-NEXT: PayloadSize: 0x1E
461 MFILE64-NEXT: SubSectionType: StringTable (0xF3)
462 MFILE64-NEXT: SubSectionSize: 0x1E
462463 MFILE64: ]
463464 MFILE64-NEXT: Subsection [
464 MFILE64-NEXT: Type: 0xF1
465 MFILE64-NEXT: PayloadSize: 0x8
465 MFILE64-NEXT: SubSectionType: Symbols (0xF1)
466 MFILE64-NEXT: SubSectionSize: 0x8
466467 MFILE64: ]
467468 MFILE64-NEXT: FunctionLineTable [
468469 MFILE64-NEXT: LinkageName: f
505506 MFILE64-NEXT: IsStatement: Yes
506507 MFILE64-NEXT: ]
507508 MFILE64-NEXT: ]
508 MFILE64-NEXT: ]
509 MFILE64: ]
509510
510511 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
511512 ; The following object files were generated using the following command:
527528 RUN: | FileCheck %s -check-prefix MCOMDAT
528529
529530 MCOMDAT: ProcStart {
530 MCOMDAT-NEXT: DisplayName: f
531 MCOMDAT-NEXT: Section: ?f@@YAHXZ
532 MCOMDAT-NEXT: CodeSize: 0x7
533 MCOMDAT-NEXT: }
531 MCOMDAT: CodeSize: 0x7
532 MCOMDAT: DisplayName: f
533 MCOMDAT: LinkageName: ?f@@YAHXZ
534 MCOMDAT: }
534535 MCOMDAT: FunctionLineTable [
535536 MCOMDAT-NEXT: LinkageName: ?f@@YAHXZ
536537 MCOMDAT-NEXT: Flags: 0x0
555556 MCOMDAT-NEXT: ]
556557 MCOMDAT-NEXT: ]
557558 MCOMDAT: ProcStart {
558 MCOMDAT-NEXT: DisplayName: g
559 MCOMDAT-NEXT: Section: ?g@@YAHXZ
560 MCOMDAT-NEXT: CodeSize: 0x7
561 MCOMDAT-NEXT: }
559 MCOMDAT: CodeSize: 0x7
560 MCOMDAT: DisplayName: g
561 MCOMDAT: LinkageName: ?g@@YAHXZ
562 MCOMDAT: }
562563 MCOMDAT: FunctionLineTable [
563564 MCOMDAT-NEXT: LinkageName: ?g@@YAHXZ
564565 MCOMDAT-NEXT: Flags: 0x0
2626 #include "llvm/Support/Format.h"
2727
2828 using namespace llvm;
29 using namespace llvm::codeview;
2930
3031 namespace {
3132 template
5657 Symbol.getSession().getConcreteSymbolById(
5758 ClassParentId);
5859
59 PDB_CallingConv CC = Symbol.getCallingConvention();
60 CallingConvention CC = Symbol.getCallingConvention();
6061 bool ShouldDumpCallingConvention = true;
61 if ((ClassParent && CC == PDB_CallingConv::Thiscall) ||
62 (!ClassParent && CC == PDB_CallingConv::NearStdcall)) {
62 if ((ClassParent && CC == CallingConvention::ThisCall) ||
63 (!ClassParent && CC == CallingConvention::NearStdCall)) {
6364 ShouldDumpCallingConvention = false;
6465 }
6566
151152 Printer << " ";
152153
153154 auto ClassParent = Symbol.getClassParent();
154 PDB_CallingConv CC = Signature->getCallingConvention();
155 CallingConvention CC = Signature->getCallingConvention();
155156 if (Pointer != FunctionDumper::PointerType::None)
156157 Printer << "(";
157158
158 if ((ClassParent && CC != PDB_CallingConv::Thiscall) ||
159 (!ClassParent && CC != PDB_CallingConv::NearStdcall)) {
159 if ((ClassParent && CC != CallingConvention::ThisCall) ||
160 (!ClassParent && CC != CallingConvention::NearStdCall)) {
160161 WithColor(Printer, PDB_ColorItem::Keyword).get()
161162 << Signature->getCallingConvention() << " ";
162163 }
1313
1414 #include "llvm-readobj.h"
1515 #include "ARMWinEHPrinter.h"
16 #include "CodeView.h"
1617 #include "Error.h"
1718 #include "ObjDumper.h"
1819 #include "StackMapPrinter.h"
2122 #include "llvm/ADT/DenseMap.h"
2223 #include "llvm/ADT/SmallString.h"
2324 #include "llvm/ADT/StringExtras.h"
25 #include "llvm/ADT/StringSet.h"
2426 #include "llvm/Object/COFF.h"
2527 #include "llvm/Object/ObjectFile.h"
2628 #include "llvm/Support/COFF.h"
3840
3941 using namespace llvm;
4042 using namespace llvm::object;
43 using namespace llvm::codeview;
4144 using namespace llvm::Win64EH;
4245
4346 namespace {
7174 void printBaseOfDataField(const pe32_header *Hdr);
7275 void printBaseOfDataField(const pe32plus_header *Hdr);
7376
74 void printCodeViewSection(const SectionRef &Section);
77 void printCodeViewSymbolSection(StringRef SectionName, const SectionRef &Section);
78 void printCodeViewTypeSection(StringRef SectionName, const SectionRef &Section);
79 void printCodeViewFieldList(StringRef FieldData);
80 StringRef getTypeName(TypeIndex Ty);
81 void printTypeIndex(StringRef FieldName, TypeIndex TI);
7582
7683 void printCodeViewSymbolsSubsection(StringRef Subsection,
7784 const SectionRef &Section,
7885 uint32_t Offset);
86
87 void printMemberAttributes(MemberAttributes Attrs);
7988
8089 void cacheRelocations();
8190
95104 RelocMapTy RelocMap;
96105 StringRef CVFileIndexToStringOffsetTable;
97106 StringRef CVStringTable;
107
108 /// All user defined type records in .debug$T live in here. Type indices
109 /// greater than 0x1000 are user defined. Subtract 0x1000 from the index to
110 /// index into this vector.
111 SmallVector CVUDTNames;
112
113 StringSet<> TypeNames;
98114 };
99115
100116 } // namespace
330346 { "Alias" , COFF::IMAGE_WEAK_EXTERN_SEARCH_ALIAS }
331347 };
332348
349 static const EnumEntry CompileSym3Flags[] = {
350 LLVM_READOBJ_ENUM_ENT(CompileSym3, EC),
351 LLVM_READOBJ_ENUM_ENT(CompileSym3, NoDbgInfo),
352 LLVM_READOBJ_ENUM_ENT(CompileSym3, LTCG),
353 LLVM_READOBJ_ENUM_ENT(CompileSym3, NoDataAlign),
354 LLVM_READOBJ_ENUM_ENT(CompileSym3, ManagedPresent),
355 LLVM_READOBJ_ENUM_ENT(CompileSym3, SecurityChecks),
356 LLVM_READOBJ_ENUM_ENT(CompileSym3, HotPatch),
357 LLVM_READOBJ_ENUM_ENT(CompileSym3, CVTCIL),
358 LLVM_READOBJ_ENUM_ENT(CompileSym3, MSILModule),
359 LLVM_READOBJ_ENUM_ENT(CompileSym3, Sdl),
360 LLVM_READOBJ_ENUM_ENT(CompileSym3, PGO),
361 LLVM_READOBJ_ENUM_ENT(CompileSym3, Exp),
362 };
363
364 static const EnumEntry SourceLanguages[] = {
365 LLVM_READOBJ_ENUM_ENT(SourceLanguage, C),
366 LLVM_READOBJ_ENUM_ENT(SourceLanguage, Cpp),
367 LLVM_READOBJ_ENUM_ENT(SourceLanguage, Fortran),
368 LLVM_READOBJ_ENUM_ENT(SourceLanguage, Masm),
369 LLVM_READOBJ_ENUM_ENT(SourceLanguage, Pascal),
370 LLVM_READOBJ_ENUM_ENT(SourceLanguage, Basic),
371 LLVM_READOBJ_ENUM_ENT(SourceLanguage, Cobol),
372 LLVM_READOBJ_ENUM_ENT(SourceLanguage, Link),
373 LLVM_READOBJ_ENUM_ENT(SourceLanguage, Cvtres),
374 LLVM_READOBJ_ENUM_ENT(SourceLanguage, Cvtpgd),
375 LLVM_READOBJ_ENUM_ENT(SourceLanguage, CSharp),
376 LLVM_READOBJ_ENUM_ENT(SourceLanguage, VB),
377 LLVM_READOBJ_ENUM_ENT(SourceLanguage, ILAsm),
378 LLVM_READOBJ_ENUM_ENT(SourceLanguage, Java),
379 LLVM_READOBJ_ENUM_ENT(SourceLanguage, JScript),
380 LLVM_READOBJ_ENUM_ENT(SourceLanguage, MSIL),
381 LLVM_READOBJ_ENUM_ENT(SourceLanguage, HLSL),
382 };
383
384 static const EnumEntry SubSectionTypes[] = {
385 LLVM_READOBJ_ENUM_CLASS_ENT(ModuleSubstreamKind, Symbols),
386 LLVM_READOBJ_ENUM_CLASS_ENT(ModuleSubstreamKind, Lines),
387 LLVM_READOBJ_ENUM_CLASS_ENT(ModuleSubstreamKind, StringTable),
388 LLVM_READOBJ_ENUM_CLASS_ENT(ModuleSubstreamKind, FileChecksums),
389 LLVM_READOBJ_ENUM_CLASS_ENT(ModuleSubstreamKind, FrameData),
390 LLVM_READOBJ_ENUM_CLASS_ENT(ModuleSubstreamKind, InlineeLines),
391 LLVM_READOBJ_ENUM_CLASS_ENT(ModuleSubstreamKind, CrossScopeImports),
392 LLVM_READOBJ_ENUM_CLASS_ENT(ModuleSubstreamKind, CrossScopeExports),
393 LLVM_READOBJ_ENUM_CLASS_ENT(ModuleSubstreamKind, ILLines),
394 LLVM_READOBJ_ENUM_CLASS_ENT(ModuleSubstreamKind, FuncMDTokenMap),
395 LLVM_READOBJ_ENUM_CLASS_ENT(ModuleSubstreamKind, TypeMDTokenMap),
396 LLVM_READOBJ_ENUM_CLASS_ENT(ModuleSubstreamKind, MergedAssemblyInput),
397 LLVM_READOBJ_ENUM_CLASS_ENT(ModuleSubstreamKind, CoffSymbolRVA),
398 };
399
400 static const EnumEntry CPUTypeNames[] = {
401 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, Intel8080),
402 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, Intel8086),
403 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, Intel80286),
404 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, Intel80386),
405 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, Intel80486),
406 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, Pentium),
407 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, PentiumPro),
408 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, Pentium3),
409 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, MIPS),
410 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, MIPS16),
411 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, MIPS32),
412 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, MIPS64),
413 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, MIPSI),
414 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, MIPSII),
415 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, MIPSIII),
416 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, MIPSIV),
417 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, MIPSV),
418 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, M68000),
419 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, M68010),
420 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, M68020),
421 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, M68030),
422 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, M68040),
423 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, Alpha),
424 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, Alpha21164),
425 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, Alpha21164A),
426 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, Alpha21264),
427 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, Alpha21364),
428 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, PPC601),
429 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, PPC603),
430 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, PPC604),
431 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, PPC620),
432 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, PPCFP),
433 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, PPCBE),
434 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, SH3),
435 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, SH3E),
436 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, SH3DSP),
437 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, SH4),
438 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, SHMedia),
439 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, ARM3),
440 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, ARM4),
441 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, ARM4T),
442 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, ARM5),
443 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, ARM5T),
444 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, ARM6),
445 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, ARM_XMAC),
446 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, ARM_WMMX),
447 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, ARM7),
448 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, Omni),
449 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, Ia64),
450 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, Ia64_2),
451 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, CEE),
452 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, AM33),
453 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, M32R),
454 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, TriCore),
455 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, X64),
456 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, EBC),
457 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, Thumb),
458 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, ARMNT),
459 LLVM_READOBJ_ENUM_CLASS_ENT(CPUType, D3D11_Shader),
460 };
461
462 static const EnumEntry ProcSymFlags[] = {
463 LLVM_READOBJ_ENUM_ENT(ProcFlags, HasFP),
464 LLVM_READOBJ_ENUM_ENT(ProcFlags, HasIRET),
465 LLVM_READOBJ_ENUM_ENT(ProcFlags, HasFRET),
466 LLVM_READOBJ_ENUM_ENT(ProcFlags, IsNoReturn),
467 LLVM_READOBJ_ENUM_ENT(ProcFlags, IsUnreachable),
468 LLVM_READOBJ_ENUM_ENT(ProcFlags, HasCustomCallingConv),
469 LLVM_READOBJ_ENUM_ENT(ProcFlags, IsNoInline),
470 LLVM_READOBJ_ENUM_ENT(ProcFlags, HasOptimizedDebugInfo),
471 };
472
473 static const EnumEntry FrameProcSymFlags[] = {
474 LLVM_READOBJ_ENUM_CLASS_ENT(FrameProcedureOptions, HasAlloca),
475 LLVM_READOBJ_ENUM_CLASS_ENT(FrameProcedureOptions, HasSetJmp),
476 LLVM_READOBJ_ENUM_CLASS_ENT(FrameProcedureOptions, HasLongJmp),
477 LLVM_READOBJ_ENUM_CLASS_ENT(FrameProcedureOptions, HasInlineAssembly),
478 LLVM_READOBJ_ENUM_CLASS_ENT(FrameProcedureOptions, HasExceptionHandling),
479 LLVM_READOBJ_ENUM_CLASS_ENT(FrameProcedureOptions, MarkedInline),
480 LLVM_READOBJ_ENUM_CLASS_ENT(FrameProcedureOptions,
481 HasStructuredExceptionHandling),
482 LLVM_READOBJ_ENUM_CLASS_ENT(FrameProcedureOptions, Naked),
483 LLVM_READOBJ_ENUM_CLASS_ENT(FrameProcedureOptions, SecurityChecks),
484 LLVM_READOBJ_ENUM_CLASS_ENT(FrameProcedureOptions,
485 AsynchronousExceptionHandling),
486 LLVM_READOBJ_ENUM_CLASS_ENT(FrameProcedureOptions,
487 NoStackOrderingForSecurityChecks),
488 LLVM_READOBJ_ENUM_CLASS_ENT(FrameProcedureOptions, Inlined),
489 LLVM_READOBJ_ENUM_CLASS_ENT(FrameProcedureOptions, StrictSecurityChecks),
490 LLVM_READOBJ_ENUM_CLASS_ENT(FrameProcedureOptions, SafeBuffers),
491 LLVM_READOBJ_ENUM_CLASS_ENT(FrameProcedureOptions,
492 ProfileGuidedOptimization),
493 LLVM_READOBJ_ENUM_CLASS_ENT(FrameProcedureOptions, ValidProfileCounts),
494 LLVM_READOBJ_ENUM_CLASS_ENT(FrameProcedureOptions, OptimizedForSpeed),
495 LLVM_READOBJ_ENUM_CLASS_ENT(FrameProcedureOptions, GuardCfg),
496 LLVM_READOBJ_ENUM_CLASS_ENT(FrameProcedureOptions, GuardCfw),
497 };
498
499 static const EnumEntry FrameDataFlags[] = {
500 LLVM_READOBJ_ENUM_ENT(FrameData, HasSEH),
501 LLVM_READOBJ_ENUM_ENT(FrameData, HasEH),
502 LLVM_READOBJ_ENUM_ENT(FrameData, IsFunctionStart),
503 };
504
505 static const EnumEntry LocalFlags[] = {
506 LLVM_READOBJ_ENUM_ENT(LocalSym, IsParameter),
507 LLVM_READOBJ_ENUM_ENT(LocalSym, IsAddressTaken),
508 LLVM_READOBJ_ENUM_ENT(LocalSym, IsCompilerGenerated),
509 LLVM_READOBJ_ENUM_ENT(LocalSym, IsAggregate),
510 LLVM_READOBJ_ENUM_ENT(LocalSym, IsAggregated),
511 LLVM_READOBJ_ENUM_ENT(LocalSym, IsAliased),
512 LLVM_READOBJ_ENUM_ENT(LocalSym, IsAlias),
513 LLVM_READOBJ_ENUM_ENT(LocalSym, IsReturnValue),
514 LLVM_READOBJ_ENUM_ENT(LocalSym, IsOptimizedOut),
515 LLVM_READOBJ_ENUM_ENT(LocalSym, IsEnregisteredGlobal),
516 LLVM_READOBJ_ENUM_ENT(LocalSym, IsEnregisteredStatic),
517 };
518
519 static const EnumEntry FrameCookieKinds[] = {
520 LLVM_READOBJ_ENUM_ENT(FrameCookieSym, Copy),
521 LLVM_READOBJ_ENUM_ENT(FrameCookieSym, XorStackPointer),
522 LLVM_READOBJ_ENUM_ENT(FrameCookieSym, XorFramePointer),
523 LLVM_READOBJ_ENUM_ENT(FrameCookieSym, XorR13),
524 };
525
526 static const EnumEntry ClassOptionNames[] = {
527 LLVM_READOBJ_ENUM_CLASS_ENT(ClassOptions, Packed),
528 LLVM_READOBJ_ENUM_CLASS_ENT(ClassOptions, HasConstructorOrDestructor),
529 LLVM_READOBJ_ENUM_CLASS_ENT(ClassOptions, HasOverloadedOperator),
530 LLVM_READOBJ_ENUM_CLASS_ENT(ClassOptions, Nested),
531 LLVM_READOBJ_ENUM_CLASS_ENT(ClassOptions, ContainsNestedClass),
532 LLVM_READOBJ_ENUM_CLASS_ENT(ClassOptions, HasOverloadedAssignmentOperator),
533 LLVM_READOBJ_ENUM_CLASS_ENT(ClassOptions, HasConversionOperator),
534 LLVM_READOBJ_ENUM_CLASS_ENT(ClassOptions, ForwardReference),
535 LLVM_READOBJ_ENUM_CLASS_ENT(ClassOptions, Scoped),
536 LLVM_READOBJ_ENUM_CLASS_ENT(ClassOptions, HasUniqueName),
537 LLVM_READOBJ_ENUM_CLASS_ENT(ClassOptions, Sealed),
538 LLVM_READOBJ_ENUM_CLASS_ENT(ClassOptions, Intrinsic),
539 };
540
541 static const EnumEntry MemberAccessNames[] = {
542 LLVM_READOBJ_ENUM_CLASS_ENT(MemberAccess, None),
543 LLVM_READOBJ_ENUM_CLASS_ENT(MemberAccess, Private),
544 LLVM_READOBJ_ENUM_CLASS_ENT(MemberAccess, Protected),
545 LLVM_READOBJ_ENUM_CLASS_ENT(MemberAccess, Public),
546 };
547
548 static const EnumEntry MethodOptionNames[] = {
549 LLVM_READOBJ_ENUM_CLASS_ENT(MethodOptions, Pseudo),
550 LLVM_READOBJ_ENUM_CLASS_ENT(MethodOptions, NoInherit),
551 LLVM_READOBJ_ENUM_CLASS_ENT(MethodOptions, NoConstruct),
552 LLVM_READOBJ_ENUM_CLASS_ENT(MethodOptions, CompilerGenerated),
553 LLVM_READOBJ_ENUM_CLASS_ENT(MethodOptions, Sealed),
554 };
555
556 static const EnumEntry MemberKindNames[] = {
557 LLVM_READOBJ_ENUM_CLASS_ENT(MethodKind, Vanilla),
558 LLVM_READOBJ_ENUM_CLASS_ENT(MethodKind, Virtual),
559 LLVM_READOBJ_ENUM_CLASS_ENT(MethodKind, Static),
560 LLVM_READOBJ_ENUM_CLASS_ENT(MethodKind, Friend),
561 LLVM_READOBJ_ENUM_CLASS_ENT(MethodKind, IntroducingVirtual),
562 LLVM_READOBJ_ENUM_CLASS_ENT(MethodKind, PureVirtual),
563 LLVM_READOBJ_ENUM_CLASS_ENT(MethodKind, PureIntroducingVirtual),
564 };
565
566 /// The names here all end in "*". If the simple type is a pointer type, we
567 /// return the whole name. Otherwise we lop off the last character in our
568 /// StringRef.
569 static const EnumEntry SimpleTypeNames[] = {
570 {"void*", SimpleTypeKind::Void},
571 {"*", SimpleTypeKind::NotTranslated},
572 {"HRESULT*", SimpleTypeKind::HResult},
573 {"signed char*", SimpleTypeKind::SignedCharacter},
574 {"unsigned char*", SimpleTypeKind::UnsignedCharacter},
575 {"char*", SimpleTypeKind::NarrowCharacter},
576 {"wchar_t*", SimpleTypeKind::WideCharacter},
577 {"__int8*", SimpleTypeKind::SByte},
578 {"unsigned __int8*", SimpleTypeKind::Byte},
579 {"short*", SimpleTypeKind::Int16Short},
580 {"unsigned short*", SimpleTypeKind::UInt16Short},
581 {"__int16*", SimpleTypeKind::Int16},
582 {"unsigned __int16*", SimpleTypeKind::UInt16},
583 {"long*", SimpleTypeKind::Int32Long},
584 {"unsigned long*", SimpleTypeKind::UInt32Long},
585 {"int*", SimpleTypeKind::Int32},
586 {"unsigned*", SimpleTypeKind::UInt32},
587 {"__int64*", SimpleTypeKind::Int64Quad},
588 {"unsigned __int64*", SimpleTypeKind::UInt64Quad},
589 {"__int64*", SimpleTypeKind::Int64},
590 {"unsigned __int64*", SimpleTypeKind::UInt64},
591 {"__int128*", SimpleTypeKind::Int128},
592 {"unsigned __int128*", SimpleTypeKind::UInt128},
593 {"__half*", SimpleTypeKind::Float16},
594 {"float*", SimpleTypeKind::Float32},
595 {"float*", SimpleTypeKind::Float32PartialPrecision},
596 {"__float48*", SimpleTypeKind::Float48},
597 {"double*", SimpleTypeKind::Float64},
598 {"long double*", SimpleTypeKind::Float80},
599 {"__float128*", SimpleTypeKind::Float128},
600 {"_Complex float*", SimpleTypeKind::Complex32},
601 {"_Complex double*", SimpleTypeKind::Complex64},
602 {"_Complex long double*", SimpleTypeKind::Complex80},
603 {"_Complex __float128*", SimpleTypeKind::Complex128},
604 {"bool*", SimpleTypeKind::Boolean8},
605 {"__bool16*", SimpleTypeKind::Boolean16},
606 {"__bool32*", SimpleTypeKind::Boolean32},
607 {"__bool64*", SimpleTypeKind::Boolean64},
608 };
609
610 static const EnumEntry LeafTypeNames[] = {
611 #define LEAF_TYPE(name, val) LLVM_READOBJ_ENUM_ENT(LeafType, name),
612 #include "CVLeafTypes.def"
613 };
614
615 static const EnumEntry PtrKindNames[] = {
616 LLVM_READOBJ_ENUM_CLASS_ENT(PointerKind, Near16),
617 LLVM_READOBJ_ENUM_CLASS_ENT(PointerKind, Far16),
618 LLVM_READOBJ_ENUM_CLASS_ENT(PointerKind, Huge16),
619 LLVM_READOBJ_ENUM_CLASS_ENT(PointerKind, BasedOnSegment),
620 LLVM_READOBJ_ENUM_CLASS_ENT(PointerKind, BasedOnValue),
621 LLVM_READOBJ_ENUM_CLASS_ENT(PointerKind, BasedOnSegmentValue),
622 LLVM_READOBJ_ENUM_CLASS_ENT(PointerKind, BasedOnAddress),
623 LLVM_READOBJ_ENUM_CLASS_ENT(PointerKind, BasedOnSegmentAddress),
624 LLVM_READOBJ_ENUM_CLASS_ENT(PointerKind, BasedOnType),
625 LLVM_READOBJ_ENUM_CLASS_ENT(PointerKind, BasedOnSelf),
626 LLVM_READOBJ_ENUM_CLASS_ENT(PointerKind, Near32),
627 LLVM_READOBJ_ENUM_CLASS_ENT(PointerKind, Far32),
628 LLVM_READOBJ_ENUM_CLASS_ENT(PointerKind, Near64),
629 };
630
631 static const EnumEntry PtrModeNames[] = {
632 LLVM_READOBJ_ENUM_CLASS_ENT(PointerMode, Pointer),
633 LLVM_READOBJ_ENUM_CLASS_ENT(PointerMode, LValueReference),
634 LLVM_READOBJ_ENUM_CLASS_ENT(PointerMode, PointerToDataMember),
635 LLVM_READOBJ_ENUM_CLASS_ENT(PointerMode, PointerToMemberFunction),
636 LLVM_READOBJ_ENUM_CLASS_ENT(PointerMode, RValueReference),
637 };
638
639 static const EnumEntry PtrMemberRepNames[] = {
640 LLVM_READOBJ_ENUM_CLASS_ENT(PointerToMemberRepresentation, Unknown),
641 LLVM_READOBJ_ENUM_CLASS_ENT(PointerToMemberRepresentation,
642 SingleInheritanceData),
643 LLVM_READOBJ_ENUM_CLASS_ENT(PointerToMemberRepresentation,
644 MultipleInheritanceData),
645 LLVM_READOBJ_ENUM_CLASS_ENT(PointerToMemberRepresentation,
646 VirtualInheritanceData),
647 LLVM_READOBJ_ENUM_CLASS_ENT(PointerToMemberRepresentation, GeneralData),
648 LLVM_READOBJ_ENUM_CLASS_ENT(PointerToMemberRepresentation,
649 SingleInheritanceFunction),
650 LLVM_READOBJ_ENUM_CLASS_ENT(PointerToMemberRepresentation,
651 MultipleInheritanceFunction),
652 LLVM_READOBJ_ENUM_CLASS_ENT(PointerToMemberRepresentation,
653 VirtualInheritanceFunction),
654 LLVM_READOBJ_ENUM_CLASS_ENT(PointerToMemberRepresentation, GeneralFunction),
655 };
656
657 static const EnumEntry TypeModifierNames[] = {
658 LLVM_READOBJ_ENUM_CLASS_ENT(ModifierOptions, Const),
659 LLVM_READOBJ_ENUM_CLASS_ENT(ModifierOptions, Volatile),
660 LLVM_READOBJ_ENUM_CLASS_ENT(ModifierOptions, Unaligned),
661 };
662
663 static const EnumEntry CallingConventions[] = {
664 LLVM_READOBJ_ENUM_CLASS_ENT(CallingConvention, NearC),
665 LLVM_READOBJ_ENUM_CLASS_ENT(CallingConvention, FarC),
666 LLVM_READOBJ_ENUM_CLASS_ENT(CallingConvention, NearPascal),
667 LLVM_READOBJ_ENUM_CLASS_ENT(CallingConvention, FarPascal),
668 LLVM_READOBJ_ENUM_CLASS_ENT(CallingConvention, NearFast),
669 LLVM_READOBJ_ENUM_CLASS_ENT(CallingConvention, FarFast),
670 LLVM_READOBJ_ENUM_CLASS_ENT(CallingConvention, NearStdCall),
671 LLVM_READOBJ_ENUM_CLASS_ENT(CallingConvention, FarStdCall),
672 LLVM_READOBJ_ENUM_CLASS_ENT(CallingConvention, NearSysCall),
673 LLVM_READOBJ_ENUM_CLASS_ENT(CallingConvention, FarSysCall),
674 LLVM_READOBJ_ENUM_CLASS_ENT(CallingConvention, ThisCall),
675 LLVM_READOBJ_ENUM_CLASS_ENT(CallingConvention, MipsCall),
676 LLVM_READOBJ_ENUM_CLASS_ENT(CallingConvention, Generic),
677 LLVM_READOBJ_ENUM_CLASS_ENT(CallingConvention, AlphaCall),
678 LLVM_READOBJ_ENUM_CLASS_ENT(CallingConvention, PpcCall),
679 LLVM_READOBJ_ENUM_CLASS_ENT(CallingConvention, SHCall),
680 LLVM_READOBJ_ENUM_CLASS_ENT(CallingConvention, ArmCall),
681 LLVM_READOBJ_ENUM_CLASS_ENT(CallingConvention, AM33Call),
682 LLVM_READOBJ_ENUM_CLASS_ENT(CallingConvention, TriCall),
683 LLVM_READOBJ_ENUM_CLASS_ENT(CallingConvention, SH5Call),
684 LLVM_READOBJ_ENUM_CLASS_ENT(CallingConvention, M32RCall),
685 LLVM_READOBJ_ENUM_CLASS_ENT(CallingConvention, ClrCall),
686 LLVM_READOBJ_ENUM_CLASS_ENT(CallingConvention, Inline),
687 LLVM_READOBJ_ENUM_CLASS_ENT(CallingConvention, NearVector),
688 };
689
690 static const EnumEntry FunctionOptionEnum[] = {
691 LLVM_READOBJ_ENUM_CLASS_ENT(FunctionOptions, CxxReturnUdt),
692 LLVM_READOBJ_ENUM_CLASS_ENT(FunctionOptions, Constructor),
693 LLVM_READOBJ_ENUM_CLASS_ENT(FunctionOptions, ConstructorWithVirtualBases),
694 };
695
333696 template
334697 static std::error_code getSymbolAuxData(const COFFObjectFile *Obj,
335698 COFFSymbolRef Symbol,
475838 void COFFDumper::printBaseOfDataField(const pe32plus_header *) {}
476839
477840 void COFFDumper::printCodeViewDebugInfo() {
841 // Print types first to build CVUDTNames, then print symbols.
478842 for (const SectionRef &S : Obj->sections()) {
479 StringRef SecName;
480 error(S.getName(SecName));
481 if (SecName == ".debug$S")
482 printCodeViewSection(S);
483 }
484 }
485
486 void COFFDumper::printCodeViewSection(const SectionRef &Section) {
487 StringRef Data;
488 error(Section.getContents(Data));
843 StringRef SectionName;
844 error(S.getName(SectionName));
845 if (SectionName == ".debug$T")
846 printCodeViewTypeSection(SectionName, S);
847 }
848 for (const SectionRef &S : Obj->sections()) {
849 StringRef SectionName;
850 error(S.getName(SectionName));
851 if (SectionName == ".debug$S")
852 printCodeViewSymbolSection(SectionName, S);
853 }
854 }
855
856 /// Consumes sizeof(T) bytes from the given byte sequence. Returns an error if
857 /// there are not enough bytes remaining. Reinterprets the consumed bytes as a
858 /// T object and points 'Res' at them.
859 template
860 static std::error_code consumeObject(StringRef &Data, const T *&Res) {
861 if (Data.size() < sizeof(*Res))
862 return object_error::parse_failed;
863 Res = reinterpret_cast(Data.data());
864 Data = Data.drop_front(sizeof(*Res));
865 return std::error_code();
866 }
867
868 static std::error_code consumeUInt32(StringRef &Data, uint32_t &Res) {
869 const ulittle32_t *IntPtr;
870 if (auto EC = consumeObject(Data, IntPtr))
871 return EC;
872 Res = *IntPtr;
873 return std::error_code();
874 }
875
876 void COFFDumper::printCodeViewSymbolSection(StringRef SectionName,
877 const SectionRef &Section) {
878 StringRef SectionContents;
879 error(Section.getContents(SectionContents));
880 StringRef Data = SectionContents;
489881
490882 SmallVector FunctionNames;
491883 StringMap FunctionLineTables;
884 std::map FunctionFrameData;
492885
493886 ListScope D(W, "CodeViewDebugInfo");
494 {
495 // FIXME: Add more offset correctness checks.
496 DataExtractor DE(Data, true, 4);
497 uint32_t Offset = 0,
498 Magic = DE.getU32(&Offset);
499 W.printHex("Magic", Magic);
500 if (Magic != COFF::DEBUG_SECTION_MAGIC) {
501 error(object_error::parse_failed);
502 return;
503 }
504
505 bool Finished = false;
506 while (DE.isValidOffset(Offset) && !Finished) {
507 // The section consists of a number of subsection in the following format:
508 // |Type|PayloadSize|Payload...|
509 uint32_t SubSectionType = DE.getU32(&Offset),
510 PayloadSize = DE.getU32(&Offset);
511 ListScope S(W, "Subsection");
512 W.printHex("Type", SubSectionType);
513 W.printHex("PayloadSize", PayloadSize);
514 if (PayloadSize > Data.size() - Offset) {
887 // Print the section to allow correlation with printSections.
888 W.printNumber("Section", SectionName, Obj->getSectionID(Section));
889
890 uint32_t Magic;
891 error(consumeUInt32(Data, Magic));
892 W.printHex("Magic", Magic);
893 if (Magic != COFF::DEBUG_SECTION_MAGIC)
894 return error(object_error::parse_failed);
895
896 while (!Data.empty()) {
897 // The section consists of a number of subsection in the following format:
898 // |SubSectionType|SubSectionSize|Contents...|
899 uint32_t SubType, SubSectionSize;
900 error(consumeUInt32(Data, SubType));
901 error(consumeUInt32(Data, SubSectionSize));
902
903 ListScope S(W, "Subsection");
904 W.printEnum("SubSectionType", SubType, makeArrayRef(SubSectionTypes));
905 W.printHex("SubSectionSize", SubSectionSize);
906
907 // Get the contents of the subsection.
908 if (SubSectionSize > Data.size())
909 return error(object_error::parse_failed);
910 StringRef Contents = Data.substr(0, SubSectionSize);
911
912 // Add SubSectionSize to the current offset and align that offset to find
913 // the next subsection.
914 size_t SectionOffset = Data.data() - SectionContents.data();
915 size_t NextOffset = SectionOffset + SubSectionSize;
916 NextOffset = RoundUpToAlignment(NextOffset, 4);
917 Data = SectionContents.drop_front(NextOffset);
918
919 // Optionally print the subsection bytes in case our parsing gets confused
920 // later.
921 if (opts::CodeViewSubsectionBytes)
922 W.printBinaryBlock("SubSectionContents", Contents);
923
924 switch (ModuleSubstreamKind(SubType)) {
925 case ModuleSubstreamKind::Symbols:
926 printCodeViewSymbolsSubsection(Contents, Section, SectionOffset);
927 break;
928 case ModuleSubstreamKind::Lines: {
929 // Holds a PC to file:line table. Some data to parse this subsection is
930 // stored in the other subsections, so just check sanity and store the
931 // pointers for deferred processing.
932
933 if (SubSectionSize < 12) {
934 // There should be at least three words to store two function
935 // relocations and size of the code.
515936 error(object_error::parse_failed);
516937 return;
517938 }
518939
519 StringRef Contents = Data.substr(Offset, PayloadSize);
520 if (opts::CodeViewSubsectionBytes) {
521 // Print the raw contents to simplify debugging if anything goes wrong
522 // afterwards.
523 W.printBinaryBlock("Contents", Contents);
940 StringRef LinkageName;
941 error(resolveSymbolName(Obj->getCOFFSection(Section), SectionOffset,
942 LinkageName));
943 W.printString("LinkageName", LinkageName);
944 if (FunctionLineTables.count(LinkageName) != 0) {
945 // Saw debug info for this function already?
946 error(object_error::parse_failed);
947 return;
524948 }
525949
526 switch (SubSectionType) {
527 case COFF::DEBUG_SYMBOL_SUBSECTION:
528 printCodeViewSymbolsSubsection(Contents, Section, Offset);
529 break;
530 case COFF::DEBUG_LINE_TABLE_SUBSECTION: {
531 // Holds a PC to file:line table. Some data to parse this subsection is
532 // stored in the other subsections, so just check sanity and store the
533 // pointers for deferred processing.
534
535 if (PayloadSize < 12) {
536 // There should be at least three words to store two function
537 // relocations and size of the code.
538 error(object_error::parse_failed);
539 return;
540 }
541
542 StringRef LinkageName;
543 error(resolveSymbolName(Obj->getCOFFSection(Section), Offset,
544 LinkageName));
545 W.printString("LinkageName", LinkageName);
546 if (FunctionLineTables.count(LinkageName) != 0) {
547 // Saw debug info for this function already?
548 error(object_error::parse_failed);
549 return;
550 }
551
552 FunctionLineTables[LinkageName] = Contents;
553 FunctionNames.push_back(LinkageName);
554 break;
950 FunctionLineTables[LinkageName] = Contents;
951 FunctionNames.push_back(LinkageName);
952 break;
953 }
954 case ModuleSubstreamKind::StringTable:
955 if (SubSectionSize == 0 || CVStringTable.data() != nullptr ||
956 Contents.back() != '\0') {
957 // Empty or duplicate or non-null-terminated subsection.
958 error(object_error::parse_failed);
959 return;
555960 }
556 case COFF::DEBUG_STRING_TABLE_SUBSECTION:
557 if (PayloadSize == 0 || CVStringTable.data() != nullptr ||
558 Contents.back() != '\0') {
559 // Empty or duplicate or non-null-terminated subsection.
560 error(object_error::parse_failed);
561 return;
562 }
563 CVStringTable = Contents;
564 break;
565 case COFF::DEBUG_INDEX_SUBSECTION:
566 // Holds the translation table from file indices
567 // to offsets in the string table.
568
569 if (PayloadSize == 0 ||
570 CVFileIndexToStringOffsetTable.data() != nullptr) {
571 // Empty or duplicate subsection.
572 error(object_error::parse_failed);
573 return;
574 }
575 CVFileIndexToStringOffsetTable = Contents;
576 break;
961 CVStringTable = Contents;
962 break;
963 case ModuleSubstreamKind::FileChecksums:
964 // Holds the translation table from file indices
965 // to offsets in the string table.
966
967 if (SubSectionSize == 0 ||
968 CVFileIndexToStringOffsetTable.data() != nullptr) {
969 // Empty or duplicate subsection.
970 error(object_error::parse_failed);
971 return;
577972 }
578 Offset += PayloadSize;
579
580 // Align the reading pointer by 4.
581 Offset += (-Offset) % 4;
973 CVFileIndexToStringOffsetTable = Contents;
974 break;
975 case ModuleSubstreamKind::FrameData: {
976 const size_t RelocationSize = 4;
977 if (SubSectionSize != sizeof(FrameData) + RelocationSize) {
978 // There should be exactly one relocation followed by the FrameData
979 // contents.
980 error(object_error::parse_failed);
981 return;
982 }
983
984 const auto *FD = reinterpret_cast(
985 Contents.drop_front(RelocationSize).data());
986
987 StringRef LinkageName;
988 error(resolveSymbolName(Obj->getCOFFSection(Section), SectionOffset,
989 LinkageName));
990 if (!FunctionFrameData.emplace(LinkageName, FD).second) {
991 error(object_error::parse_failed);
992 return;
993 }
994 break;
995 }
996
997 // Do nothing for unrecognized subsections.
998 default:
999 break;
5821000 }
5831001 }
5841002
6731091 }
6741092 }
6751093 }
1094
1095 for (auto FrameDataPair : FunctionFrameData) {
1096 StringRef LinkageName = FrameDataPair.first;
1097 const FrameData *FD = FrameDataPair.second;
1098 ListScope S(W, "FunctionFrameData");
1099 W.printString("LinkageName", LinkageName);
1100 W.printHex("RvaStart", FD->RvaStart);
1101 W.printHex("CodeSize", FD->CodeSize);
1102 W.printHex("LocalSize", FD->LocalSize);
1103 W.printHex("ParamsSize", FD->ParamsSize);
1104 W.printHex("MaxStackSize", FD->MaxStackSize);
1105 W.printString("FrameFunc", StringRef(CVStringTable.data() + FD->FrameFunc));
1106 W.printHex("PrologSize", FD->PrologSize);
1107 W.printHex("SavedRegsSize", FD->SavedRegsSize);
1108 W.printFlags("Flags", FD->Flags, makeArrayRef(FrameDataFlags));
1109 }
1110 }
1111
1112 static std::error_code decodeNumerictLeaf(StringRef &Data, APSInt &Num) {
1113 // Used to avoid overload ambiguity on APInt construtor.
1114 bool FalseVal = false;
1115 if (Data.size() < 2)
1116 return object_error::parse_failed;
1117 uint16_t Short = *reinterpret_cast(Data.data());
1118 Data = Data.drop_front(2);
1119 if (Short < LF_NUMERIC) {
1120 Num = APSInt(APInt(/*numBits=*/16, Short, /*isSigned=*/false),
1121 /*isUnsigned=*/true);
1122 return std::error_code();
1123 }
1124 switch (Short) {
1125 case LF_CHAR:
1126 Num = APSInt(APInt(/*numBits=*/8,
1127 *reinterpret_cast(Data.data()),
1128 /*isSigned=*/true),
1129 /*isUnsigned=*/false);
1130 Data = Data.drop_front(1);
1131 return std::error_code();
1132 case LF_SHORT:
1133 Num = APSInt(APInt(/*numBits=*/16,
1134 *reinterpret_cast(Data.data()),
1135 /*isSigned=*/true),
1136 /*isUnsigned=*/false);
1137 Data = Data.drop_front(2);
1138 return std::error_code();
1139 case LF_USHORT:
1140 Num = APSInt(APInt(/*numBits=*/16,
1141 *reinterpret_cast(Data.data()),
1142 /*isSigned=*/false),
1143 /*isUnsigned=*/true);
1144 Data = Data.drop_front(2);
1145 return std::error_code();
1146 case LF_LONG:
1147 Num = APSInt(APInt(/*numBits=*/32,
1148 *reinterpret_cast(Data.data()),
1149 /*isSigned=*/true),
1150 /*isUnsigned=*/false);
1151 Data = Data.drop_front(4);
1152 return std::error_code();
1153 case LF_ULONG:
1154 Num = APSInt(APInt(/*numBits=*/32,
1155 *reinterpret_cast(Data.data()),
1156 /*isSigned=*/FalseVal),
1157 /*isUnsigned=*/true);
1158 Data = Data.drop_front(4);
1159 return std::error_code();
1160 case LF_QUADWORD:
1161 Num = APSInt(APInt(/*numBits=*/64,
1162 *reinterpret_cast(Data.data()),
1163 /*isSigned=*/true),
1164 /*isUnsigned=*/false);
1165 Data = Data.drop_front(8);
1166 return std::error_code();
1167 case LF_UQUADWORD:
1168 Num = APSInt(APInt(/*numBits=*/64,
1169 *reinterpret_cast(Data.data()),
1170 /*isSigned=*/false),
1171 /*isUnsigned=*/true);
1172 Data = Data.drop_front(8);
1173 return std::error_code();
1174 }
1175 return object_error::parse_failed;
1176 }
1177
1178 /// Decode an unsigned integer numeric leaf value.
1179 std::error_code decodeUIntLeaf(StringRef &Data, uint64_t &Num) {
1180 APSInt N;
1181 if (std::error_code err = decodeNumerictLeaf(Data, N))
1182 return err;
1183 if (N.isSigned() || !N.isIntN(64))
1184 return object_error::parse_failed;
1185 Num = N.getLimitedValue();
1186 return std::error_code();
6761187 }
6771188
6781189 void COFFDumper::printCodeViewSymbolsSubsection(StringRef Subsection,
6791190 const SectionRef &Section,
6801191 uint32_t OffsetInSection) {
681 if (Subsection.size() == 0) {
682 error(object_error::parse_failed);
683 return;
684 }
685 DataExtractor DE(Subsection, true, 4);
686 uint32_t Offset = 0;
687
688 // Function-level subsections have "procedure start" and "procedure end"
689 // commands that should come in pairs and surround relevant info.
1192 if (Subsection.size() < sizeof(SymRecord))
1193 return error(object_error::parse_failed);
1194
1195 // This holds the remaining data to parse.
1196 StringRef Data = Subsection;
1197
6901198 bool InFunctionScope = false;
691 while (DE.isValidOffset(Offset)) {
692 // Read subsection segments one by one.
693 uint16_t Size = DE.getU16(&Offset);
694 // The section size includes the size of the type identifier.
695 if (Size < 2 || !DE.isValidOffsetForDataOfSize(Offset, Size)) {
696 error(object_error::parse_failed);
1199 while (!Data.empty()) {
1200 const SymRecord *Rec;
1201 error(consumeObject(Data, Rec));
1202
1203 StringRef SymData = Data.substr(0, Rec->RecordLength - 2);
1204
1205 Data = Data.drop_front(Rec->RecordLength - 2);
1206
1207 SymType Type = static_cast(uint16_t(Rec->RecordType));
1208 switch (Type) {
1209 case S_LPROC32:
1210 case S_GPROC32:
1211 case S_GPROC32_ID:
1212 case S_LPROC32_ID:
1213 case S_LPROC32_DPC:
1214 case S_LPROC32_DPC_ID: {
1215 DictScope S(W, "ProcStart");
1216 const ProcSym *Proc;
1217 error(consumeObject(SymData, Proc));
1218 if (InFunctionScope)
1219 return error(object_error::parse_failed);
1220 InFunctionScope = true;
1221
1222 // In a COFF object file, the CodeOffset field is typically zero and has a
1223 // relocation applied to it. Go and look up the symbol for that
1224 // relocation.
1225 ptrdiff_t SecOffsetOfCodeOffset =
1226 reinterpret_cast(&Proc->CodeOffset) - Subsection.data();
1227 StringRef LinkageName;
1228 error(resolveSymbolName(Obj->getCOFFSection(Section),
1229 OffsetInSection + SecOffsetOfCodeOffset,
1230 LinkageName));
1231
1232 StringRef DisplayName = SymData.split('\0').first;
1233 W.printHex("PtrParent", Proc->PtrParent);
1234 W.printHex("PtrEnd", Proc->PtrEnd);
1235 W.printHex("PtrNext", Proc->PtrNext);
1236 W.printHex("CodeSize", Proc->CodeSize);
1237 W.printHex("DbgStart", Proc->DbgStart);
1238 W.printHex("DbgEnd", Proc->DbgEnd);
1239 printTypeIndex("FunctionType", Proc->FunctionType);
1240 W.printHex("CodeOffset", Proc->CodeOffset);
1241 W.printHex("Segment", Proc->Segment);
1242 W.printFlags("Flags", Proc->Flags, makeArrayRef(ProcSymFlags));
1243 W.printString("DisplayName", DisplayName);
1244 W.printString("LinkageName", LinkageName);
1245 break;
1246 }
1247
1248 case S_PROC_ID_END: {
1249 W.startLine() << "ProcEnd\n";
1250 InFunctionScope = false;
1251 break;
1252 }
1253
1254 case S_BLOCK32: {
1255 DictScope S(W, "BlockStart");
1256 const BlockSym *Block;
1257 error(consumeObject(SymData, Block));
1258
1259 // In a COFF object file, the CodeOffset field is typically zero and has a
1260 // relocation applied to it. Go and look up the symbol for that
1261 // relocation.
1262 ptrdiff_t SecOffsetOfCodeOffset =
1263 reinterpret_cast(&Block->CodeOffset) - Subsection.data();
1264 StringRef LinkageName;
1265 error(resolveSymbolName(Obj->getCOFFSection(Section),
1266 OffsetInSection + SecOffsetOfCodeOffset,
1267 LinkageName));
1268
1269 StringRef BlockName = SymData.split('\0').first;
1270 W.printHex("PtrParent", Block->PtrParent);
1271 W.printHex("PtrEnd", Block->PtrEnd);
1272 W.printHex("CodeSize", Block->CodeSize);
1273 W.printHex("CodeOffset", Block->CodeOffset);
1274 W.printHex("Segment", Block->Segment);
1275 W.printString("BlockName", BlockName);
1276 W.printString("LinkageName", LinkageName);
1277 break;
1278 }
1279
1280 case S_END: {
1281 W.startLine() << "BlockEnd\n";
1282 InFunctionScope = false;
1283 break;
1284 }
1285
1286 case S_LABEL32: {
1287 DictScope S(W, "Label");
1288 const LabelSym *Label;
1289 error(consumeObject(SymData, Label));
1290
1291 // In a COFF object file, the CodeOffset field is typically zero and has a
1292 // relocation applied to it. Go and look up the symbol for that
1293 // relocation.
1294 ptrdiff_t SecOffsetOfCodeOffset =
1295 reinterpret_cast(&Label->CodeOffset) - Subsection.data();
1296 StringRef LinkageName;
1297 error(resolveSymbolName(Obj->getCOFFSection(Section),
1298 OffsetInSection + SecOffsetOfCodeOffset,
1299 LinkageName));
1300
1301 StringRef DisplayName = SymData.split('\0').first;
1302 W.printHex("CodeOffset", Label->CodeOffset);
1303 W.printHex("Segment", Label->Segment);
1304 W.printHex("Flags", Label->Flags);
1305 W.printFlags("Flags", Label->Flags, makeArrayRef(ProcSymFlags));
1306 W.printString("DisplayName", DisplayName);
1307 W.printString("LinkageName", LinkageName);
1308 break;
1309 }
1310
1311 case S_INLINESITE: {
1312 DictScope S(W, "InlineSite");
1313 const InlineSiteSym *InlineSite;
1314 error(consumeObject(SymData, InlineSite));
1315 W.printHex("PtrParent", InlineSite->PtrParent);
1316 W.printHex("PtrEnd", InlineSite->PtrEnd);
1317 printTypeIndex("Inlinee", InlineSite->Inlinee);
1318 W.printBinaryBlock("BinaryAnnotations", SymData);
1319 break;
1320 }
1321
1322 case S_INLINESITE_END: {
1323 DictScope S(W, "InlineSiteEnd");
1324 break;
1325 }
1326
1327 case S_LOCAL: {
1328 DictScope S(W, "Local");
1329 const LocalSym *Local;
1330 error(consumeObject(SymData, Local));
1331 printTypeIndex("Type", Local->Type);
1332 W.printFlags("Flags", uint16_t(Local->Flags), makeArrayRef(LocalFlags));
1333 StringRef VarName = SymData.split('\0').first;
1334 W.printString("VarName", VarName);
1335 break;
1336 }
1337
1338 case S_CALLSITEINFO: {
1339 DictScope S(W, "CallSiteInfo");
1340 const CallSiteInfoSym *CallSiteInfo;
1341 error(consumeObject(SymData, CallSiteInfo));
1342
1343 // In a COFF object file, the CodeOffset field is typically zero and has a
1344 // relocation applied to it. Go and look up the symbol for that
1345 // relocation.
1346 ptrdiff_t SecOffsetOfCodeOffset =
1347 reinterpret_cast(&CallSiteInfo->CodeOffset) - Subsection.data();
1348 StringRef LinkageName;
1349 error(resolveSymbolName(Obj->getCOFFSection(Section),
1350 OffsetInSection + SecOffsetOfCodeOffset,
1351 LinkageName));
1352 W.printHex("CodeOffset", CallSiteInfo->CodeOffset);
1353 W.printHex("Segment", CallSiteInfo->Segment);
1354 W.printHex("Reserved", CallSiteInfo->Reserved);
1355 printTypeIndex("Type", CallSiteInfo->Type);
1356 W.printString("LinkageName", LinkageName);
1357 break;
1358 }
1359
1360 case S_HEAPALLOCSITE: {
1361 DictScope S(W, "HeapAllocationSite");
1362 const HeapAllocationSiteSym *HeapAllocationSite;
1363 error(consumeObject(SymData, HeapAllocationSite));
1364
1365 // In a COFF object file, the CodeOffset field is typically zero and has a
1366 // relocation applied to it. Go and look up the symbol for that
1367 // relocation.
1368 ptrdiff_t SecOffsetOfCodeOffset =
1369 reinterpret_cast(&HeapAllocationSite->CodeOffset) -
1370 Subsection.data();
1371 StringRef LinkageName;
1372 error(resolveSymbolName(Obj->getCOFFSection(Section),
1373 OffsetInSection + SecOffsetOfCodeOffset,
1374 LinkageName));
1375 W.printHex("CodeOffset", HeapAllocationSite->CodeOffset);
1376 W.printHex("Segment", HeapAllocationSite->Segment);
1377 W.printHex("CallInstructionSize",
1378 HeapAllocationSite->CallInstructionSize);
1379 printTypeIndex("Type", HeapAllocationSite->Type);
1380 W.printString("LinkageName", LinkageName);
1381 break;
1382 }
1383
1384 case S_FRAMECOOKIE: {
1385 DictScope S(W, "FrameCookie");
1386 const FrameCookieSym *FrameCookie;
1387 error(consumeObject(SymData, FrameCookie));
1388 W.printHex("CodeOffset", FrameCookie->CodeOffset);
1389 W.printHex("Register", FrameCookie->Register);
1390 W.printEnum("CookieKind", uint16_t(FrameCookie->CookieKind),
1391 makeArrayRef(FrameCookieKinds));
1392 break;
1393 }
1394
1395 case S_LDATA32:
1396 case S_GDATA32:
1397 case S_LMANDATA:
1398 case S_GMANDATA: {
1399 DictScope S(W, "DataSym");
1400 const DataSym *Data;
1401 error(consumeObject(SymData, Data));
1402
1403 // In a COFF object file, the DataOffset field is typically zero and has a
1404 // relocation applied to it. Go and look up the symbol for that
1405 // relocation.
1406 ptrdiff_t SecOffsetOfDataOffset =
1407 reinterpret_cast(&Data->DataOffset) - Subsection.data();
1408 StringRef LinkageName;
1409 error(resolveSymbolName(Obj->getCOFFSection(Section),
1410 OffsetInSection + SecOffsetOfDataOffset,
1411 LinkageName));
1412 StringRef DisplayName = SymData.split('\0').first;
1413 W.printHex("DataOffset", Data->DataOffset);
1414 printTypeIndex("Type", Data->Type);
1415 W.printString("DisplayName", DisplayName);
1416 W.printString("LinkageName", LinkageName);
1417 break;
1418 }
1419 case S_LTHREAD32:
1420 case S_GTHREAD32: {
1421 DictScope S(W, "ThreadLocalDataSym");
1422 const DataSym *Data;
1423 error(consumeObject(SymData, Data));
1424
1425 // In a COFF object file, the DataOffset field is typically zero and has a
1426 // relocation applied to it. Go and look up the symbol for that
1427 // relocation.
1428 ptrdiff_t SecOffsetOfDataOffset =
1429 reinterpret_cast(&Data->DataOffset) - Subsection.data();
1430 StringRef LinkageName;
1431 error(resolveSymbolName(Obj->getCOFFSection(Section),
1432 OffsetInSection + SecOffsetOfDataOffset,
1433 LinkageName));
1434 StringRef DisplayName = SymData.split('\0').first;
1435 W.printHex("DataOffset", Data->DataOffset);
1436 printTypeIndex("Type", Data->Type);
1437 W.printString("DisplayName", DisplayName);
1438 W.printString("LinkageName", LinkageName);
1439 break;
1440 }
1441
1442 case S_OBJNAME: {
1443 DictScope S(W, "ObjectName");
1444 const ObjNameSym *ObjName;
1445 error(consumeObject(SymData, ObjName));
1446 W.printHex("Signature", ObjName->Signature);
1447 StringRef ObjectName = SymData.split('\0').first;
1448 W.printString("ObjectName", ObjectName);
1449 break;
1450 }
1451
1452 case S_COMPILE3: {
1453 DictScope S(W, "CompilerFlags");
1454 const CompileSym3 *CompFlags;
1455 error(consumeObject(SymData, CompFlags));
1456 W.printEnum("Language", CompFlags->getLanguage(),
1457 makeArrayRef(SourceLanguages));
1458 W.printFlags("Flags", CompFlags->flags & ~0xff,
1459 makeArrayRef(CompileSym3Flags));
1460 W.printEnum("Machine", unsigned(CompFlags->Machine),
1461 makeArrayRef(CPUTypeNames));
1462 std::string FrontendVersion;
1463 {
1464 raw_string_ostream Out(FrontendVersion);
1465 Out << CompFlags->VersionFrontendMajor << '.'
1466 << CompFlags->VersionFrontendMinor << '.'
1467 << CompFlags->VersionFrontendBuild << '.'
1468 << CompFlags->VersionFrontendQFE;
1469 }
1470 std::string BackendVersion;
1471 {
1472 raw_string_ostream Out(BackendVersion);
1473 Out << CompFlags->VersionBackendMajor << '.'
1474 << CompFlags->VersionBackendMinor << '.'
1475 << CompFlags->VersionBackendBuild << '.'
1476 << CompFlags->VersionBackendQFE;
1477 }
1478 W.printString("FrontendVersion", FrontendVersion);
1479 W.printString("BackendVersion", BackendVersion);
1480 StringRef VersionName = SymData.split('\0').first;
1481 W.printString("VersionName", VersionName);
1482 break;
1483 }
1484
1485 case S_FRAMEPROC: {
1486 DictScope S(W, "FrameProc");
1487 const FrameProcSym *FrameProc;
1488 error(consumeObject(SymData, FrameProc));
1489 W.printHex("TotalFrameBytes", FrameProc->TotalFrameBytes);
1490 W.printHex("PaddingFrameBytes", FrameProc->PaddingFrameBytes);
1491 W.printHex("OffsetToPadding", FrameProc->OffsetToPadding);
1492 W.printHex("BytesOfCalleeSavedRegisters", FrameProc->BytesOfCalleeSavedRegisters);
1493 W.printHex("OffsetOfExceptionHandler", FrameProc->OffsetOfExceptionHandler);
1494 W.printHex("SectionIdOfExceptionHandler", FrameProc->SectionIdOfExceptionHandler);
1495 W.printFlags("Flags", FrameProc->Flags, makeArrayRef(FrameProcSymFlags));
1496 break;
1497 }
1498
1499 case S_UDT:
1500 case S_COBOLUDT: {
1501 DictScope S(W, "UDT");
1502 const UDTSym *UDT;
1503 error(consumeObject(SymData, UDT));
1504 printTypeIndex("Type", UDT->Type);
1505 StringRef UDTName = SymData.split('\0').first;
1506 W.printString("UDTName", UDTName);
1507 break;
1508 }
1509
1510 case S_BPREL32: {
1511 DictScope S(W, "BPRelativeSym");
1512 const BPRelativeSym *BPRel;
1513 error(consumeObject(SymData, BPRel));
1514 W.printHex("Offset", BPRel->Offset);
1515 printTypeIndex("Type", BPRel->Type);
1516 StringRef VarName = SymData.split('\0').first;
1517 W.printString("VarName", VarName);
1518 break;
1519 }
1520
1521 case S_REGREL32: {
1522 DictScope S(W, "RegRelativeSym");
1523 const RegRelativeSym *RegRel;
1524 error(consumeObject(SymData, RegRel));
1525 W.printHex("Offset", RegRel->Offset);
1526 printTypeIndex("Type", RegRel->Type);
1527 W.printHex("Register", RegRel->Register);
1528 StringRef VarName = SymData.split('\0').first;
1529 W.printString("VarName", VarName);
1530 break;
1531 }
1532
1533 case S_BUILDINFO: {
1534 DictScope S(W, "BuildInfo");
1535 const BuildInfoSym *BuildInfo;
1536 error(consumeObject(SymData, BuildInfo));
1537 W.printNumber("BuildId", BuildInfo->BuildId);
1538 break;
1539 }
1540
1541 case S_CONSTANT:
1542 case S_MANCONSTANT: {
1543 DictScope S(W, "Constant");
1544 const ConstantSym *Constant;
1545 error(consumeObject(SymData, Constant));
1546 printTypeIndex("Type", Constant->Type);
1547 APSInt Value;
1548 error(decodeNumerictLeaf(SymData, Value));
1549 W.printNumber("Value", Value);
1550 StringRef Name = SymData.split('\0').first;
1551 W.printString("Name", Name);
1552 break;
1553 }
1554
1555 default: {
1556 DictScope S(W, "UnknownSym");
1557 W.printHex("Type", unsigned(Type));
1558 W.printHex("Size", Rec->RecordLength);
1559 W.printBinaryBlock("SymData", SymData);
1560 break;
1561 }
1562 }
1563 }
1564 }
1565
1566 StringRef getRemainingTypeBytes(const TypeRecord *Rec, const char *Start) {
1567 ptrdiff_t StartOffset = Start - reinterpret_cast(Rec);
1568 size_t RecSize = Rec->Len + 2;
1569 assert(StartOffset >= 0 && "negative start-offset!");
1570 assert(static_cast(StartOffset) <= RecSize &&
1571 "Start beyond the end of Rec");
1572 return StringRef(Start, RecSize - StartOffset);
1573 }
1574
1575 StringRef getRemainingBytesAsString(const TypeRecord *Rec, const char *Start) {
1576 StringRef Remaining = getRemainingTypeBytes(Rec, Start);
1577 StringRef Leading, Trailing;
1578 std::tie(Leading, Trailing) = Remaining.split('\0');
1579 return Leading;
1580 }
1581
1582 StringRef COFFDumper::getTypeName(TypeIndex TI) {
1583 if (TI.isNoType())
1584 return "";
1585
1586 if (TI.isSimple()) {
1587 // This is a simple type.
1588 for (const auto &SimpleTypeName : SimpleTypeNames) {
1589 if (SimpleTypeName.Value == TI.getSimpleKind()) {
1590 if (TI.getSimpleMode() == SimpleTypeMode::Direct)
1591 return SimpleTypeName.Name.drop_back(1);
1592 // Otherwise, this is a pointer type. We gloss over the distinction
1593 // between near, far, 64, 32, etc, and just give a pointer type.
1594 return SimpleTypeName.Name;
1595 }
1596 }
1597 return "";
1598 }
1599
1600 // User-defined type.
1601 StringRef UDTName;
1602 unsigned UDTIndex = TI.getIndex() - 0x1000;
1603 if (UDTIndex < CVUDTNames.size())
1604 return CVUDTNames[UDTIndex];
1605
1606 return "";
1607 }
1608
1609 void COFFDumper::printTypeIndex(StringRef FieldName, TypeIndex TI) {
1610 StringRef TypeName;
1611 if (!TI.isNoType())
1612 TypeName = getTypeName(TI);
1613 if (!TypeName.empty())
1614 W.printHex(FieldName, TypeName, TI.getIndex());
1615 else
1616 W.printHex(FieldName, TI.getIndex());
1617 }
1618
1619 static StringRef getLeafTypeName(LeafType LT) {
1620 switch (LT) {
1621 case LF_STRING_ID: return "StringId";
1622 case LF_FIELDLIST: return "FieldList";
1623 case LF_ARGLIST:
1624 case LF_SUBSTR_LIST: return "ArgList";
1625 case LF_CLASS:
1626 case LF_STRUCTURE:
1627 case LF_INTERFACE: return "ClassType";
1628 case LF_UNION: return "UnionType";
1629 case LF_ENUM: return "EnumType";
1630 case LF_ARRAY: return "ArrayType";
1631 case LF_VFTABLE: return "VFTableType";
1632 case LF_MFUNC_ID: return "MemberFuncId";
1633 case LF_PROCEDURE: return "ProcedureType";
1634 case LF_MFUNCTION: return "MemberFunctionType";
1635 case LF_METHODLIST: return "MethodListEntry";
1636 case LF_FUNC_ID: return "FuncId";
1637 case LF_TYPESERVER2: return "TypeServer2";
1638 case LF_POINTER: return "PointerType";
1639 case LF_MODIFIER: return "TypeModifier";
1640 case LF_VTSHAPE: return "VTableShape";
1641 case LF_UDT_SRC_LINE: return "UDTSrcLine";
1642 case LF_BUILDINFO: return "BuildInfo";
1643 default: break;
1644 }
1645 return "UnknownLeaf";
1646 }
1647
1648 void COFFDumper::printCodeViewTypeSection(StringRef SectionName,
1649 const SectionRef &Section) {
1650 ListScope D(W, "CodeViewTypes");
1651 W.printNumber("Section", SectionName, Obj->getSectionID(Section));
1652 StringRef Data;
1653 error(Section.getContents(Data));
1654 W.printBinaryBlock("Data", Data);
1655
1656 unsigned Magic = *reinterpret_cast(Data.data());
1657 W.printHex("Magic", Magic);
1658
1659 Data = Data.drop_front(4);
1660
1661 while (!Data.empty()) {
1662 const TypeRecord *Rec;
1663 error(consumeObject(Data, Rec));
1664 auto Leaf = static_cast(uint16_t(Rec->Leaf));
1665
1666 // This record is 'Len - 2' bytes, and the next one starts immediately
1667 // afterwards.
1668 StringRef LeafData = Data.substr(0, Rec->Len - 2);
1669 StringRef RemainingData = Data.drop_front(LeafData.size());
1670
1671 // Find the name of this leaf type.
1672 StringRef LeafName = getLeafTypeName(Leaf);
1673 DictScope S(W, LeafName);
1674 unsigned NextTypeIndex = 0x1000 + CVUDTNames.size();
1675 W.printEnum("LeafType", unsigned(Leaf), makeArrayRef(LeafTypeNames));
1676 W.printHex("TypeIndex", NextTypeIndex);
1677
1678 // Fill this in inside the switch to get something in CVUDTNames.
1679 StringRef Name;
1680
1681 switch (Leaf) {
1682 default: {
1683 W.printHex("Size", Rec->Len);
1684 if (opts::CodeViewSubsectionBytes)
1685 W.printBinaryBlock("LeafData", LeafData);
1686 break;
1687 }
1688
1689 case LF_STRING_ID: {
1690 const StringId *String;
1691 error(consumeObject(LeafData, String));
1692 W.printHex("Id", String->id.getIndex());
1693 StringRef StringData = getRemainingBytesAsString(Rec, LeafData.data());
1694 W.printString("StringData", StringData);
1695 // Put this in CVUDTNames so it gets printed with LF_UDT_SRC_LINE.
1696 Name = StringData;
1697 break;
1698 }
1699
1700 case LF_FIELDLIST: {
1701 W.printHex("Size", Rec->Len);
1702 // FieldList has no fixed prefix that can be described with a struct. All
1703 // the bytes must be interpreted as more records.
1704 printCodeViewFieldList(LeafData);
1705 break;
1706 }
1707
1708 case LF_ARGLIST:
1709 case LF_SUBSTR_LIST: {
1710 const ArgList *Args;
1711 error(consumeObject(LeafData, Args));
1712 W.printNumber("NumArgs", Args->NumArgs);
1713 ListScope Arguments(W, "Arguments");
1714 SmallString<256> TypeName("(");
1715 for (uint32_t ArgI = 0; ArgI != Args->NumArgs; ++ArgI) {
1716 const TypeIndex *Type;
1717 error(consumeObject(LeafData, Type));
1718 printTypeIndex("ArgType", *Type);
1719 StringRef ArgTypeName = getTypeName(*Type);
1720 TypeName.append(ArgTypeName);
1721 if (ArgI + 1 != Args->NumArgs)
1722 TypeName.append(", ");
1723 }
1724 TypeName.push_back(')');
1725 Name = TypeNames.insert(TypeName).first->getKey();
1726 break;
1727 }
1728
1729 case LF_CLASS:
1730 case LF_STRUCTURE:
1731 case LF_INTERFACE: {
1732 const ClassType *Class;
1733 error(consumeObject(LeafData, Class));
1734 W.printNumber("MemberCount", Class->MemberCount);
1735 uint16_t Props = Class->Properties;
1736 W.printFlags("Properties", Props, makeArrayRef(ClassOptionNames));
1737 printTypeIndex("FieldList", Class->FieldList);
1738 printTypeIndex("DerivedFrom", Class->DerivedFrom);
1739 printTypeIndex("VShape", Class->VShape);
1740 uint64_t SizeOf;
1741 error(decodeUIntLeaf(LeafData, SizeOf));
1742 W.printNumber("SizeOf", SizeOf);
1743 StringRef LinkageName;
1744 std::tie(Name, LinkageName) = LeafData.split('\0');
1745 W.printString("Name", Name);
1746 if (Props & uint16_t(ClassOptions::HasUniqueName)) {
1747 LinkageName = getRemainingBytesAsString(Rec, LinkageName.data());
1748 if (LinkageName.empty())
1749 return error(object_error::parse_failed);
1750 W.printString("LinkageName", LinkageName);
1751 }
1752 break;
1753 }
1754
1755 case LF_UNION: {
1756 const UnionType *Union;
1757 error(consumeObject(LeafData, Union));
1758 W.printNumber("MemberCount", Union->MemberCount);
1759 uint16_t Props = Union->Properties;
1760 W.printFlags("Properties", Props, makeArrayRef(ClassOptionNames));
1761 printTypeIndex("FieldList", Union->FieldList);
1762 uint64_t SizeOf;
1763 error(decodeUIntLeaf(LeafData, SizeOf));
1764 W.printNumber("SizeOf", SizeOf);
1765 StringRef LinkageName;
1766 std::tie(Name, LinkageName) = LeafData.split('\0');
1767 W.printString("Name", Name);
1768 if (Props & uint16_t(ClassOptions::HasUniqueName)) {
1769 LinkageName = getRemainingBytesAsString(Rec, LinkageName.data());
1770 if (LinkageName.empty())
1771 return error(object_error::parse_failed);
1772 W.printString("LinkageName", LinkageName);
1773 }
1774 break;
1775 }
1776
1777 case LF_ENUM: {
1778 const EnumType *Enum;
1779 error(consumeObject(LeafData, Enum));
1780 W.printNumber("NumEnumerators", Enum->NumEnumerators);
1781 W.printFlags("Properties", uint16_t(Enum->Properties),
1782 makeArrayRef(ClassOptionNames));
1783 printTypeIndex("UnderlyingType", Enum->UnderlyingType);
1784 printTypeIndex("FieldListType", Enum->FieldListType);
1785 Name = LeafData.split('\0').first;
1786 W.printString("Name", Name);
1787 break;
1788 }
1789
1790 case LF_ARRAY: {
1791 const ArrayType *AT;
1792 error(consumeObject(LeafData, AT));
1793 printTypeIndex("ElementType", AT->ElementType);
1794 printTypeIndex("IndexType", AT->IndexType);
1795 uint64_t SizeOf;
1796 error(decodeUIntLeaf(LeafData, SizeOf));
1797 W.printNumber("SizeOf", SizeOf);
1798 Name = LeafData.split('\0').first;
1799 W.printString("Name", Name);
1800 break;
1801 }
1802
1803 case LF_VFTABLE: {
1804 const VFTableType *VFT;
1805 error(consumeObject(LeafData, VFT));
1806 printTypeIndex("CompleteClass", VFT->CompleteClass);
1807 printTypeIndex("OverriddenVFTable", VFT->OverriddenVFTable);
1808 W.printHex("VFPtrOffset", VFT->VFPtrOffset);
1809 StringRef NamesData = LeafData.substr(0, VFT->NamesLen);
1810 std::tie(Name, NamesData) = NamesData.split('\0');
1811 W.printString("VFTableName", Name);
1812 while (!NamesData.empty()) {
1813 StringRef MethodName;
1814 std::tie(MethodName, NamesData) = NamesData.split('\0');
1815 W.printString("MethodName", MethodName);
1816 }
1817 break;
1818 }
1819
1820 case LF_MFUNC_ID: {
1821 const MemberFuncId *Id;
1822 error(consumeObject(LeafData, Id));
1823 printTypeIndex("ClassType", Id->ClassType);
1824 printTypeIndex("FunctionType", Id->FunctionType);
1825 Name = LeafData.split('\0').first;
1826 W.printString("Name", Name);
1827 break;
1828 }
1829
1830 case LF_PROCEDURE: {
1831 const ProcedureType *Proc;
1832 error(consumeObject(LeafData, Proc));
1833 printTypeIndex("ReturnType", Proc->ReturnType);
1834 W.printEnum("CallingConvention", uint8_t(Proc->CallConv),
1835 makeArrayRef(CallingConventions));
1836 W.printFlags("FunctionOptions", uint8_t(Proc->Options),
1837 makeArrayRef(FunctionOptionEnum));
1838 W.printNumber("NumParameters", Proc->NumParameters);
1839 printTypeIndex("ArgListType", Proc->ArgListType);
1840
1841 StringRef ReturnTypeName = getTypeName(Proc->ReturnType);
1842 StringRef ArgListTypeName = getTypeName(Proc->ArgListType);
1843 SmallString<256> TypeName(ReturnTypeName);
1844 TypeName.push_back(' ');
1845 TypeName.append(ArgListTypeName);
1846 Name = TypeNames.insert(TypeName).first->getKey();
1847 break;
1848 }
1849
1850 case LF_MFUNCTION: {
1851 const MemberFunctionType *MemberFunc;
1852 error(consumeObject(LeafData, MemberFunc));
1853 printTypeIndex("ReturnType", MemberFunc->ReturnType);
1854 printTypeIndex("ClassType", MemberFunc->ClassType);
1855 printTypeIndex("ThisType", MemberFunc->ThisType);
1856 W.printEnum("CallingConvention", uint8_t(MemberFunc->CallConv),
1857 makeArrayRef(CallingConventions));
1858 W.printFlags("FunctionOptions", uint8_t(MemberFunc->Options),
1859 makeArrayRef(FunctionOptionEnum));
1860 W.printNumber("NumParameters", MemberFunc->NumParameters);
1861 printTypeIndex("ArgListType", MemberFunc->ArgListType);
1862 W.printNumber("ThisAdjustment", MemberFunc->ThisAdjustment);
1863
1864 StringRef ReturnTypeName = getTypeName(MemberFunc->ReturnType);
1865 StringRef ClassTypeName = getTypeName(MemberFunc->ClassType);
1866 StringRef ArgListTypeName = getTypeName(MemberFunc->ArgListType);
1867 SmallString<256> TypeName(ReturnTypeName);
1868 TypeName.push_back(' ');
1869 TypeName.append(ClassTypeName);
1870 TypeName.append("::");
1871 TypeName.append(ArgListTypeName);
1872 Name = TypeNames.insert(TypeName).first->getKey();
1873 break;
1874 }
1875
1876 case LF_METHODLIST: {
1877 while (!LeafData.empty()) {
1878 const MethodListEntry *Method;
1879 error(consumeObject(LeafData, Method));
1880 ListScope S(W, "Method");
1881 printMemberAttributes(Method->Attrs);
1882 printTypeIndex("Type", Method->Type);
1883 if (Method->isIntroducedVirtual()) {
1884 const little32_t *VFTOffsetPtr;
1885 error(consumeObject(LeafData, VFTOffsetPtr));
1886 W.printHex("VFTableOffset", *VFTOffsetPtr);
1887 }
1888 }
1889 break;
1890 }
1891
1892 case LF_FUNC_ID: {
1893 const FuncId *Func;
1894 error(consumeObject(LeafData, Func));
1895 printTypeIndex("ParentScope", Func->ParentScope);
1896 printTypeIndex("FunctionType", Func->FunctionType);
1897 StringRef Name, Null;
1898 std::tie(Name, Null) = LeafData.split('\0');
1899 W.printString("Name", Name);
1900 break;
1901 }
1902
1903 case LF_TYPESERVER2: {
1904 const TypeServer2 *TypeServer;
1905 error(consumeObject(LeafData, TypeServer));
1906 W.printBinary("Signature", StringRef(TypeServer->Signature, 16));
1907 W.printNumber("Age", TypeServer->Age);
1908 Name = LeafData.split('\0').first;
1909 W.printString("Name", Name);
1910 break;
1911 }
1912
1913 case LF_POINTER: {
1914 const PointerType *Ptr;
1915 error(consumeObject(LeafData, Ptr));
1916 printTypeIndex("PointeeType", Ptr->PointeeType);
1917 W.printHex("PointerAttributes", Ptr->Attrs);
1918 W.printEnum("PtrType", unsigned(Ptr->getPtrKind()),
1919 makeArrayRef(PtrKindNames));
1920 W.printEnum("PtrMode", unsigned(Ptr->getPtrMode()),
1921 makeArrayRef(PtrModeNames));
1922 W.printNumber("IsFlat", Ptr->isFlat());
1923 W.printNumber("IsConst", Ptr->isConst());
1924 W.printNumber("IsVolatile", Ptr->isVolatile());
1925 W.printNumber("IsUnaligned", Ptr->isUnaligned());
1926
1927 if (Ptr->isPointerToMember()) {
1928 const PointerToMemberTail *PMT;
1929 error(consumeObject(LeafData, PMT));
1930 printTypeIndex("ClassType", PMT->ClassType);
1931 W.printEnum("Representation", PMT->Representation,
1932 makeArrayRef(PtrMemberRepNames));
1933
1934 StringRef PointeeName = getTypeName(Ptr->PointeeType);
1935 StringRef ClassName = getTypeName(PMT->ClassType);
1936 SmallString<256> TypeName(PointeeName);
1937 TypeName.push_back(' ');
1938 TypeName.append(ClassName);
1939 TypeName.append("::*");
1940 Name = TypeNames.insert(TypeName).first->getKey();
1941 } else {
1942 W.printBinaryBlock("TailData", LeafData);
1943
1944 SmallString<256> TypeName;
1945 if (Ptr->isConst())
1946 TypeName.append("const ");
1947 if (Ptr->isVolatile())
1948 TypeName.append("volatile ");
1949 if (Ptr->isUnaligned())
1950 TypeName.append("__unaligned ");
1951
1952 TypeName.append(getTypeName(Ptr->PointeeType));
1953
1954 if (Ptr->getPtrMode() == PointerMode::LValueReference)
1955 TypeName.append("&");
1956 else if (Ptr->getPtrMode() == PointerMode::RValueReference)
1957 TypeName.append("&&");
1958 else if (Ptr->getPtrMode() == PointerMode::Pointer)
1959 TypeName.append("*");
1960
1961 Name = TypeNames.insert(TypeName).first->getKey();
1962 }
1963 break;
1964 }
1965
1966 case LF_MODIFIER: {
1967 const TypeModifier *Mod;
1968 error(consumeObject(LeafData, Mod));
1969 printTypeIndex("ModifiedType", Mod->ModifiedType);
1970 W.printFlags("Modifiers", Mod->Modifiers,
1971 makeArrayRef(TypeModifierNames));
1972
1973 StringRef ModifiedName = getTypeName(Mod->ModifiedType);
1974 SmallString<256> TypeName;
1975 if (Mod->Modifiers & uint16_t(ModifierOptions::Const))
1976 TypeName.append("const ");
1977 if (Mod->Modifiers & uint16_t(ModifierOptions::Volatile))
1978 TypeName.append("volatile ");
1979 if (Mod->Modifiers & uint16_t(ModifierOptions::Unaligned))
1980 TypeName.append("__unaligned ");
1981 TypeName.append(ModifiedName);
1982 Name = TypeNames.insert(TypeName).first->getKey();
1983 break;
1984 }
1985
1986 case LF_VTSHAPE: {
1987 const VTableShape *Shape;
1988 error(consumeObject(LeafData, Shape));
1989 unsigned VFEntryCount = Shape->VFEntryCount;
1990 W.printNumber("VFEntryCount", VFEntryCount);
1991 // We could print out whether the methods are near or far, but in practice
1992 // today everything is CV_VTS_near32, so it's just noise.
1993 break;
1994 }
1995
1996 case LF_UDT_SRC_LINE: {
1997 const UDTSrcLine *Line;
1998 error(consumeObject(LeafData, Line));
1999 printTypeIndex("UDT", Line->UDT);
2000 printTypeIndex("SourceFile", Line->SourceFile);
2001 W.printNumber("LineNumber", Line->LineNumber);
2002 break;
2003 }
2004
2005 case LF_BUILDINFO: {
2006 const BuildInfo *Args;
2007 error(consumeObject(LeafData, Args));
2008 W.printNumber("NumArgs", Args->NumArgs);
2009
2010 ListScope Arguments(W, "Arguments");
2011 for (uint32_t ArgI = 0; ArgI != Args->NumArgs; ++ArgI) {
2012 const TypeIndex *Type;
2013 error(consumeObject(LeafData, Type));
2014 printTypeIndex("ArgType", *Type);
2015 }
2016 break;
2017 }
2018 }
2019
2020 CVUDTNames.push_back(Name);
2021
2022 Data = RemainingData;
2023 // FIXME: The stream contains LF_PAD bytes that we need to ignore, but those
2024 // are typically included in LeafData. We may need to call skipPadding() if
2025 // we ever find a record that doesn't count those bytes.
2026 }
2027 }
2028
2029 static StringRef skipPadding(StringRef Data) {
2030 if (Data.empty())
2031 return Data;
2032 uint8_t Leaf = Data.front();
2033 if (Leaf < LF_PAD0)
2034 return Data;
2035 // Leaf is greater than 0xf0. We should advance by the number of bytes in the
2036 // low 4 bits.
2037 return Data.drop_front(Leaf & 0x0F);
2038 }
2039
2040 void COFFDumper::printMemberAttributes(MemberAttributes Attrs) {
2041 W.printEnum("AccessSpecifier", uint8_t(Attrs.getAccess()),
2042 makeArrayRef(MemberAccessNames));
2043 auto MK = Attrs.getMethodKind();
2044 // Data members will be vanilla. Don't try to print a method kind for them.
2045 if (MK != MethodKind::Vanilla)
2046 W.printEnum("MethodKind", unsigned(MK), makeArrayRef(MemberKindNames));
2047 if (Attrs.getFlags() != MethodOptions::None) {
2048 W.printFlags("MethodOptions", unsigned(Attrs.getFlags()),
2049 makeArrayRef(MethodOptionNames));
2050 }
2051 }
2052
2053 void COFFDumper::printCodeViewFieldList(StringRef FieldData) {
2054 while (!FieldData.empty()) {
2055 const ulittle16_t *LeafPtr;
2056 error(consumeObject(FieldData, LeafPtr));
2057 uint16_t Leaf = *LeafPtr;
2058 switch (Leaf) {
2059 default:
2060 W.printHex("UnknownMember", Leaf);
2061 // We can't advance once we hit an unknown field. The size is not encoded.
6972062 return;
698 }
699 Size -= 2;
700 uint16_t Type = DE.getU16(&Offset);
701 switch (Type) {
702 case COFF::DEBUG_SYMBOL_TYPE_PROC_START: {
703 DictScope S(W, "ProcStart");
704 if (InFunctionScope || Size < 36) {
705 error(object_error::parse_failed);
706 return;
2063
2064 case LF_NESTTYPE: {
2065 const NestedType *Nested;
2066 error(consumeObject(FieldData, Nested));
2067 DictScope S(W, "NestedType");
2068 printTypeIndex("Type", Nested->Type);
2069 StringRef Name;
2070 std::tie(Name, FieldData) = FieldData.split('\0');
2071 W.printString("Name", Name);
2072 break;
2073 }
2074
2075 case LF_ONEMETHOD: {
2076 const OneMethod *Method;
2077 error(consumeObject(FieldData, Method));
2078 DictScope S(W, "OneMethod");
2079 printMemberAttributes(Method->Attrs);
2080 printTypeIndex("Type", Method->Type);
2081 // If virtual, then read the vftable offset.
2082 if (Method->isIntroducedVirtual()) {
2083 const little32_t *VFTOffsetPtr;
2084 error(consumeObject(FieldData, VFTOffsetPtr));
2085 W.printHex("VFTableOffset", *VFTOffsetPtr);
7072086 }
708 InFunctionScope = true;
709
710 // We're currently interested in a limited subset of fields in this
711 // segment, just ignore the rest of the fields for now.
712 uint8_t Unused[12];
713 DE.getU8(&Offset, Unused, 12);
714 uint32_t CodeSize = DE.getU32(&Offset);
715 DE.getU8(&Offset, Unused, 12);
716 StringRef SectionName;
717 error(resolveSymbolName(Obj->getCOFFSection(Section),
718 OffsetInSection + Offset, SectionName));
719 Offset += 4;
720 DE.getU8(&Offset, Unused, 3);
721 StringRef DisplayName = DE.getCStr(&Offset);
722 if (!DE.isValidOffset(Offset)) {
723 error(object_error::parse_failed);
724 return;
725 }
726 W.printString("DisplayName", DisplayName);
727 W.printString("Section", SectionName);
728 W.printHex("CodeSize", CodeSize);
729
730 break;
731 }
732 case COFF::DEBUG_SYMBOL_TYPE_PROC_END: {
733 W.startLine() << "ProcEnd\n";
734 if (!InFunctionScope || Size > 0) {
735 error(object_error::parse_failed);
736 return;
737 }
738 InFunctionScope = false;
739 break;
740 }
741 default: {
742 if (opts::CodeViewSubsectionBytes) {
743 ListScope S(W, "Record");
744 W.printHex("Size", Size);
745 W.printHex("Type", Type);
746
747 StringRef Contents = DE.getData().substr(Offset, Size);
748 W.printBinaryBlock("Contents", Contents);
749 }
750
751 Offset += Size;
752 break;
753 }
754 }
755 }
756
757 if (InFunctionScope)
758 error(object_error::parse_failed);
2087 StringRef Name;
2088 std::tie(Name, FieldData) = FieldData.split('\0');
2089 W.printString("Name", Name);
2090 break;
2091 }
2092
2093 case LF_METHOD: {
2094 const OverloadedMethod *Method;
2095 error(consumeObject(FieldData, Method));
2096 DictScope S(W, "OverloadedMethod");
2097 W.printHex("MethodCount", Method->MethodCount);
2098 W.printHex("MethodListIndex", Method->MethList.getIndex());
2099 StringRef Name;
2100 std::tie(Name, FieldData) = FieldData.split('\0');
2101 W.printString("Name", Name);
2102 break;
2103 }
2104
2105 case LF_MEMBER: {
2106 const DataMember *Field;
2107 error(consumeObject(FieldData, Field));
2108 DictScope S(W, "DataMember");
2109 printMemberAttributes(Field->Attrs);
2110 printTypeIndex("Type", Field->Type);
2111 uint64_t FieldOffset;
2112 error(decodeUIntLeaf(FieldData, FieldOffset));
2113 W.printHex("FieldOffset", FieldOffset);
2114 StringRef Name;
2115 std::tie(Name, FieldData) = FieldData.split('\0');
2116 W.printString("Name", Name);
2117 break;
2118 }
2119
2120 case LF_STMEMBER: {
2121 const StaticDataMember *Field;
2122 error(consumeObject(FieldData, Field));
2123 DictScope S(W, "StaticDataMember");
2124 printMemberAttributes(Field->Attrs);
2125 printTypeIndex("Type", Field->Type);
2126 StringRef Name;
2127 std::tie(Name, FieldData) = FieldData.split('\0');
2128 W.printString("Name", Name);
2129 break;
2130 }
2131
2132 case LF_VFUNCTAB: {
2133 const VirtualFunctionPointer *VFTable;
2134 error(consumeObject(FieldData, VFTable));
2135 DictScope S(W, "VirtualFunctionPointer");
2136 printTypeIndex("Type", VFTable->Type);
2137 break;
2138 }
2139
2140 case LF_ENUMERATE: {
2141 const Enumerator *Enum;
2142 error(consumeObject(FieldData, Enum));
2143 DictScope S(W, "Enumerator");
2144 printMemberAttributes(Enum->Attrs);
2145 APSInt EnumValue;
2146 error(decodeNumerictLeaf(FieldData, EnumValue));
2147 W.printNumber("EnumValue", EnumValue);
2148 StringRef Name;
2149 std::tie(Name, FieldData) = FieldData.split('\0');
2150 W.printString("Name", Name);
2151 break;
2152 }
2153
2154 case LF_BCLASS:
2155 case LF_BINTERFACE: {
2156 const BaseClass *Base;
2157 error(consumeObject(FieldData, Base));
2158 DictScope S(W, "BaseClass");
2159 printMemberAttributes(Base->Attrs);
2160 printTypeIndex("BaseType", Base->BaseType);
2161 uint64_t BaseOffset;
2162 error(decodeUIntLeaf(FieldData, BaseOffset));
2163 W.printHex("BaseOffset", BaseOffset);
2164 break;
2165 }
2166
2167 case LF_VBCLASS:
2168 case LF_IVBCLASS: {
2169 const VirtualBaseClass *Base;
2170 error(consumeObject(FieldData, Base));
2171 DictScope S(W, "VirtualBaseClass");
2172 printMemberAttributes(Base->Attrs);
2173 printTypeIndex("BaseType", Base->BaseType);
2174 printTypeIndex("VBPtrType", Base->VBPtrType);
2175 uint64_t VBPtrOffset, VBTableIndex;
2176 error(decodeUIntLeaf(FieldData, VBPtrOffset));
2177 error(decodeUIntLeaf(FieldData, VBTableIndex));
2178 W.printHex("VBPtrOffset", VBPtrOffset);
2179 W.printHex("VBTableIndex", VBTableIndex);
2180 break;
2181 }
2182 }
2183
2184 // Handle padding.
2185 FieldData = skipPadding(FieldData);
2186 }
7592187 }
7602188
7612189 void COFFDumper::printSections() {
0 //===-- CVLeafTypes.def - All CodeView leaf types ---------------*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // See LEAF_ENUM_e in cvinfo.h. This should match the constants there.
10 //
11 //===----------------------------------------------------------------------===//
12
13 #ifndef LEAF_TYPE
14 #define LEAF_TYPE(ename, value)
15 #endif
16
17 // 16 bit type records.
18 LEAF_TYPE(LF_MODIFIER_16t, 0x0001)
19 LEAF_TYPE(LF_POINTER_16t, 0x0002)
20 LEAF_TYPE(LF_ARRAY_16t, 0x0003)
21 LEAF_TYPE(LF_CLASS_16t, 0x0004)
22 LEAF_TYPE(LF_STRUCTURE_16t, 0x0005)
23 LEAF_TYPE(LF_UNION_16t, 0x0006)
24 LEAF_TYPE(LF_ENUM_16t, 0x0007)
25 LEAF_TYPE(LF_PROCEDURE_16t, 0x0008)
26 LEAF_TYPE(LF_MFUNCTION_16t, 0x0009)
27 LEAF_TYPE(LF_VTSHAPE, 0x000a)
28 LEAF_TYPE(LF_COBOL0_16t, 0x000b)
29 LEAF_TYPE(LF_COBOL1, 0x000c)
30 LEAF_TYPE(LF_BARRAY_16t, 0x000d)
31 LEAF_TYPE(LF_LABEL, 0x000e)
32 LEAF_TYPE(LF_NULLLEAF, 0x000f) // LF_NULL
33 LEAF_TYPE(LF_NOTTRAN, 0x0010)
34 LEAF_TYPE(LF_DIMARRAY_16t, 0x0011)
35 LEAF_TYPE(LF_VFTPATH_16t, 0x0012)
36 LEAF_TYPE(LF_PRECOMP_16t, 0x0013)
37 LEAF_TYPE(LF_ENDPRECOMP, 0x0014)
38 LEAF_TYPE(LF_OEM_16t, 0x0015)
39 LEAF_TYPE(LF_TYPESERVER_ST, 0x0016)
40
41 LEAF_TYPE(LF_SKIP_16t, 0x0200)
42 LEAF_TYPE(LF_ARGLIST_16t, 0x0201)
43 LEAF_TYPE(LF_DEFARG_16t, 0x0202)
44 LEAF_TYPE(LF_LIST, 0x0203)
45 LEAF_TYPE(LF_FIELDLIST_16t, 0x0204)
46 LEAF_TYPE(LF_DERIVED_16t, 0x0205)
47 LEAF_TYPE(LF_BITFIELD_16t, 0x0206)
48 LEAF_TYPE(LF_METHODLIST_16t, 0x0207)
49 LEAF_TYPE(LF_DIMCONU_16t, 0x0208)
50 LEAF_TYPE(LF_DIMCONLU_16t, 0x0209)
51 LEAF_TYPE(LF_DIMVARU_16t, 0x020a)
52 LEAF_TYPE(LF_DIMVARLU_16t, 0x020b)
53 LEAF_TYPE(LF_REFSYM, 0x020c)
54
55 // 16 bit member types. Generally not length prefixed.
56 LEAF_TYPE(LF_BCLASS_16t, 0x0400)
57 LEAF_TYPE(LF_VBCLASS_16t, 0x0401)
58 LEAF_TYPE(LF_IVBCLASS_16t, 0x0402)
59 LEAF_TYPE(LF_ENUMERATE_ST, 0x0403)
60 LEAF_TYPE(LF_FRIENDFCN_16t, 0x0404)
61 LEAF_TYPE(LF_INDEX_16t, 0x0405)
62 LEAF_TYPE(LF_MEMBER_16t, 0x0406)
63 LEAF_TYPE(LF_STMEMBER_16t, 0x0407)
64 LEAF_TYPE(LF_METHOD_16t, 0x0408)
65 LEAF_TYPE(LF_NESTTYPE_16t, 0x0409)
66 LEAF_TYPE(LF_VFUNCTAB_16t, 0x040a)
67 LEAF_TYPE(LF_FRIENDCLS_16t, 0x040b)
68 LEAF_TYPE(LF_ONEMETHOD_16t, 0x040c)
69 LEAF_TYPE(LF_VFUNCOFF_16t, 0x040d)
70
71 LEAF_TYPE(LF_TI16_MAX, 0x1000)
72
73 LEAF_TYPE(LF_MODIFIER, 0x1001)
74 LEAF_TYPE(LF_POINTER, 0x1002)
75 LEAF_TYPE(LF_ARRAY_ST, 0x1003)
76 LEAF_TYPE(LF_CLASS_ST, 0x1004)
77 LEAF_TYPE(LF_STRUCTURE_ST, 0x1005)
78 LEAF_TYPE(LF_UNION_ST, 0x1006)
79 LEAF_TYPE(LF_ENUM_ST, 0x1007)
80 LEAF_TYPE(LF_PROCEDURE, 0x1008)
81 LEAF_TYPE(LF_MFUNCTION, 0x1009)
82 LEAF_TYPE(LF_COBOL0, 0x100a)
83 LEAF_TYPE(LF_BARRAY, 0x100b)
84 LEAF_TYPE(LF_DIMARRAY_ST, 0x100c)
85 LEAF_TYPE(LF_VFTPATH, 0x100d)
86 LEAF_TYPE(LF_PRECOMP_ST, 0x100e)
87 LEAF_TYPE(LF_OEM, 0x100f)
88 LEAF_TYPE(LF_ALIAS_ST, 0x1010)
89 LEAF_TYPE(LF_OEM2, 0x1011)
90
91 LEAF_TYPE(LF_SKIP, 0x1200)
92 LEAF_TYPE(LF_ARGLIST, 0x1201)
93 LEAF_TYPE(LF_DEFARG_ST, 0x1202)
94 LEAF_TYPE(LF_FIELDLIST, 0x1203)
95 LEAF_TYPE(LF_DERIVED, 0x1204)
96 LEAF_TYPE(LF_BITFIELD, 0x1205)
97 LEAF_TYPE(LF_METHODLIST, 0x1206)
98 LEAF_TYPE(LF_DIMCONU, 0x1207)
99 LEAF_TYPE(LF_DIMCONLU, 0x1208)
100 LEAF_TYPE(LF_DIMVARU, 0x1209)
101 LEAF_TYPE(LF_DIMVARLU, 0x120a)
102
103 // Member type records. These are generally not length prefixed, and appear
104 // inside of a field list record.
105 LEAF_TYPE(LF_BCLASS, 0x1400)
106 LEAF_TYPE(LF_VBCLASS, 0x1401)
107 LEAF_TYPE(LF_IVBCLASS, 0x1402)
108 LEAF_TYPE(LF_FRIENDFCN_ST, 0x1403)
109 LEAF_TYPE(LF_INDEX, 0x1404)
110 LEAF_TYPE(LF_MEMBER_ST, 0x1405)
111 LEAF_TYPE(LF_STMEMBER_ST, 0x1406)
112 LEAF_TYPE(LF_METHOD_ST, 0x1407)
113 LEAF_TYPE(LF_NESTTYPE_ST, 0x1408)
114 LEAF_TYPE(LF_VFUNCTAB, 0x1409)
115 LEAF_TYPE(LF_FRIENDCLS, 0x140a)
116 LEAF_TYPE(LF_ONEMETHOD_ST, 0x140b)
117 LEAF_TYPE(LF_VFUNCOFF, 0x140c)
118 LEAF_TYPE(LF_NESTTYPEEX_ST, 0x140d)
119 LEAF_TYPE(LF_MEMBERMODIFY_ST, 0x140e)
120 LEAF_TYPE(LF_MANAGED_ST, 0x140f)
121
122 LEAF_TYPE(LF_ST_MAX, 0x1500)
123 LEAF_TYPE(LF_TYPESERVER, 0x1501)
124 LEAF_TYPE(LF_ENUMERATE, 0x1502)
125 LEAF_TYPE(LF_ARRAY, 0x1503)
126 LEAF_TYPE(LF_CLASS, 0x1504)
127 LEAF_TYPE(LF_STRUCTURE, 0x1505)
128 LEAF_TYPE(LF_UNION, 0x1506)
129 LEAF_TYPE(LF_ENUM, 0x1507)
130 LEAF_TYPE(LF_DIMARRAY, 0x1508)
131 LEAF_TYPE(LF_PRECOMP, 0x1509)
132 LEAF_TYPE(LF_ALIAS, 0x150a)
133 LEAF_TYPE(LF_DEFARG, 0x150b)
134 LEAF_TYPE(LF_FRIENDFCN, 0x150c)
135 LEAF_TYPE(LF_MEMBER, 0x150d)
136 LEAF_TYPE(LF_STMEMBER, 0x150e)
137 LEAF_TYPE(LF_METHOD, 0x150f)
138 LEAF_TYPE(LF_NESTTYPE, 0x1510)
139 LEAF_TYPE(LF_ONEMETHOD, 0x1511)
140 LEAF_TYPE(LF_NESTTYPEEX, 0x1512)
141 LEAF_TYPE(LF_MEMBERMODIFY, 0x1513)
142 LEAF_TYPE(LF_MANAGED, 0x1514)
143 LEAF_TYPE(LF_TYPESERVER2, 0x1515)
144 LEAF_TYPE(LF_STRIDED_ARRAY, 0x1516)
145 LEAF_TYPE(LF_HLSL, 0x1517)
146 LEAF_TYPE(LF_MODIFIER_EX, 0x1518)
147 LEAF_TYPE(LF_INTERFACE, 0x1519)
148 LEAF_TYPE(LF_BINTERFACE, 0x151a)
149 LEAF_TYPE(LF_VECTOR, 0x151b)
150 LEAF_TYPE(LF_MATRIX, 0x151c)
151 LEAF_TYPE(LF_VFTABLE, 0x151d)
152
153 // ID leaf records. Subsequent leaf types may be referenced from .debug$S.
154
155 LEAF_TYPE(LF_FUNC_ID, 0x1601)
156 LEAF_TYPE(LF_MFUNC_ID, 0x1602)
157 LEAF_TYPE(LF_BUILDINFO, 0x1603)
158 LEAF_TYPE(LF_SUBSTR_LIST, 0x1604)
159 LEAF_TYPE(LF_STRING_ID, 0x1605)
160 LEAF_TYPE(LF_UDT_SRC_LINE, 0x1606)
161 LEAF_TYPE(LF_UDT_MOD_SRC_LINE, 0x1607)
162
163 // Numeric leaf types. These are generally contained in other records, and not
164 // encountered in the main type stream.
165
166 LEAF_TYPE(LF_NUMERIC, 0x8000)
167 LEAF_TYPE(LF_CHAR, 0x8000)
168 LEAF_TYPE(LF_SHORT, 0x8001)
169 LEAF_TYPE(LF_USHORT, 0x8002)
170 LEAF_TYPE(LF_LONG, 0x8003)
171 LEAF_TYPE(LF_ULONG, 0x8004)
172 LEAF_TYPE(LF_REAL32, 0x8005)
173 LEAF_TYPE(LF_REAL64, 0x8006)
174 LEAF_TYPE(LF_REAL80, 0x8007)
175 LEAF_TYPE(LF_REAL128, 0x8008)
176 LEAF_TYPE(LF_QUADWORD, 0x8009)
177 LEAF_TYPE(LF_UQUADWORD, 0x800a)
178 LEAF_TYPE(LF_REAL48, 0x800b)
179 LEAF_TYPE(LF_COMPLEX32, 0x800c)
180 LEAF_TYPE(LF_COMPLEX64, 0x800d)
181 LEAF_TYPE(LF_COMPLEX80, 0x800e)
182 LEAF_TYPE(LF_COMPLEX128, 0x800f)
183 LEAF_TYPE(LF_VARSTRING, 0x8010)
184 LEAF_TYPE(LF_OCTWORD, 0x8017)
185 LEAF_TYPE(LF_UOCTWORD, 0x8018)
186 LEAF_TYPE(LF_DECIMAL, 0x8019)
187 LEAF_TYPE(LF_DATE, 0x801a)
188 LEAF_TYPE(LF_UTF8STRING, 0x801b)
189 LEAF_TYPE(LF_REAL16, 0x801c)
190
191 // Padding bytes. These are emitted into alignment bytes in the type stream.
192
193 LEAF_TYPE(LF_PAD0, 0xf0)
194 LEAF_TYPE(LF_PAD1, 0xf1)
195 LEAF_TYPE(LF_PAD2, 0xf2)
196 LEAF_TYPE(LF_PAD3, 0xf3)
197 LEAF_TYPE(LF_PAD4, 0xf4)
198 LEAF_TYPE(LF_PAD5, 0xf5)
199 LEAF_TYPE(LF_PAD6, 0xf6)
200 LEAF_TYPE(LF_PAD7, 0xf7)
201 LEAF_TYPE(LF_PAD8, 0xf8)
202 LEAF_TYPE(LF_PAD9, 0xf9)
203 LEAF_TYPE(LF_PAD10, 0xfa)
204 LEAF_TYPE(LF_PAD11, 0xfb)
205 LEAF_TYPE(LF_PAD12, 0xfc)
206 LEAF_TYPE(LF_PAD13, 0xfd)
207 LEAF_TYPE(LF_PAD14, 0xfe)
208 LEAF_TYPE(LF_PAD15, 0xff)
209
210 #undef LEAF_TYPE
0 //===-- CVLeafTypes.def - All CodeView leaf types ---------------*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // See LEAF_ENUM_e in cvinfo.h. This should match the constants there.
10 //
11 //===----------------------------------------------------------------------===//
12
13 #ifndef SYMBOL_TYPE
14 #define SYMBOL_TYPE(ename, value)
15 #endif
16
17 // 16 bit symbol types. Not very useful, provided only for reference.
18 SYMBOL_TYPE(S_COMPILE , 0x0001)
19 SYMBOL_TYPE(S_REGISTER_16t , 0x0002)
20 SYMBOL_TYPE(S_CONSTANT_16t , 0x0003)
21 SYMBOL_TYPE(S_UDT_16t , 0x0004)
22 SYMBOL_TYPE(S_SSEARCH , 0x0005)
23 SYMBOL_TYPE(S_END , 0x0006)
24 SYMBOL_TYPE(S_SKIP , 0x0007)
25 SYMBOL_TYPE(S_CVRESERVE , 0x0008)
26 SYMBOL_TYPE(S_OBJNAME_ST , 0x0009)
27 SYMBOL_TYPE(S_ENDARG , 0x000a)
28 SYMBOL_TYPE(S_COBOLUDT_16t , 0x000b)
29 SYMBOL_TYPE(S_MANYREG_16t , 0x000c)
30 SYMBOL_TYPE(S_RETURN , 0x000d)
31 SYMBOL_TYPE(S_ENTRYTHIS , 0x000e)
32 SYMBOL_TYPE(S_BPREL16 , 0x0100)
33 SYMBOL_TYPE(S_LDATA16 , 0x0101)
34 SYMBOL_TYPE(S_GDATA16 , 0x0102)
35 SYMBOL_TYPE(S_PUB16 , 0x0103)
36 SYMBOL_TYPE(S_LPROC16 , 0x0104)
37 SYMBOL_TYPE(S_GPROC16 , 0x0105)
38 SYMBOL_TYPE(S_THUNK16 , 0x0106)
39 SYMBOL_TYPE(S_BLOCK16 , 0x0107)
40 SYMBOL_TYPE(S_WITH16 , 0x0108)
41 SYMBOL_TYPE(S_LABEL16 , 0x0109)
42 SYMBOL_TYPE(S_CEXMODEL16 , 0x010a)
43 SYMBOL_TYPE(S_VFTABLE16 , 0x010b)
44 SYMBOL_TYPE(S_REGREL16 , 0x010c)
45 SYMBOL_TYPE(S_BPREL32_16t , 0x0200)
46 SYMBOL_TYPE(S_LDATA32_16t , 0x0201)
47 SYMBOL_TYPE(S_GDATA32_16t , 0x0202)
48 SYMBOL_TYPE(S_PUB32_16t , 0x0203)
49 SYMBOL_TYPE(S_LPROC32_16t , 0x0204)
50 SYMBOL_TYPE(S_GPROC32_16t , 0x0205)
51 SYMBOL_TYPE(S_THUNK32_ST , 0x0206)
52 SYMBOL_TYPE(S_BLOCK32_ST , 0x0207)
53 SYMBOL_TYPE(S_WITH32_ST , 0x0208)
54 SYMBOL_TYPE(S_LABEL32_ST , 0x0209)
55 SYMBOL_TYPE(S_CEXMODEL32 , 0x020a)
56 SYMBOL_TYPE(S_VFTABLE32_16t , 0x020b)
57 SYMBOL_TYPE(S_REGREL32_16t , 0x020c)
58 SYMBOL_TYPE(S_LTHREAD32_16t , 0x020d)
59 SYMBOL_TYPE(S_GTHREAD32_16t , 0x020e)
60 SYMBOL_TYPE(S_SLINK32 , 0x020f)
61 SYMBOL_TYPE(S_LPROCMIPS_16t , 0x0300)
62 SYMBOL_TYPE(S_GPROCMIPS_16t , 0x0301)
63 SYMBOL_TYPE(S_PROCREF_ST , 0x0400)
64 SYMBOL_TYPE(S_DATAREF_ST , 0x0401)
65 SYMBOL_TYPE(S_ALIGN , 0x0402)
66 SYMBOL_TYPE(S_LPROCREF_ST , 0x0403)
67 SYMBOL_TYPE(S_OEM , 0x0404)
68
69 // All post 16 bit symbol types have the 0x1000 bit set.
70 SYMBOL_TYPE(S_TI16_MAX , 0x1000)
71
72 // Mostly unused "start" symbol types.
73 SYMBOL_TYPE(S_REGISTER_ST , 0x1001)
74 SYMBOL_TYPE(S_CONSTANT_ST , 0x1002)
75 SYMBOL_TYPE(S_UDT_ST , 0x1003)
76 SYMBOL_TYPE(S_COBOLUDT_ST , 0x1004)
77 SYMBOL_TYPE(S_MANYREG_ST , 0x1005)
78 SYMBOL_TYPE(S_BPREL32_ST , 0x1006)
79 SYMBOL_TYPE(S_LDATA32_ST , 0x1007)
80 SYMBOL_TYPE(S_GDATA32_ST , 0x1008)
81 SYMBOL_TYPE(S_PUB32_ST , 0x1009)
82 SYMBOL_TYPE(S_LPROC32_ST , 0x100a)
83 SYMBOL_TYPE(S_GPROC32_ST , 0x100b)
84 SYMBOL_TYPE(S_VFTABLE32 , 0x100c)
85 SYMBOL_TYPE(S_REGREL32_ST , 0x100d)
86 SYMBOL_TYPE(S_LTHREAD32_ST , 0x100e)
87 SYMBOL_TYPE(S_GTHREAD32_ST , 0x100f)
88 SYMBOL_TYPE(S_LPROCMIPS_ST , 0x1010)
89 SYMBOL_TYPE(S_GPROCMIPS_ST , 0x1011)
90
91 // Information about the frame layout of a procedure.
92 SYMBOL_TYPE(S_FRAMEPROC , 0x1012)
93
94 SYMBOL_TYPE(S_COMPILE2_ST , 0x1013)
95 SYMBOL_TYPE(S_MANYREG2_ST , 0x1014)
96 SYMBOL_TYPE(S_LPROCIA64_ST , 0x1015)
97 SYMBOL_TYPE(S_GPROCIA64_ST , 0x1016)
98 SYMBOL_TYPE(S_LOCALSLOT_ST , 0x1017)
99 SYMBOL_TYPE(S_PARAMSLOT_ST , 0x1018)
100 SYMBOL_TYPE(S_ANNOTATION , 0x1019)
101 SYMBOL_TYPE(S_GMANPROC_ST , 0x101a)
102 SYMBOL_TYPE(S_LMANPROC_ST , 0x101b)
103 SYMBOL_TYPE(S_RESERVED1 , 0x101c)
104 SYMBOL_TYPE(S_RESERVED2 , 0x101d)
105 SYMBOL_TYPE(S_RESERVED3 , 0x101e)
106 SYMBOL_TYPE(S_RESERVED4 , 0x101f)
107 SYMBOL_TYPE(S_LMANDATA_ST , 0x1020)
108 SYMBOL_TYPE(S_GMANDATA_ST , 0x1021)
109 SYMBOL_TYPE(S_MANFRAMEREL_ST, 0x1022)
110 SYMBOL_TYPE(S_MANREGISTER_ST, 0x1023)
111 SYMBOL_TYPE(S_MANSLOT_ST , 0x1024)
112 SYMBOL_TYPE(S_MANMANYREG_ST , 0x1025)
113 SYMBOL_TYPE(S_MANREGREL_ST , 0x1026)
114 SYMBOL_TYPE(S_MANMANYREG2_ST, 0x1027)
115 SYMBOL_TYPE(S_MANTYPREF , 0x1028)
116 SYMBOL_TYPE(S_UNAMESPACE_ST , 0x1029)
117
118 // End of S_*_ST symbols, which do not appear to be generated by modern
119 // compilers.
120 SYMBOL_TYPE(S_ST_MAX , 0x1100)
121
122 SYMBOL_TYPE(S_OBJNAME , 0x1101)
123 SYMBOL_TYPE(S_THUNK32 , 0x1102)
124 SYMBOL_TYPE(S_BLOCK32 , 0x1103)
125 SYMBOL_TYPE(S_WITH32 , 0x1104)
126 SYMBOL_TYPE(S_LABEL32 , 0x1105)
127 SYMBOL_TYPE(S_REGISTER , 0x1106)
128 SYMBOL_TYPE(S_CONSTANT , 0x1107)
129 SYMBOL_TYPE(S_UDT , 0x1108)
130 SYMBOL_TYPE(S_COBOLUDT , 0x1109)
131 SYMBOL_TYPE(S_MANYREG , 0x110a)
132 SYMBOL_TYPE(S_BPREL32 , 0x110b)
133 SYMBOL_TYPE(S_LDATA32 , 0x110c)
134 SYMBOL_TYPE(S_GDATA32 , 0x110d)
135 SYMBOL_TYPE(S_PUB32 , 0x110e)
136 SYMBOL_TYPE(S_LPROC32 , 0x110f)
137 SYMBOL_TYPE(S_GPROC32 , 0x1110)
138 SYMBOL_TYPE(S_REGREL32 , 0x1111)
139 SYMBOL_TYPE(S_LTHREAD32 , 0x1112)
140 SYMBOL_TYPE(S_GTHREAD32 , 0x1113)
141 SYMBOL_TYPE(S_LPROCMIPS , 0x1114)
142 SYMBOL_TYPE(S_GPROCMIPS , 0x1115)
143 SYMBOL_TYPE(S_COMPILE2 , 0x1116)
144 SYMBOL_TYPE(S_MANYREG2 , 0x1117)
145 SYMBOL_TYPE(S_LPROCIA64 , 0x1118)
146 SYMBOL_TYPE(S_GPROCIA64 , 0x1119)
147 SYMBOL_TYPE(S_LOCALSLOT , 0x111a)
148 SYMBOL_TYPE(S_PARAMSLOT , 0x111b)
149
150 // Managed code symbols.
151 SYMBOL_TYPE(S_LMANDATA , 0x111c)
152 SYMBOL_TYPE(S_GMANDATA , 0x111d)
153 SYMBOL_TYPE(S_MANFRAMEREL , 0x111e)
154 SYMBOL_TYPE(S_MANREGISTER , 0x111f)
155 SYMBOL_TYPE(S_MANSLOT , 0x1120)
156 SYMBOL_TYPE(S_MANMANYREG , 0x1121)
157 SYMBOL_TYPE(S_MANREGREL , 0x1122)
158 SYMBOL_TYPE(S_MANMANYREG2 , 0x1123)
159 SYMBOL_TYPE(S_UNAMESPACE , 0x1124)
160 SYMBOL_TYPE(S_PROCREF , 0x1125)
161 SYMBOL_TYPE(S_DATAREF , 0x1126)
162 SYMBOL_TYPE(S_LPROCREF , 0x1127)
163 SYMBOL_TYPE(S_ANNOTATIONREF , 0x1128)
164 SYMBOL_TYPE(S_TOKENREF , 0x1129)
165 SYMBOL_TYPE(S_GMANPROC , 0x112a)
166 SYMBOL_TYPE(S_LMANPROC , 0x112b)
167 SYMBOL_TYPE(S_TRAMPOLINE , 0x112c)
168 SYMBOL_TYPE(S_MANCONSTANT , 0x112d)
169 SYMBOL_TYPE(S_ATTR_FRAMEREL , 0x112e)
170 SYMBOL_TYPE(S_ATTR_REGISTER , 0x112f)
171 SYMBOL_TYPE(S_ATTR_REGREL , 0x1130)
172 SYMBOL_TYPE(S_ATTR_MANYREG , 0x1131)
173
174
175 SYMBOL_TYPE(S_SEPCODE , 0x1132)
176 SYMBOL_TYPE(S_LOCAL_2005 , 0x1133)
177 SYMBOL_TYPE(S_DEFRANGE_2005 , 0x1134)
178 SYMBOL_TYPE(S_DEFRANGE2_2005, 0x1135)
179 SYMBOL_TYPE(S_SECTION , 0x1136)
180 SYMBOL_TYPE(S_COFFGROUP , 0x1137)
181 SYMBOL_TYPE(S_EXPORT , 0x1138)
182 SYMBOL_TYPE(S_CALLSITEINFO , 0x1139)
183 SYMBOL_TYPE(S_FRAMECOOKIE , 0x113a)
184 SYMBOL_TYPE(S_DISCARDED , 0x113b)
185 SYMBOL_TYPE(S_COMPILE3 , 0x113c)
186 SYMBOL_TYPE(S_ENVBLOCK , 0x113d)
187 SYMBOL_TYPE(S_LOCAL , 0x113e)
188 SYMBOL_TYPE(S_DEFRANGE , 0x113f)
189 SYMBOL_TYPE(S_DEFRANGE_SUBFIELD, 0x1140)
190 SYMBOL_TYPE(S_DEFRANGE_REGISTER, 0x1141)
191 SYMBOL_TYPE(S_DEFRANGE_FRAMEPOINTER_REL, 0x1142)
192 SYMBOL_TYPE(S_DEFRANGE_SUBFIELD_REGISTER, 0x1143)
193 SYMBOL_TYPE(S_DEFRANGE_FRAMEPOINTER_REL_FULL_SCOPE, 0x1144)
194 SYMBOL_TYPE(S_DEFRANGE_REGISTER_REL, 0x1145)
195
196 // Current symbol types for most procedures as of this writing.
197 SYMBOL_TYPE(S_LPROC32_ID , 0x1146)
198 SYMBOL_TYPE(S_GPROC32_ID , 0x1147)
199 SYMBOL_TYPE(S_LPROCMIPS_ID , 0x1148)
200 SYMBOL_TYPE(S_GPROCMIPS_ID , 0x1149)
201 SYMBOL_TYPE(S_LPROCIA64_ID , 0x114a)
202 SYMBOL_TYPE(S_GPROCIA64_ID , 0x114b)
203
204 SYMBOL_TYPE(S_BUILDINFO