2009-08-27 Rodrigo Kumpera <rkumpera@novell.com>
authorRodrigo Kumpera <kumpera@gmail.com>
Thu, 27 Aug 2009 19:59:07 +0000 (19:59 -0000)
committerRodrigo Kumpera <kumpera@gmail.com>
Thu, 27 Aug 2009 19:59:07 +0000 (19:59 -0000)
* pedump.c: Initialize all types during metadata validation so we report
errors only detected as part of class initialization.

svn path=/trunk/mono/; revision=140838

mono/metadata/ChangeLog
mono/metadata/pedump.c

index 1a99dfa00a79058ce76b37f097e05254e5c666c7..82340b0a6be402165e4e1d3ea26235d5755812cb 100644 (file)
@@ -1,3 +1,8 @@
+2009-08-27  Rodrigo Kumpera  <rkumpera@novell.com>
+
+       * pedump.c: Initialize all types during metadata validation so we report
+       errors only detected as part of class initialization.
+
 2009-08-26  Rodrigo Kumpera  <rkumpera@novell.com>
 
        * metadata-verify.c (verify_method_table): PInvoke requires method to
index 83091fcbffb040c784e2584c45478f661c5b11b5..d0c847d7574ab5bf697f7966d496f2e0d52df395 100644 (file)
@@ -419,8 +419,10 @@ verify_image_file (const char *fname)
 {
        GSList *errors = NULL, *tmp;
        MonoImage *image;
+       MonoTableInfo *table;
+       MonoAssembly *assembly;
        MonoImageOpenStatus status;
-       int count = 0;
+       int i, count = 0;
        const char* desc [] = {
                "Ok", "Error", "Warning", NULL, "CLS", NULL, NULL, NULL, "Not Verifiable"
        };
@@ -455,6 +457,26 @@ verify_image_file (const char *fname)
        if (!mono_verifier_verify_full_table_data (image, &errors))
                goto invalid_image;
 
+
+       /*fake an assembly for class loading to work*/
+       assembly = g_new0 (MonoAssembly, 1);
+       assembly->in_gac = FALSE;
+       assembly->image = image;
+       image->assembly = assembly;
+
+       table = &image->tables [MONO_TABLE_TYPEDEF];
+       for (i = 1; i <= table->rows; ++i) {
+               guint32 token = i | MONO_TOKEN_TYPE_DEF;
+               MonoClass *class = mono_class_get (image, token);
+               mono_class_init (class);
+               if (class->exception_type != MONO_EXCEPTION_NONE || mono_loader_get_last_error ()) {
+                       printf ("Error verifying class(0x%08x) %s.%s a type load error happened\n", token, class->name_space, class->name);
+                       mono_loader_clear_error ();
+                       ++count;
+               }
+       }
+       if (count)
+               return 1;
        return 0;
 
 invalid_image: