if (cfg->exception_type != MONO_EXCEPTION_NONE) \
goto exception_exit; \
} while (0)
+#define METHOD_ACCESS_FAILURE(method, cmethod) do { \
+ method_access_failure ((cfg), (method), (cmethod)); \
+ goto exception_exit; \
+ } while (0)
#define FIELD_ACCESS_FAILURE(method, field) do { \
field_access_failure ((cfg), (method), (field)); \
goto exception_exit; \
G_BREAKPOINT ();
}
+static MONO_NEVER_INLINE void
+method_access_failure (MonoCompile *cfg, MonoMethod *method, MonoMethod *cil_method)
+{
+ char *method_fname = mono_method_full_name (method, TRUE);
+ char *cil_method_fname = mono_method_full_name (cil_method, TRUE);
+ mono_cfg_set_exception (cfg, MONO_EXCEPTION_MONO_ERROR);
+ mono_error_set_generic_error (&cfg->error, "System", "MethodAccessException", "Method `%s' is inaccessible from method `%s'\n", cil_method_fname, method_fname);
+ g_free (method_fname);
+ g_free (cil_method_fname);
+}
+
static MONO_NEVER_INLINE void
field_access_failure (MonoCompile *cfg, MonoMethod *method, MonoClassField *field)
{
return ins;
}
-
-static void
-emit_method_access_failure (MonoCompile *cfg, MonoMethod *method, MonoMethod *cil_method)
-{
- char *caller_fname = mono_method_full_name (method, TRUE);
- char *callee_fname = mono_method_full_name (cil_method, TRUE);
- MonoInst *args [16];
- char *n1, *n2;
-
- n1 = mono_domain_alloc (cfg->domain, strlen (caller_fname) + 1);
- strcmp (n1, caller_fname);
- n2 = mono_domain_alloc (cfg->domain, strlen (callee_fname) + 1);
- strcmp (n1, callee_fname);
- g_free (caller_fname);
- g_free (callee_fname);
-
- EMIT_NEW_PCONST (cfg, args [0], n1);
- EMIT_NEW_PCONST (cfg, args [1], n2);
-
- mono_emit_jit_icall (cfg, mono_throw_method_access, args);
-}
-
static MonoMethod*
get_memcpy_method (void)
{
}
if (!mono_method_can_access_method (method_definition, target_method) &&
!mono_method_can_access_method (method, cil_method))
- emit_method_access_failure (cfg, method, cil_method);
+ METHOD_ACCESS_FAILURE (method, cil_method);
}
if (mono_security_core_clr_enabled ())
cil_method = cmethod;
if (!dont_verify && !cfg->skip_visibility && !mono_method_can_access_method (method, cmethod))
- emit_method_access_failure (cfg, method, cil_method);
+ METHOD_ACCESS_FAILURE (method, cil_method);
if (mono_security_core_clr_enabled ())
ensure_method_is_allowed_to_call_method (cfg, method, cmethod);
register_icall (mono_llvmonly_init_delegate_virtual, "mono_llvmonly_init_delegate_virtual", "void object object ptr", TRUE);
register_icall (mono_get_assembly_object, "mono_get_assembly_object", "object ptr", TRUE);
register_icall (mono_get_method_object, "mono_get_method_object", "object ptr", TRUE);
- register_icall (mono_throw_method_access, "mono_throw_method_access", "void ptr ptr", FALSE);
register_icall_with_wrapper (mono_monitor_enter, "mono_monitor_enter", "void obj");
register_icall_with_wrapper (mono_monitor_enter_v4, "mono_monitor_enter_v4", "void obj ptr");