#endif
+/* If TRUE (but also see DISABLE_STICT_STRONG_NAMES #define), Mono will check
+ * that the public key token, culture and version of a candidate assembly matches
+ * the requested strong name. If FALSE, as long as the name matches, the candidate
+ * will be allowed.
+ */
+static gboolean check_strong_names_strictly = FALSE;
+
// Amount initially reserved in each imageset's mempool.
// FIXME: This number is arbitrary, a more practical number should be found
#define INITIAL_IMAGE_SET_SIZE 1024
break;
/*
- * CustomAttributeType: TypeDef, TypeRef, MethodDef,
- * MemberRef and String.
+ * CustomAttributeType: MethodDef, MemberRef.
*/
case MONO_MT_CAT_IDX:
- /* String is a heap, if it is wide, we know the size */
- /* See above, nope.
- if (meta->idx_string_wide){
- field_size = 4;
- break;
- }*/
-
- n = MAX (get_nrows (meta, MONO_TABLE_TYPEREF),
- get_nrows (meta, MONO_TABLE_TYPEDEF));
- n = MAX (n, get_nrows (meta, MONO_TABLE_METHOD));
- n = MAX (n, get_nrows (meta, MONO_TABLE_MEMBERREF));
+ n = MAX (get_nrows (meta, MONO_TABLE_METHOD),
+ get_nrows (meta, MONO_TABLE_MEMBERREF));
/* 3 bits to encode */
field_size = rtsize (meta, n, 16-3);
* \param ptr pointer to a blob object
* \param rptr the new position of the pointer
*
- * This decodes a compressed size as described by 23.1.4 (a blob or user string object)
+ * This decodes a compressed size as described by 24.2.4 (#US and #Blob a blob or user string object)
*
* \returns the size of the blob object
*/
#define NBUILTIN_TYPES() (sizeof (builtin_types) / sizeof (builtin_types [0]))
static GHashTable *type_cache = NULL;
-static int next_generic_inst_id = 0;
+static gint32 next_generic_inst_id = 0;
/* Protected by image_sets_mutex */
static MonoImageSet *mscorlib_image_set;
}
// If we iterated all the way through images without breaking, all items in images were found in set->images
- if (j == nimages)
- break; // Break on "found a set with equal members"
+ if (j == nimages) {
+ // Break on "found a set with equal members".
+ // This happens in case of a hash collision with a previously cached set.
+ break;
+ }
}
l = l->next;
g_ptr_array_add (image_sets, set);
++img_set_count;
-
- img_set_cache_add (set);
}
+ /* Cache the set. If there was a cache collision, the previously cached value will be replaced. */
+ img_set_cache_add (set);
+
if (nimages == 1 && images [0] == mono_defaults.corlib) {
mono_memory_barrier ();
mscorlib_image_set = set;
return set;
}
+static gboolean
+type_is_gtd (MonoType *type)
+{
+ switch (type->type) {
+ case MONO_TYPE_CLASS:
+ case MONO_TYPE_VALUETYPE:
+ return mono_class_is_gtd (type->data.klass);
+ default:
+ return FALSE;
+ }
+}
+
/*
* mono_metadata_get_generic_inst:
*
ginst->type_argc = type_argc;
memcpy (ginst->type_argv, type_argv, type_argc * sizeof (MonoType *));
+ for (i = 0; i < type_argc; ++i) {
+ MonoType *t = ginst->type_argv [i];
+ if (type_is_gtd (t)) {
+ ginst->type_argv [i] = mono_class_gtd_get_canonical_inst (t->data.klass);
+ }
+ }
+
return mono_metadata_get_canonical_generic_inst (ginst);
}
int size = MONO_SIZEOF_GENERIC_INST + type_argc * sizeof (MonoType *);
ginst = (MonoGenericInst *)mono_image_set_alloc0 (set, size);
#ifndef MONO_SMALL_CONFIG
- ginst->id = ++next_generic_inst_id;
+ ginst->id = InterlockedIncrement (&next_generic_inst_id);
#endif
ginst->is_open = is_open;
ginst->type_argc = type_argc;
return owner;
}
+
+void
+mono_loader_set_strict_strong_names (gboolean enabled)
+{
+ check_strong_names_strictly = enabled;
+}
+
+gboolean
+mono_loader_get_strict_strong_names (void)
+{
+ return check_strong_names_strictly;
+}