1 /**
2  * Codeview 4 stuff
3  * See "Microsoft Symbol and Type OMF" document
4  *
5  * Compiler implementation of the
6  * $(LINK2 http://www.dlang.org, D programming language).
7  *
8  * Source:      $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/backend/cv4.d, backend/_cv4.d)
9  */
10 
11 module dmd.backend.cv4;
12 
13 // Online documentation: https://dlang.org/phobos/dmd_backend_cv4.html
14 
15 enum OEM = 0x42;        // Digital Mars OEM number (picked at random)
16 
17 // Symbol Indices
18 enum
19 {
20     S_COMPILE     = 1,
21     S_REGISTER    = 2,
22     S_CONST       = 3,
23     S_UDT         = 4,
24     S_SSEARCH     = 5,
25     S_END         = 6,
26     S_SKIP        = 7,
27     S_CVRESERVE   = 8,
28     S_OBJNAME     = 9,
29     S_ENDARG      = 0x0A,
30     S_COBOLUDT    = 0x0B,
31     S_MANYREG     = 0x0C,
32     S_RETURN      = 0x0D,
33     S_ENTRYTHIS   = 0x0E,
34     S_TDBNAME     = 0x0F,
35 
36     S_BPREL16     = 0x100,
37     S_LDATA16     = 0x101,
38     S_GDATA16     = 0x102,
39     S_PUB16       = 0x103,
40     S_LPROC16     = 0x104,
41     S_GPROC16     = 0x105,
42     S_THUNK16     = 0x106,
43     S_BLOCK16     = 0x107,
44     S_WITH16      = 0x108,
45     S_LABEL16     = 0x109,
46     S_CEXMODEL16  = 0x10A,
47     S_VFTPATH16   = 0x10B,
48 
49     S_BPREL32     = 0x200,
50     S_LDATA32     = 0x201,
51     S_GDATA32     = 0x202,
52     S_PUB32       = 0x203,
53     S_LPROC32     = 0x204,
54     S_GPROC32     = 0x205,
55     S_THUNK32     = 0x206,
56     S_BLOCK32     = 0x207,
57     S_WITH32      = 0x208,
58     S_LABEL32     = 0x209,
59     S_CEXMODEL32  = 0x20A,
60     S_VFTPATH32   = 0x20B,
61 
62     /************** Added Since CV4 *********************/
63 
64     S_REGISTER_V2         = 0x1001,
65     S_CONSTANT_V2         = 0x1002,
66     S_UDT_V2              = 0x1003,
67     S_COBOLUDT_V2         = 0x1004,
68     S_MANYREG_V2          = 0x1005,
69     S_BPREL_V2            = 0x1006,
70     S_LDATA_V2            = 0x1007,
71     S_GDATA_V2            = 0x1008,
72     S_PUB_V2              = 0x1009,
73     S_LPROC_V2            = 0x100A,
74     S_GPROC_V2            = 0x100B,
75     S_VFTTABLE_V2         = 0x100C,
76     S_REGREL_V2           = 0x100D,
77     S_LTHREAD_V2          = 0x100E,
78     S_GTHREAD_V2          = 0x100F,
79     S_FUNCINFO_V2         = 0x1012,
80     S_COMPILAND_V2        = 0x1013,
81 
82     S_COMPILAND_V3        = 0x1101,
83     S_THUNK_V3            = 0x1102,
84     S_BLOCK_V3            = 0x1103,
85     S_LABEL_V3            = 0x1105,
86     S_REGISTER_V3         = 0x1106,
87     S_CONSTANT_V3         = 0x1107,
88     S_UDT_V3              = 0x1108,
89     S_BPREL_V3            = 0x110B,
90     S_LDATA_V3            = 0x110C,
91     S_GDATA_V3            = 0x110D,
92     S_PUB_V3              = 0x110E,
93     S_LPROC_V3            = 0x110F,
94     S_GPROC_V3            = 0x1110,
95     S_BPREL_XXXX_V3       = 0x1111,
96     S_MSTOOL_V3           = 0x1116,
97     S_PUB_FUNC1_V3        = 0x1125,
98     S_PUB_FUNC2_V3        = 0x1127,
99     S_SECTINFO_V3         = 0x1136,
100     S_SUBSECTINFO_V3      = 0x1137,
101     S_ENTRYPOINT_V3       = 0x1138,
102     S_SECUCOOKIE_V3       = 0x113A,
103     S_MSTOOLINFO_V3       = 0x113C,
104     S_MSTOOLENV_V3        = 0x113D,
105 }
106 
107 // Leaf Indices
108 enum
109 {
110     LF_MODIFIER    = 1,
111     LF_POINTER     = 2,
112     LF_ARRAY       = 3,
113     LF_CLASS       = 4,
114     LF_STRUCTURE   = 5,
115     LF_UNION       = 6,
116     LF_ENUM        = 7,
117     LF_PROCEDURE   = 8,
118     LF_MFUNCTION   = 9,
119     LF_VTSHAPE     = 0x0A,
120     LF_COBOL0      = 0x0B,
121     LF_COBOL1      = 0x0C,
122     LF_BARRAY      = 0x0D,
123     LF_LABEL       = 0x0E,
124     LF_NULL        = 0x0F,
125     LF_NOTTRAN     = 0x10,
126     LF_DIMARRAY    = 0x11,
127     LF_VFTPATH     = 0x12,
128     LF_PRECOMP     = 0x13,
129     LF_ENDPRECOMP  = 0x14,
130     LF_OEM         = 0x15,
131     LF_TYPESERVER  = 0x16,
132 
133     // D extensions (not used, causes linker to fail)
134     LF_DYN_ARRAY   = 0x17,
135     LF_ASSOC_ARRAY = 0x18,
136     LF_DELEGATE    = 0x19,
137 
138     LF_SKIP        = 0x200,
139     LF_ARGLIST     = 0x201,
140     LF_DEFARG      = 0x202,
141     LF_LIST        = 0x203,
142     LF_FIELDLIST   = 0x204,
143     LF_DERIVED     = 0x205,
144     LF_BITFIELD    = 0x206,
145     LF_METHODLIST  = 0x207,
146     LF_DIMCONU     = 0x208,
147     LF_DIMCONLU    = 0x209,
148     LF_DIMVARU     = 0x20A,
149     LF_DIMVARLU    = 0x20B,
150     LF_REFSYM      = 0x20C,
151 
152     LF_BCLASS      = 0x400,
153     LF_VBCLASS     = 0x401,
154     LF_IVBCLASS    = 0x402,
155     LF_ENUMERATE   = 0x403,
156     LF_FRIENDFCN   = 0x404,
157     LF_INDEX       = 0x405,
158     LF_MEMBER      = 0x406,
159     LF_STMEMBER    = 0x407,
160     LF_METHOD      = 0x408,
161     LF_NESTTYPE    = 0x409,
162     LF_VFUNCTAB    = 0x40A,
163     LF_FRIENDCLS   = 0x40B,
164 
165     LF_NUMERIC     = 0x8000,
166     LF_CHAR        = 0x8000,
167     LF_SHORT       = 0x8001,
168     LF_USHORT      = 0x8002,
169     LF_LONG        = 0x8003,
170     LF_ULONG       = 0x8004,
171     LF_REAL32      = 0x8005,
172     LF_REAL64      = 0x8006,
173     LF_REAL80      = 0x8007,
174     LF_REAL128     = 0x8008,
175     LF_QUADWORD    = 0x8009,
176     LF_UQUADWORD   = 0x800A,
177     LF_REAL48      = 0x800B,
178 
179     LF_COMPLEX32   = 0x800C,
180     LF_COMPLEX64   = 0x800D,
181     LF_COMPLEX80   = 0x800E,
182     LF_COMPLEX128  = 0x800F,
183 
184     LF_VARSTRING   = 0x8010,
185 
186     /************** Added Since CV4 *********************/
187 
188     LF_MODIFIER_V2        = 0x1001,
189     LF_POINTER_V2         = 0x1002,
190     LF_ARRAY_V2           = 0x1003,
191     LF_CLASS_V2           = 0x1004,
192     LF_STRUCTURE_V2       = 0x1005,
193     LF_UNION_V2           = 0x1006,
194     LF_ENUM_V2            = 0x1007,
195     LF_PROCEDURE_V2       = 0x1008,
196     LF_MFUNCTION_V2       = 0x1009,
197     LF_COBOL0_V2          = 0x100A,
198     LF_BARRAY_V2          = 0x100B,
199     LF_DIMARRAY_V2        = 0x100C,
200     LF_VFTPATH_V2         = 0x100D,
201     LF_PRECOMP_V2         = 0x100E,
202     LF_OEM_V2             = 0x100F,
203 
204     LF_SKIP_V2            = 0x1200,
205     LF_ARGLIST_V2         = 0x1201,
206     LF_DEFARG_V2          = 0x1202,
207     LF_FIELDLIST_V2       = 0x1203,
208     LF_DERIVED_V2         = 0x1204,
209     LF_BITFIELD_V2        = 0x1205,
210     LF_METHODLIST_V2      = 0x1206,
211     LF_DIMCONU_V2         = 0x1207,
212     LF_DIMCONLU_V2        = 0x1208,
213     LF_DIMVARU_V2         = 0x1209,
214     LF_DIMVARLU_V2        = 0x120A,
215 
216     LF_BCLASS_V2          = 0x1400,
217     LF_VBCLASS_V2         = 0x1401,
218     LF_IVBCLASS_V2        = 0x1402,
219     LF_FRIENDFCN_V2       = 0x1403,
220     LF_INDEX_V2           = 0x1404,
221     LF_MEMBER_V2          = 0x1405,
222     LF_STMEMBER_V2        = 0x1406,
223     LF_METHOD_V2          = 0x1407,
224     LF_NESTTYPE_V2        = 0x1408,
225     LF_VFUNCTAB_V2        = 0x1409,
226     LF_FRIENDCLS_V2       = 0x140A,
227     LF_ONEMETHOD_V2       = 0x140B,
228     LF_VFUNCOFF_V2        = 0x140C,
229     LF_NESTTYPEEX_V2      = 0x140D,
230 
231     LF_ENUMERATE_V3       = 0x1502,
232     LF_ARRAY_V3           = 0x1503,
233     LF_CLASS_V3           = 0x1504,
234     LF_STRUCTURE_V3       = 0x1505,
235     LF_UNION_V3           = 0x1506,
236     LF_ENUM_V3            = 0x1507,
237     LF_MEMBER_V3          = 0x150D,
238     LF_STMEMBER_V3        = 0x150E,
239     LF_METHOD_V3          = 0x150F,
240     LF_NESTTYPE_V3        = 0x1510,
241     LF_ONEMETHOD_V3       = 0x1511,
242 }
243