Merge pull request #2894 from marek-safar/mono.security
[mono.git] / mono / metadata / object-offsets.h
1 /*
2 This is a parameterized header. It's supposed/ok to be included multiple times.
3
4 Input defines: (those to be defined by the includer file)
5
6 Required:
7 DECL_OFFSET(struct,field)
8 DECL_OFFSET2(struct,field,offset)
9 DECL_ALIGN(name,type)
10 DECL_ALIGN2(name,alignment)
11
12 Optional:
13 USE_CROSS_COMPILE_OFFSETS - if defined, force the cross compiler offsets to be used, otherwise
14         they will only be used if MONO_CROSS_COMPILE is defined
15
16 Output defines:
17
18 HAS_CROSS_COMPILER_OFFSETS - if set, it means we found some cross offsets, it doesnt mean we'll use it.
19 USED_CROSS_COMPILER_OFFSETS - if set, it means we used the cross offsets
20
21 Environment defines (from config.h and CFLAGS):
22
23 MONO_GENERATING_OFFSETS - Set by an offsets generating tool to disable the usage of any (possibly non-existing) generated header.
24 MONO_OFFSETS_FILE - Name of the header file containing the offsets to be used.
25
26 */
27
28
29 #undef HAS_CROSS_COMPILER_OFFSETS
30 #undef USED_CROSS_COMPILER_OFFSETS
31
32 #if !defined (MONO_GENERATING_OFFSETS) && defined (MONO_OFFSETS_FILE)
33 #include MONO_OFFSETS_FILE
34 #endif
35
36 #ifndef USED_CROSS_COMPILER_OFFSETS
37
38 DECL_ALIGN(gint8)
39 DECL_ALIGN(gint16)
40 DECL_ALIGN(gint32)
41 DECL_ALIGN(gint64)
42 DECL_ALIGN(float)
43 DECL_ALIGN(double)
44 DECL_ALIGN(gpointer)
45
46 DECL_SIZE(gint8)
47 DECL_SIZE(gint16)
48 DECL_SIZE(gint32)
49 DECL_SIZE(gint64)
50 DECL_SIZE(float)
51 DECL_SIZE(double)
52 DECL_SIZE(gpointer)
53
54 #ifndef DISABLE_METADATA_OFFSETS
55 //object offsets
56 DECL_OFFSET(MonoObject, vtable)
57 DECL_OFFSET(MonoObject, synchronisation)
58
59 DECL_OFFSET(MonoClass, interface_bitmap)
60 DECL_OFFSET(MonoClass, byval_arg)
61 DECL_OFFSET(MonoClass, cast_class)
62 DECL_OFFSET(MonoClass, element_class)
63 DECL_OFFSET(MonoClass, idepth)
64 DECL_OFFSET(MonoClass, instance_size)
65 DECL_OFFSET(MonoClass, interface_id)
66 DECL_OFFSET(MonoClass, max_interface_id)
67 DECL_OFFSET(MonoClass, parent)
68 DECL_OFFSET(MonoClass, rank)
69 DECL_OFFSET(MonoClass, sizes)
70 DECL_OFFSET(MonoClass, supertypes)
71
72 DECL_OFFSET(MonoVTable, klass)
73 DECL_OFFSET(MonoVTable, max_interface_id)
74 DECL_OFFSET(MonoVTable, interface_bitmap)
75 DECL_OFFSET(MonoVTable, vtable)
76 DECL_OFFSET(MonoVTable, rank)
77 DECL_OFFSET(MonoVTable, type)
78 DECL_OFFSET(MonoVTable, runtime_generic_context)
79
80 DECL_OFFSET(MonoDomain, stack_overflow_ex)
81
82 DECL_OFFSET(MonoDelegate, target)
83 DECL_OFFSET(MonoDelegate, method_ptr)
84 DECL_OFFSET(MonoDelegate, invoke_impl)
85 DECL_OFFSET(MonoDelegate, method)
86 DECL_OFFSET(MonoDelegate, method_code)
87 DECL_OFFSET(MonoDelegate, method_is_virtual)
88 DECL_OFFSET(MonoDelegate, extra_arg)
89
90 DECL_OFFSET(MonoInternalThread, tid)
91 DECL_OFFSET(MonoInternalThread, small_id)
92 DECL_OFFSET(MonoInternalThread, static_data)
93
94 DECL_OFFSET(MonoMulticastDelegate, delegates)
95
96 DECL_OFFSET(MonoTransparentProxy, rp)
97 DECL_OFFSET(MonoTransparentProxy, remote_class)
98 DECL_OFFSET(MonoTransparentProxy, custom_type_info)
99
100 DECL_OFFSET(MonoRealProxy, target_domain_id)
101 DECL_OFFSET(MonoRealProxy, context)
102 DECL_OFFSET(MonoRealProxy, unwrapped_server)
103
104 DECL_OFFSET(MonoRemoteClass, proxy_class)
105
106 DECL_OFFSET(MonoArray, vector)
107 DECL_OFFSET(MonoArray, max_length)
108 DECL_OFFSET(MonoArray, bounds)
109
110 DECL_OFFSET(MonoArrayBounds, lower_bound)
111 DECL_OFFSET(MonoArrayBounds, length)
112
113 DECL_OFFSET(MonoSafeHandle, handle)
114
115 DECL_OFFSET(MonoHandleRef, handle)
116
117 DECL_OFFSET(MonoComInteropProxy, com_object)
118
119 DECL_OFFSET(MonoString, length)
120 DECL_OFFSET(MonoString, chars)
121
122 DECL_OFFSET(MonoException, message)
123
124 DECL_OFFSET(MonoTypedRef, type)
125 DECL_OFFSET(MonoTypedRef, klass)
126 DECL_OFFSET(MonoTypedRef, value)
127
128 //Internal structs
129 DECL_OFFSET(MonoThreadsSync, status)
130 DECL_OFFSET(MonoThreadsSync, nest)
131
132 #if defined (HAVE_SGEN_GC) && !defined (HAVE_KW_THREAD)
133 DECL_OFFSET(SgenThreadInfo, tlab_next_addr)
134 DECL_OFFSET(SgenThreadInfo, tlab_temp_end)
135 #endif
136
137 #endif //DISABLE METADATA OFFSETS
138
139 #ifndef DISABLE_JIT_OFFSETS
140 DECL_OFFSET(MonoLMF, previous_lmf)
141
142 DECL_OFFSET(MonoMethodRuntimeGenericContext, class_vtable)
143
144 DECL_OFFSET(MonoJitTlsData, lmf)
145 DECL_OFFSET(MonoJitTlsData, class_cast_from)
146 DECL_OFFSET(MonoJitTlsData, class_cast_to)
147 DECL_OFFSET(MonoJitTlsData, handler_block_return_address)
148 DECL_OFFSET(MonoJitTlsData, restore_stack_prot)
149
150 DECL_OFFSET(MonoGSharedVtMethodRuntimeInfo, locals_size)
151 DECL_OFFSET(MonoGSharedVtMethodRuntimeInfo, entries) //XXX more to fix here
152
153 DECL_OFFSET(MonoContinuation, stack_used_size)
154 DECL_OFFSET(MonoContinuation, saved_stack)
155 DECL_OFFSET(MonoContinuation, return_sp)
156 DECL_OFFSET(MonoContinuation, lmf)
157 DECL_OFFSET(MonoContinuation, return_ip)
158
159 DECL_OFFSET(MonoDelegateTrampInfo, invoke_impl)
160 DECL_OFFSET(MonoDelegateTrampInfo, method_ptr)
161
162 // Architecture-specific offsets
163 // -----------------------------
164
165 #if defined(TARGET_X86)
166 DECL_OFFSET(MonoContext, eax)
167 DECL_OFFSET(MonoContext, ebx)
168 DECL_OFFSET(MonoContext, ecx)
169 DECL_OFFSET(MonoContext, edx)
170 DECL_OFFSET(MonoContext, edi)
171 DECL_OFFSET(MonoContext, esi)
172 DECL_OFFSET(MonoContext, esp)
173 DECL_OFFSET(MonoContext, ebp)
174 DECL_OFFSET(MonoContext, eip)
175
176 DECL_OFFSET(MonoLMF, method)
177 DECL_OFFSET(MonoLMF, lmf_addr)
178 DECL_OFFSET(MonoLMF, esp)
179 DECL_OFFSET(MonoLMF, ebx)
180 DECL_OFFSET(MonoLMF, edi)
181 DECL_OFFSET(MonoLMF, esi)
182 DECL_OFFSET(MonoLMF, ebp)
183 DECL_OFFSET(MonoLMF, eip)
184 #elif defined(TARGET_AMD64)
185 DECL_OFFSET(MonoContext, gregs)
186 DECL_OFFSET(MonoContext, fregs)
187
188 DECL_OFFSET(MonoLMF, rsp)
189 DECL_OFFSET(MonoLMF, rbp)
190 DECL_OFFSET(MonoLMF, rip)
191
192 DECL_OFFSET(DynCallArgs, res)
193
194 DECL_OFFSET(MonoLMFTramp, ctx)
195 DECL_OFFSET(MonoLMFTramp, lmf_addr)
196 #elif defined(TARGET_ARM)
197 DECL_OFFSET(MonoLMF, sp)
198 DECL_OFFSET(MonoLMF, fp)
199 DECL_OFFSET(MonoLMF, ip)
200 DECL_OFFSET(MonoLMF, iregs)
201 DECL_OFFSET(MonoLMF, fregs)
202 #elif defined(TARGET_ARM64)
203 DECL_OFFSET(MonoLMF, pc)
204 DECL_OFFSET(MonoLMF, gregs)
205 DECL_OFFSET(DynCallArgs, regs)
206 DECL_OFFSET(DynCallArgs, fpregs)
207 DECL_OFFSET(DynCallArgs, n_fpargs)
208 DECL_OFFSET(DynCallArgs, n_fpret)
209 #endif
210
211 // Shared architecture offfsets
212 // ----------------------------
213
214 #if defined(TARGET_ARM) || defined(TARGET_ARM64)
215 DECL_OFFSET (MonoContext, pc)
216 DECL_OFFSET (MonoContext, regs)
217 DECL_OFFSET (MonoContext, fregs)
218
219 DECL_OFFSET(MonoLMF, lmf_addr)
220
221 DECL_OFFSET(SeqPointInfo, ss_trigger_page)
222
223 DECL_OFFSET(DynCallArgs, res)
224 DECL_OFFSET(DynCallArgs, res2)
225 #endif
226
227 #if defined(TARGET_ARM)
228 DECL_OFFSET(MonoLMF, method)
229 DECL_OFFSET(GSharedVtCallInfo, stack_usage)
230 DECL_OFFSET(GSharedVtCallInfo, vret_arg_reg)
231 DECL_OFFSET(GSharedVtCallInfo, ret_marshal)
232 DECL_OFFSET(GSharedVtCallInfo, vret_slot)
233 DECL_OFFSET(GSharedVtCallInfo, gsharedvt_in)
234 #endif
235
236 #if defined(TARGET_ARM64)
237 DECL_OFFSET(GSharedVtCallInfo, stack_usage)
238 DECL_OFFSET(GSharedVtCallInfo, gsharedvt_in)
239 DECL_OFFSET(GSharedVtCallInfo, ret_marshal)
240 DECL_OFFSET(GSharedVtCallInfo, vret_slot)
241 #endif
242
243 #if defined(TARGET_AMD64) || defined(TARGET_ARM64)
244 DECL_OFFSET(SeqPointInfo, ss_tramp_addr)
245 #endif
246
247 #if defined(TARGET_AMD64) || defined(TARGET_ARM) || defined(TARGET_ARM64)
248 DECL_OFFSET(SeqPointInfo, bp_addrs)
249 #endif
250
251 #endif //DISABLE_JIT_OFFSETS
252
253 #endif //USED_CROSS_COMPILER_OFFSETS
254
255 #undef DECL_OFFSET
256 #undef DECL_OFFSET2
257 #undef DECL_ALIGN
258 #undef DECL_ALIGN2
259 #undef DECL_SIZE
260 #undef DECL_SIZE2
261 #undef USE_CROSS_COMPILE_OFFSETS