Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

2010-03-26 Rodrigo Kumpera <rkumpera@novell.com>

	* verify.c: Remove old table verification code that has
	been superseeded by the new metadata verifier.

	* verify.h: Remove mono_image_verify_tables from the public
	API.

	* pedump.c: Fix for removed bits.

svn path=/trunk/mono/; revision=154332
  • Loading branch information...
commit d3ab0f40240f55297e9c5930334beb88d7854701 1 parent 5721e4d
Rodrigo Kumpera kumpera authored
10 mono/metadata/ChangeLog
View
@@ -1,5 +1,15 @@
2010-03-26 Rodrigo Kumpera <rkumpera@novell.com>
+ * verify.c: Remove old table verification code that has
+ been superseeded by the new metadata verifier.
+
+ * verify.h: Remove mono_image_verify_tables from the public
+ API.
+
+ * pedump.c: Fix for removed bits.
+
+2010-03-26 Rodrigo Kumpera <rkumpera@novell.com>
+
* verify.c: Allocate stack slows lazily to reduce stack usage
in case of methods with huge stacks. Reduces memory consumption
for mcs yyparse from 459Mb to 1.8Mb.
12 mono/metadata/pedump.c
View
@@ -349,18 +349,6 @@ dump_verify_info (MonoImage *image, int flags)
"Ok", "Error", "Warning", NULL, "CLS", NULL, NULL, NULL, "Not Verifiable"
};
- if (verify_metadata) {
- errors = mono_image_verify_tables (image, flags);
-
- for (tmp = errors; tmp; tmp = tmp->next) {
- MonoVerifyInfo *info = tmp->data;
- g_print ("%s: %s\n", desc [info->status], info->message);
- if (info->status == MONO_VERIFY_ERROR)
- count++;
- }
- mono_free_verify_list (errors);
- }
-
if (verify_code) { /* verify code */
int i;
MonoTableInfo *m = &image->tables [MONO_TABLE_METHOD];
625 mono/metadata/verify.c
View
@@ -1043,625 +1043,6 @@ mono_free_verify_list (GSList *list)
(list) = g_slist_prepend ((list), vinfo); \
} while (0)
-static const char
-valid_cultures[][9] = {
- "ar-SA", "ar-IQ", "ar-EG", "ar-LY",
- "ar-DZ", "ar-MA", "ar-TN", "ar-OM",
- "ar-YE", "ar-SY", "ar-JO", "ar-LB",
- "ar-KW", "ar-AE", "ar-BH", "ar-QA",
- "bg-BG", "ca-ES", "zh-TW", "zh-CN",
- "zh-HK", "zh-SG", "zh-MO", "cs-CZ",
- "da-DK", "de-DE", "de-CH", "de-AT",
- "de-LU", "de-LI", "el-GR", "en-US",
- "en-GB", "en-AU", "en-CA", "en-NZ",
- "en-IE", "en-ZA", "en-JM", "en-CB",
- "en-BZ", "en-TT", "en-ZW", "en-PH",
- "es-ES-Ts", "es-MX", "es-ES-Is", "es-GT",
- "es-CR", "es-PA", "es-DO", "es-VE",
- "es-CO", "es-PE", "es-AR", "es-EC",
- "es-CL", "es-UY", "es-PY", "es-BO",
- "es-SV", "es-HN", "es-NI", "es-PR",
- "Fi-FI", "fr-FR", "fr-BE", "fr-CA",
- "Fr-CH", "fr-LU", "fr-MC", "he-IL",
- "hu-HU", "is-IS", "it-IT", "it-CH",
- "Ja-JP", "ko-KR", "nl-NL", "nl-BE",
- "nb-NO", "nn-NO", "pl-PL", "pt-BR",
- "pt-PT", "ro-RO", "ru-RU", "hr-HR",
- "Lt-sr-SP", "Cy-sr-SP", "sk-SK", "sq-AL",
- "sv-SE", "sv-FI", "th-TH", "tr-TR",
- "ur-PK", "id-ID", "uk-UA", "be-BY",
- "sl-SI", "et-EE", "lv-LV", "lt-LT",
- "fa-IR", "vi-VN", "hy-AM", "Lt-az-AZ",
- "Cy-az-AZ",
- "eu-ES", "mk-MK", "af-ZA",
- "ka-GE", "fo-FO", "hi-IN", "ms-MY",
- "ms-BN", "kk-KZ", "ky-KZ", "sw-KE",
- "Lt-uz-UZ", "Cy-uz-UZ", "tt-TA", "pa-IN",
- "gu-IN", "ta-IN", "te-IN", "kn-IN",
- "mr-IN", "sa-IN", "mn-MN", "gl-ES",
- "kok-IN", "syr-SY", "div-MV"
-};
-
-static int
-is_valid_culture (const char *cname)
-{
- int i;
- int found;
-
- found = *cname == 0;
- for (i = 0; i < G_N_ELEMENTS (valid_cultures); ++i) {
- if (g_ascii_strcasecmp (valid_cultures [i], cname)) {
- found = 1;
- break;
- }
- }
- return found;
-}
-
-static int
-is_valid_assembly_flags (guint32 flags) {
- /* Metadata: 22.1.2 */
- flags &= ~(0x8000 | 0x4000); /* ignore reserved bits 0x0030? */
- return ((flags == 1) || (flags == 0));
-}
-
-static int
-is_valid_blob (MonoImage *image, guint32 blob_index, int notnull)
-{
- guint32 size;
- const char *p, *blob_end;
-
- if (blob_index >= image->heap_blob.size)
- return 0;
- p = mono_metadata_blob_heap (image, blob_index);
- size = mono_metadata_decode_blob_size (p, &blob_end);
- if (blob_index + size + (blob_end-p) > image->heap_blob.size)
- return 0;
- if (notnull && !size)
- return 0;
- return 1;
-}
-
-static const char*
-is_valid_string (MonoImage *image, guint32 str_index, int notnull)
-{
- const char *p, *blob_end, *res;
-
- if (str_index >= image->heap_strings.size)
- return NULL;
- res = p = mono_metadata_string_heap (image, str_index);
- blob_end = mono_metadata_string_heap (image, image->heap_strings.size - 1);
- if (notnull && !*p)
- return 0;
- /*
- * FIXME: should check it's a valid utf8 string, too.
- */
- while (p <= blob_end) {
- if (!*p)
- return res;
- ++p;
- }
- return *p? NULL: res;
-}
-
-static int
-is_valid_cls_ident (const char *p)
-{
- /*
- * FIXME: we need the full unicode glib support for this.
- * Check: http://www.unicode.org/unicode/reports/tr15/Identifier.java
- * We do the lame thing for now.
- */
- if (!isalpha (*p))
- return 0;
- ++p;
- while (*p) {
- if (!isalnum (*p) && *p != '_')
- return 0;
- ++p;
- }
- return 1;
-}
-
-static int
-is_valid_filename (const char *p)
-{
- if (!*p)
- return 0;
- return strpbrk (p, "\\//:")? 0: 1;
-}
-
-static GSList*
-verify_assembly_table (MonoImage *image, GSList *list, int level)
-{
- MonoTableInfo *t = &image->tables [MONO_TABLE_ASSEMBLY];
- guint32 cols [MONO_ASSEMBLY_SIZE];
- const char *p;
-
- if (level & MONO_VERIFY_ERROR) {
- if (t->rows > 1)
- ADD_ERROR (list, g_strdup ("Assembly table may only have 0 or 1 rows"));
- mono_metadata_decode_row (t, 0, cols, MONO_ASSEMBLY_SIZE);
-
- switch (cols [MONO_ASSEMBLY_HASH_ALG]) {
- case ASSEMBLY_HASH_NONE:
- case ASSEMBLY_HASH_MD5:
- case ASSEMBLY_HASH_SHA1:
- break;
- default:
- ADD_ERROR (list, g_strdup_printf ("Hash algorithm 0x%x unknown", cols [MONO_ASSEMBLY_HASH_ALG]));
- }
-
- if (!is_valid_assembly_flags (cols [MONO_ASSEMBLY_FLAGS]))
- ADD_ERROR (list, g_strdup_printf ("Invalid flags in assembly: 0x%x", cols [MONO_ASSEMBLY_FLAGS]));
-
- if (!is_valid_blob (image, cols [MONO_ASSEMBLY_PUBLIC_KEY], FALSE))
- ADD_ERROR (list, g_strdup ("Assembly public key is an invalid index"));
-
- if (!(p = is_valid_string (image, cols [MONO_ASSEMBLY_NAME], TRUE))) {
- ADD_ERROR (list, g_strdup ("Assembly name is invalid"));
- } else {
- if (strpbrk (p, ":\\/."))
- ADD_ERROR (list, g_strdup_printf ("Assembly name `%s' contains invalid chars", p));
- }
-
- if (!(p = is_valid_string (image, cols [MONO_ASSEMBLY_CULTURE], FALSE))) {
- ADD_ERROR (list, g_strdup ("Assembly culture is an invalid index"));
- } else {
- if (!is_valid_culture (p))
- ADD_ERROR (list, g_strdup_printf ("Assembly culture `%s' is invalid", p));
- }
- }
- return list;
-}
-
-static GSList*
-verify_assemblyref_table (MonoImage *image, GSList *list, int level)
-{
- MonoTableInfo *t = &image->tables [MONO_TABLE_ASSEMBLYREF];
- guint32 cols [MONO_ASSEMBLYREF_SIZE];
- const char *p;
- int i;
-
- if (level & MONO_VERIFY_ERROR) {
- for (i = 0; i < t->rows; ++i) {
- mono_metadata_decode_row (t, i, cols, MONO_ASSEMBLYREF_SIZE);
- if (!is_valid_assembly_flags (cols [MONO_ASSEMBLYREF_FLAGS]))
- ADD_ERROR (list, g_strdup_printf ("Invalid flags in assemblyref row %d: 0x%x", i + 1, cols [MONO_ASSEMBLY_FLAGS]));
-
- if (!is_valid_blob (image, cols [MONO_ASSEMBLYREF_PUBLIC_KEY], FALSE))
- ADD_ERROR (list, g_strdup_printf ("AssemblyRef public key in row %d is an invalid index", i + 1));
-
- if (!(p = is_valid_string (image, cols [MONO_ASSEMBLYREF_CULTURE], FALSE))) {
- ADD_ERROR (list, g_strdup_printf ("AssemblyRef culture in row %d is invalid", i + 1));
- } else {
- if (!is_valid_culture (p))
- ADD_ERROR (list, g_strdup_printf ("AssemblyRef culture `%s' in row %d is invalid", p, i + 1));
- }
-
- if (cols [MONO_ASSEMBLYREF_HASH_VALUE] && !is_valid_blob (image, cols [MONO_ASSEMBLYREF_HASH_VALUE], TRUE))
- ADD_ERROR (list, g_strdup_printf ("AssemblyRef hash value in row %d is invalid or not null and empty", i + 1));
- }
- }
- if (level & MONO_VERIFY_WARNING) {
- /* check for duplicated rows */
- for (i = 0; i < t->rows; ++i) {
- }
- }
- return list;
-}
-
-static GSList*
-verify_class_layout_table (MonoImage *image, GSList *list, int level)
-{
- MonoTableInfo *t = &image->tables [MONO_TABLE_CLASSLAYOUT];
- MonoTableInfo *tdef = &image->tables [MONO_TABLE_TYPEDEF];
- guint32 cols [MONO_CLASS_LAYOUT_SIZE];
- guint32 value, i;
-
- if (level & MONO_VERIFY_ERROR) {
- for (i = 0; i < t->rows; ++i) {
- mono_metadata_decode_row (t, i, cols, MONO_CLASS_LAYOUT_SIZE);
-
- if (cols [MONO_CLASS_LAYOUT_PARENT] > tdef->rows || !cols [MONO_CLASS_LAYOUT_PARENT]) {
- ADD_ERROR (list, g_strdup_printf ("Parent in class layout is invalid in row %d", i + 1));
- } else {
- value = mono_metadata_decode_row_col (tdef, cols [MONO_CLASS_LAYOUT_PARENT] - 1, MONO_TYPEDEF_FLAGS);
- if (value & TYPE_ATTRIBUTE_INTERFACE)
- ADD_ERROR (list, g_strdup_printf ("Parent in class layout row %d is an interface", i + 1));
- if (value & TYPE_ATTRIBUTE_AUTO_LAYOUT)
- ADD_ERROR (list, g_strdup_printf ("Parent in class layout row %d is AutoLayout", i + 1));
- if (value & TYPE_ATTRIBUTE_SEQUENTIAL_LAYOUT) {
- switch (cols [MONO_CLASS_LAYOUT_PACKING_SIZE]) {
- case 0: case 1: case 2: case 4: case 8: case 16:
- case 32: case 64: case 128: break;
- default:
- ADD_ERROR (list, g_strdup_printf ("Packing size %d in class layout row %d is invalid", cols [MONO_CLASS_LAYOUT_PACKING_SIZE], i + 1));
- }
- } else if (value & TYPE_ATTRIBUTE_EXPLICIT_LAYOUT) {
- /*
- * FIXME: LAMESPEC: it claims it must be 0 (it's 1, instead).
- if (cols [MONO_CLASS_LAYOUT_PACKING_SIZE])
- ADD_ERROR (list, g_strdup_printf ("Packing size %d in class layout row %d is invalid with explicit layout", cols [MONO_CLASS_LAYOUT_PACKING_SIZE], i + 1));
- */
- }
- /*
- * FIXME: we need to check that if class size != 0,
- * it needs to be greater than the class calculated size.
- * If parent is a valuetype it also needs to be smaller than
- * 1 MByte (0x100000 bytes).
- * To do both these checks we need to load the referenced
- * assemblies, though (the spec claims we didn't have to, bah).
- */
- /*
- * We need to check that the parent types have the same layout
- * type as well.
- */
- }
- }
- }
-
- return list;
-}
-
-static GSList*
-verify_constant_table (MonoImage *image, GSList *list, int level)
-{
- MonoTableInfo *t = &image->tables [MONO_TABLE_CONSTANT];
- guint32 cols [MONO_CONSTANT_SIZE];
- guint32 value, i;
- GHashTable *dups = g_hash_table_new (NULL, NULL);
-
- for (i = 0; i < t->rows; ++i) {
- mono_metadata_decode_row (t, i, cols, MONO_CONSTANT_SIZE);
-
- if (level & MONO_VERIFY_ERROR)
- if (g_hash_table_lookup (dups, GUINT_TO_POINTER (cols [MONO_CONSTANT_PARENT])))
- ADD_ERROR (list, g_strdup_printf ("Parent 0x%08x is duplicated in Constant row %d", cols [MONO_CONSTANT_PARENT], i + 1));
- g_hash_table_insert (dups, GUINT_TO_POINTER (cols [MONO_CONSTANT_PARENT]),
- GUINT_TO_POINTER (cols [MONO_CONSTANT_PARENT]));
-
- switch (cols [MONO_CONSTANT_TYPE]) {
- case MONO_TYPE_U1: /* LAMESPEC: it says I1...*/
- case MONO_TYPE_U2:
- case MONO_TYPE_U4:
- case MONO_TYPE_U8:
- if (level & MONO_VERIFY_CLS)
- ADD_WARN (list, MONO_VERIFY_CLS, g_strdup_printf ("Type 0x%x not CLS compliant in Constant row %d", cols [MONO_CONSTANT_TYPE], i + 1));
- case MONO_TYPE_BOOLEAN:
- case MONO_TYPE_CHAR:
- case MONO_TYPE_I1:
- case MONO_TYPE_I2:
- case MONO_TYPE_I4:
- case MONO_TYPE_I8:
- case MONO_TYPE_R4:
- case MONO_TYPE_R8:
- case MONO_TYPE_STRING:
- case MONO_TYPE_CLASS:
- break;
- default:
- if (level & MONO_VERIFY_ERROR)
- ADD_ERROR (list, g_strdup_printf ("Type 0x%x is invalid in Constant row %d", cols [MONO_CONSTANT_TYPE], i + 1));
- }
- if (level & MONO_VERIFY_ERROR) {
- value = cols [MONO_CONSTANT_PARENT] >> MONO_HASCONSTANT_BITS;
- switch (cols [MONO_CONSTANT_PARENT] & MONO_HASCONSTANT_MASK) {
- case MONO_HASCONSTANT_FIEDDEF:
- if (value > image->tables [MONO_TABLE_FIELD].rows)
- ADD_ERROR (list, g_strdup_printf ("Parent (field) is invalid in Constant row %d", i + 1));
- break;
- case MONO_HASCONSTANT_PARAM:
- if (value > image->tables [MONO_TABLE_PARAM].rows)
- ADD_ERROR (list, g_strdup_printf ("Parent (param) is invalid in Constant row %d", i + 1));
- break;
- case MONO_HASCONSTANT_PROPERTY:
- if (value > image->tables [MONO_TABLE_PROPERTY].rows)
- ADD_ERROR (list, g_strdup_printf ("Parent (property) is invalid in Constant row %d", i + 1));
- break;
- default:
- ADD_ERROR (list, g_strdup_printf ("Parent is invalid in Constant row %d", i + 1));
- break;
- }
- }
- if (level & MONO_VERIFY_CLS) {
- /*
- * FIXME: verify types is consistent with the enum type
- * is parent is an enum.
- */
- }
- }
- g_hash_table_destroy (dups);
- return list;
-}
-
-static GSList*
-verify_event_map_table (MonoImage *image, GSList *list, int level)
-{
- MonoTableInfo *t = &image->tables [MONO_TABLE_EVENTMAP];
- guint32 cols [MONO_EVENT_MAP_SIZE];
- guint32 i, last_event;
- GHashTable *dups = g_hash_table_new (NULL, NULL);
-
- last_event = 0;
-
- for (i = 0; i < t->rows; ++i) {
- mono_metadata_decode_row (t, i, cols, MONO_EVENT_MAP_SIZE);
- if (level & MONO_VERIFY_ERROR)
- if (g_hash_table_lookup (dups, GUINT_TO_POINTER (cols [MONO_EVENT_MAP_PARENT])))
- ADD_ERROR (list, g_strdup_printf ("Parent 0x%08x is duplicated in Event Map row %d", cols [MONO_EVENT_MAP_PARENT], i + 1));
- g_hash_table_insert (dups, GUINT_TO_POINTER (cols [MONO_EVENT_MAP_PARENT]),
- GUINT_TO_POINTER (cols [MONO_EVENT_MAP_PARENT]));
- if (level & MONO_VERIFY_ERROR) {
- if (cols [MONO_EVENT_MAP_PARENT] > image->tables [MONO_TABLE_TYPEDEF].rows)
- ADD_ERROR (list, g_strdup_printf ("Parent 0x%08x is invalid in Event Map row %d", cols [MONO_EVENT_MAP_PARENT], i + 1));
- if (cols [MONO_EVENT_MAP_EVENTLIST] > image->tables [MONO_TABLE_EVENT].rows)
- ADD_ERROR (list, g_strdup_printf ("EventList 0x%08x is invalid in Event Map row %d", cols [MONO_EVENT_MAP_EVENTLIST], i + 1));
-
- if (cols [MONO_EVENT_MAP_EVENTLIST] <= last_event)
- ADD_ERROR (list, g_strdup_printf ("EventList overlap in Event Map row %d", i + 1));
- last_event = cols [MONO_EVENT_MAP_EVENTLIST];
- }
- }
-
- g_hash_table_destroy (dups);
- return list;
-}
-
-static GSList*
-verify_event_table (MonoImage *image, GSList *list, int level)
-{
- MonoTableInfo *t = &image->tables [MONO_TABLE_EVENT];
- guint32 cols [MONO_EVENT_SIZE];
- const char *p;
- guint32 value, i;
-
- for (i = 0; i < t->rows; ++i) {
- mono_metadata_decode_row (t, i, cols, MONO_EVENT_SIZE);
-
- if (cols [MONO_EVENT_FLAGS] & ~(EVENT_SPECIALNAME|EVENT_RTSPECIALNAME)) {
- if (level & MONO_VERIFY_ERROR)
- ADD_ERROR (list, g_strdup_printf ("Flags 0x%04x invalid in Event row %d", cols [MONO_EVENT_FLAGS], i + 1));
- }
- if (!(p = is_valid_string (image, cols [MONO_EVENT_NAME], TRUE))) {
- if (level & MONO_VERIFY_ERROR)
- ADD_ERROR (list, g_strdup_printf ("Invalid name in Event row %d", i + 1));
- } else {
- if (level & MONO_VERIFY_CLS) {
- if (!is_valid_cls_ident (p))
- ADD_WARN (list, MONO_VERIFY_CLS, g_strdup_printf ("Invalid CLS name '%s` in Event row %d", p, i + 1));
- }
- }
-
- if (level & MONO_VERIFY_ERROR && cols [MONO_EVENT_TYPE]) {
- value = cols [MONO_EVENT_TYPE] >> MONO_TYPEDEFORREF_BITS;
- switch (cols [MONO_EVENT_TYPE] & MONO_TYPEDEFORREF_MASK) {
- case MONO_TYPEDEFORREF_TYPEDEF:
- if (!value || value > image->tables [MONO_TABLE_TYPEDEF].rows)
- ADD_ERROR (list, g_strdup_printf ("Type invalid in Event row %d", i + 1));
- break;
- case MONO_TYPEDEFORREF_TYPEREF:
- if (!value || value > image->tables [MONO_TABLE_TYPEREF].rows)
- ADD_ERROR (list, g_strdup_printf ("Type invalid in Event row %d", i + 1));
- break;
- case MONO_TYPEDEFORREF_TYPESPEC:
- if (!value || value > image->tables [MONO_TABLE_TYPESPEC].rows)
- ADD_ERROR (list, g_strdup_printf ("Type invalid in Event row %d", i + 1));
- break;
- default:
- ADD_ERROR (list, g_strdup_printf ("Type invalid in Event row %d", i + 1));
- }
- }
- /*
- * FIXME: check that there is 1 add and remove row in methodsemantics
- * and 0 or 1 raise and 0 or more other (maybe it's better to check for
- * these while checking methodsemantics).
- * check for duplicated names for the same type [ERROR]
- * check for CLS duplicate names for the same type [CLS]
- */
- }
- return list;
-}
-
-static GSList*
-verify_field_table (MonoImage *image, GSList *list, int level)
-{
- MonoTableInfo *t = &image->tables [MONO_TABLE_FIELD];
- guint32 cols [MONO_FIELD_SIZE];
- const char *p;
- guint32 i, flags;
-
- for (i = 0; i < t->rows; ++i) {
- mono_metadata_decode_row (t, i, cols, MONO_FIELD_SIZE);
- /*
- * Check this field has only one owner and that the owner is not
- * an interface (done in verify_typedef_table() )
- */
- flags = cols [MONO_FIELD_FLAGS];
- switch (flags & FIELD_ATTRIBUTE_FIELD_ACCESS_MASK) {
- case FIELD_ATTRIBUTE_COMPILER_CONTROLLED:
- case FIELD_ATTRIBUTE_PRIVATE:
- case FIELD_ATTRIBUTE_FAM_AND_ASSEM:
- case FIELD_ATTRIBUTE_ASSEMBLY:
- case FIELD_ATTRIBUTE_FAMILY:
- case FIELD_ATTRIBUTE_FAM_OR_ASSEM:
- case FIELD_ATTRIBUTE_PUBLIC:
- break;
- default:
- if (level & MONO_VERIFY_ERROR)
- ADD_ERROR (list, g_strdup_printf ("Invalid access mask in Field row %d", i + 1));
- break;
- }
- if (level & MONO_VERIFY_ERROR) {
- if ((flags & FIELD_ATTRIBUTE_LITERAL) && (flags & FIELD_ATTRIBUTE_INIT_ONLY))
- ADD_ERROR (list, g_strdup_printf ("Literal and InitOnly cannot be both set in Field row %d", i + 1));
- if ((flags & FIELD_ATTRIBUTE_LITERAL) && !(flags & FIELD_ATTRIBUTE_STATIC))
- ADD_ERROR (list, g_strdup_printf ("Literal needs also Static set in Field row %d", i + 1));
- if ((flags & FIELD_ATTRIBUTE_RT_SPECIAL_NAME) && !(flags & FIELD_ATTRIBUTE_SPECIAL_NAME))
- ADD_ERROR (list, g_strdup_printf ("RTSpecialName needs also SpecialName set in Field row %d", i + 1));
- /*
- * FIXME: check there is only one owner in the respective table.
- * if (flags & FIELD_ATTRIBUTE_HAS_FIELD_MARSHAL)
- * if (flags & FIELD_ATTRIBUTE_HAS_DEFAULT)
- * if (flags & FIELD_ATTRIBUTE_HAS_FIELD_RVA)
- */
- }
- if (!(p = is_valid_string (image, cols [MONO_FIELD_NAME], TRUE))) {
- if (level & MONO_VERIFY_ERROR)
- ADD_ERROR (list, g_strdup_printf ("Invalid name in Field row %d", i + 1));
- } else {
- if (level & MONO_VERIFY_CLS) {
- if (!is_valid_cls_ident (p))
- ADD_WARN (list, MONO_VERIFY_CLS, g_strdup_printf ("Invalid CLS name '%s` in Field row %d", p, i + 1));
- }
- }
- /*
- * check signature.
- * if owner is module needs to be static, access mask needs to be compilercontrolled,
- * public or private (not allowed in cls mode).
- * if owner is an enum ...
- */
-
-
- }
- return list;
-}
-
-static GSList*
-verify_file_table (MonoImage *image, GSList *list, int level)
-{
- MonoTableInfo *t = &image->tables [MONO_TABLE_FILE];
- guint32 cols [MONO_FILE_SIZE];
- const char *p;
- guint32 i;
- GHashTable *dups = g_hash_table_new (g_str_hash, g_str_equal);
-
- for (i = 0; i < t->rows; ++i) {
- mono_metadata_decode_row (t, i, cols, MONO_FILE_SIZE);
- if (level & MONO_VERIFY_ERROR) {
- if (cols [MONO_FILE_FLAGS] != FILE_CONTAINS_METADATA && cols [MONO_FILE_FLAGS] != FILE_CONTAINS_NO_METADATA)
- ADD_ERROR (list, g_strdup_printf ("Invalid flags in File row %d", i + 1));
- if (!is_valid_blob (image, cols [MONO_FILE_HASH_VALUE], TRUE))
- ADD_ERROR (list, g_strdup_printf ("File hash value in row %d is invalid or not null and empty", i + 1));
- }
- if (!(p = is_valid_string (image, cols [MONO_FILE_NAME], TRUE))) {
- if (level & MONO_VERIFY_ERROR)
- ADD_ERROR (list, g_strdup_printf ("Invalid name in File row %d", i + 1));
- } else {
- if (level & MONO_VERIFY_ERROR) {
- if (!is_valid_filename (p))
- ADD_ERROR (list, g_strdup_printf ("Invalid name '%s` in File row %d", p, i + 1));
- else if (g_hash_table_lookup (dups, p)) {
- ADD_ERROR (list, g_strdup_printf ("Duplicate name '%s` in File row %d", p, i + 1));
- }
- g_hash_table_insert (dups, (gpointer)p, (gpointer)p);
- }
- }
- /*
- * FIXME: I don't understand what this means:
- * If this module contains a row in the Assembly table (that is, if this module "holds the manifest")
- * then there shall not be any row in the File table for this module - i.e., no self-reference [ERROR]
- */
-
- }
- if (level & MONO_VERIFY_WARNING) {
- if (!t->rows && image->tables [MONO_TABLE_EXPORTEDTYPE].rows)
- ADD_WARN (list, MONO_VERIFY_WARNING, g_strdup ("ExportedType table should be empty if File table is empty"));
- }
- g_hash_table_destroy (dups);
- return list;
-}
-
-static GSList*
-verify_moduleref_table (MonoImage *image, GSList *list, int level)
-{
- MonoTableInfo *t = &image->tables [MONO_TABLE_MODULEREF];
- MonoTableInfo *tfile = &image->tables [MONO_TABLE_FILE];
- guint32 cols [MONO_MODULEREF_SIZE];
- const char *p, *pf;
- guint32 found, i, j, value;
- GHashTable *dups = g_hash_table_new (g_str_hash, g_str_equal);
-
- for (i = 0; i < t->rows; ++i) {
- mono_metadata_decode_row (t, i, cols, MONO_MODULEREF_SIZE);
- if (!(p = is_valid_string (image, cols [MONO_MODULEREF_NAME], TRUE))) {
- if (level & MONO_VERIFY_ERROR)
- ADD_ERROR (list, g_strdup_printf ("Invalid name in ModuleRef row %d", i + 1));
- } else {
- if (level & MONO_VERIFY_ERROR) {
- if (!is_valid_filename (p))
- ADD_ERROR (list, g_strdup_printf ("Invalid name '%s` in ModuleRef row %d", p, i + 1));
- else if (g_hash_table_lookup (dups, p)) {
- ADD_WARN (list, MONO_VERIFY_WARNING, g_strdup_printf ("Duplicate name '%s` in ModuleRef row %d", p, i + 1));
- g_hash_table_insert (dups, (gpointer)p, (gpointer)p);
- found = 0;
- for (j = 0; j < tfile->rows; ++j) {
- value = mono_metadata_decode_row_col (tfile, j, MONO_FILE_NAME);
- if ((pf = is_valid_string (image, value, TRUE)))
- if (strcmp (p, pf) == 0) {
- found = 1;
- break;
- }
- }
- if (!found)
- ADD_ERROR (list, g_strdup_printf ("Name '%s` in ModuleRef row %d doesn't have a match in File table", p, i + 1));
- }
- }
- }
- }
- g_hash_table_destroy (dups);
- return list;
-}
-
-static GSList*
-verify_standalonesig_table (MonoImage *image, GSList *list, int level)
-{
- MonoTableInfo *t = &image->tables [MONO_TABLE_STANDALONESIG];
- guint32 cols [MONO_STAND_ALONE_SIGNATURE_SIZE];
- const char *p;
- guint32 i;
-
- for (i = 0; i < t->rows; ++i) {
- mono_metadata_decode_row (t, i, cols, MONO_STAND_ALONE_SIGNATURE_SIZE);
- if (level & MONO_VERIFY_ERROR) {
- if (!is_valid_blob (image, cols [MONO_STAND_ALONE_SIGNATURE], TRUE)) {
- ADD_ERROR (list, g_strdup_printf ("Signature is invalid in StandAloneSig row %d", i + 1));
- } else {
- p = mono_metadata_blob_heap (image, cols [MONO_STAND_ALONE_SIGNATURE]);
- /* FIXME: check it's a valid locals or method sig.*/
- }
- }
- }
- return list;
-}
-
-GSList*
-mono_image_verify_tables (MonoImage *image, int level)
-{
- GSList *error_list = NULL;
-
- error_list = verify_assembly_table (image, error_list, level);
- /*
- * AssemblyOS, AssemblyProcessor, AssemblyRefOs and
- * AssemblyRefProcessor should be ignored,
- * though we may want to emit a warning, since it should not
- * be present in a PE file.
- */
- error_list = verify_assemblyref_table (image, error_list, level);
- error_list = verify_class_layout_table (image, error_list, level);
- error_list = verify_constant_table (image, error_list, level);
- /*
- * cutom attribute, declsecurity
- */
- error_list = verify_event_map_table (image, error_list, level);
- error_list = verify_event_table (image, error_list, level);
- error_list = verify_field_table (image, error_list, level);
- error_list = verify_file_table (image, error_list, level);
- error_list = verify_moduleref_table (image, error_list, level);
- error_list = verify_standalonesig_table (image, error_list, level);
-
- return g_slist_reverse (error_list);
-}
-
#define ADD_INVALID(list,msg) \
do { \
MonoVerifyInfoExtended *vinfo = g_new (MonoVerifyInfoExtended, 1); \
@@ -6449,10 +5830,4 @@ mono_free_verify_list (GSList *list)
/* will always be null if verifier is disabled */
}
-GSList*
-mono_image_verify_tables (MonoImage *image, int level)
-{
- /* The verifier was disabled at compile time */
- return NULL;
-}
#endif
1  mono/metadata/verify.h
View
@@ -52,7 +52,6 @@ typedef struct {
} MonoVerifyInfoExtended;
-GSList* mono_image_verify_tables (MonoImage *image, int level);
GSList* mono_method_verify (MonoMethod *method, int level);
void mono_free_verify_list (GSList *list);
char* mono_verify_corlib (void);
Please sign in to comment.
Something went wrong with that request. Please try again.