Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorRodrigo Kumpera <kumpera@users.noreply.github.com>2017-08-16 07:58:17 +0300
committerGitHub <noreply@github.com>2017-08-16 07:58:17 +0300
commitd67c6000ce1d36f882eea059b8f874456055a6b9 (patch)
treefe4b1f8c7640e3456def2aee5f5e8e391e6d92e1 /tools
parent16eadad7d3f724ff400276a55bb2d4a13146c9b6 (diff)
parentc385035a808fc70681bf46eb420b512e574e976e (diff)
Merge pull request #5382 from kumpera/pedump_fix
Address pedump issues from https://bugzilla.xamarin.com/show_bug.cgi?id=58168
Diffstat (limited to 'tools')
-rw-r--r--tools/pedump/pedump.c109
1 files changed, 74 insertions, 35 deletions
diff --git a/tools/pedump/pedump.c b/tools/pedump/pedump.c
index 322185faaf7..722d42f9828 100644
--- a/tools/pedump/pedump.c
+++ b/tools/pedump/pedump.c
@@ -348,7 +348,7 @@ dump_dotnet_iinfo (MonoImage *image)
}
static int
-dump_verify_info (MonoImage *image, int flags)
+dump_verify_info (MonoImage *image, int flags, gboolean valid_only)
{
GSList *errors, *tmp;
int count = 0, verifiable = 0;
@@ -387,6 +387,9 @@ dump_verify_info (MonoImage *image, int flags)
for (tmp = errors; tmp; tmp = tmp->next) {
MonoVerifyInfo *info = (MonoVerifyInfo *)tmp->data;
+ if (info->status == MONO_VERIFY_NOT_VERIFIABLE && valid_only)
+ continue;
+
g_print ("%s: %s\n", desc [info->status], info->message);
if (info->status == MONO_VERIFY_ERROR) {
count++;
@@ -426,51 +429,83 @@ verify_image_file (const char *fname)
"Ok", "Error", "Warning", NULL, "CLS", NULL, NULL, NULL, "Not Verifiable"
};
- image = mono_image_open_raw (fname, &status);
- if (!image) {
- printf ("Could not open %s\n", fname);
- return 1;
- }
+ if (!strstr (fname, "mscorlib.dll")) {
+ image = mono_image_open_raw (fname, &status);
+ if (!image) {
+ printf ("Could not open %s\n", fname);
+ return 1;
+ }
- if (!mono_verifier_verify_pe_data (image, &errors))
- goto invalid_image;
+ if (!mono_verifier_verify_pe_data (image, &errors))
+ goto invalid_image;
- if (!mono_image_load_pe_data (image)) {
- printf ("Could not load pe data for assembly %s\n", fname);
- return 1;
- }
+ if (!mono_image_load_pe_data (image)) {
+ printf ("Could not load pe data for assembly %s\n", fname);
+ return 1;
+ }
- if (!mono_verifier_verify_cli_data (image, &errors))
- goto invalid_image;
+ if (!mono_verifier_verify_cli_data (image, &errors))
+ goto invalid_image;
- if (!mono_image_load_cli_data (image)) {
- printf ("Could not load cli data for assembly %s\n", fname);
- return 1;
- }
+ if (!mono_image_load_cli_data (image)) {
+ printf ("Could not load cli data for assembly %s\n", fname);
+ return 1;
+ }
- if (!mono_verifier_verify_table_data (image, &errors))
- goto invalid_image;
+ if (!mono_verifier_verify_table_data (image, &errors))
+ goto invalid_image;
+
+ mono_image_load_names (image);
- mono_image_load_names (image);
+ /*fake an assembly for class loading to work*/
+ assembly = g_new0 (MonoAssembly, 1);
+ assembly->in_gac = FALSE;
+ assembly->image = image;
+ image->assembly = assembly;
+ mono_assembly_fill_assembly_name (image, &assembly->aname);
- /*fake an assembly for class loading to work*/
- assembly = g_new0 (MonoAssembly, 1);
- assembly->in_gac = FALSE;
- assembly->image = image;
- image->assembly = assembly;
- mono_assembly_fill_assembly_name (image, &assembly->aname);
+ /*Finish initializing the runtime*/
+ mono_install_assembly_load_hook (pedump_assembly_load_hook, NULL);
+ mono_install_assembly_search_hook (pedump_assembly_search_hook, NULL);
- /*Finish initializing the runtime*/
- mono_install_assembly_load_hook (pedump_assembly_load_hook, NULL);
- mono_install_assembly_search_hook (pedump_assembly_search_hook, NULL);
+ mono_init_version ("pedump", image->version);
- mono_init_version ("pedump", image->version);
+ mono_install_assembly_preload_hook (pedump_preload, GUINT_TO_POINTER (FALSE));
- mono_install_assembly_preload_hook (pedump_preload, GUINT_TO_POINTER (FALSE));
+ mono_icall_init ();
+ mono_marshal_init ();
+ } else {
+ /*Finish initializing the runtime*/
+ mono_install_assembly_load_hook (pedump_assembly_load_hook, NULL);
+ mono_install_assembly_search_hook (pedump_assembly_search_hook, NULL);
+
+ mono_init_version ("pedump", NULL);
+
+ mono_install_assembly_preload_hook (pedump_preload, GUINT_TO_POINTER (FALSE));
- mono_icall_init ();
- mono_marshal_init ();
+ mono_icall_init ();
+ mono_marshal_init ();
+ image = mono_get_corlib ();
+
+ if (!mono_verifier_verify_pe_data (image, &errors))
+ goto invalid_image;
+
+ if (!mono_image_load_pe_data (image)) {
+ printf ("Could not load pe data for assembly %s\n", fname);
+ return 1;
+ }
+ if (!mono_verifier_verify_cli_data (image, &errors))
+ goto invalid_image;
+
+ if (!mono_image_load_cli_data (image)) {
+ printf ("Could not load cli data for assembly %s\n", fname);
+ return 1;
+ }
+
+ if (!mono_verifier_verify_table_data (image, &errors))
+ goto invalid_image;
+ }
if (!verify_partial_md && !mono_verifier_verify_full_table_data (image, &errors))
goto invalid_image;
@@ -669,6 +704,10 @@ main (int argc, char *argv [])
if (!file)
usage ();
+ //We have to force the runtime to load the corlib under verification as its own corlib so core types are properly populated in mono_defaults.
+ if (strstr (file, "mscorlib.dll"))
+ g_setenv ("MONO_PATH", g_path_get_dirname (file), 1);
+
#ifndef DISABLE_PERFCOUNTERS
mono_perfcounters_init ();
#endif
@@ -764,7 +803,7 @@ main (int argc, char *argv [])
return 4;
}
- code_result = dump_verify_info (assembly->image, verify_flags);
+ code_result = dump_verify_info (assembly->image, verify_flags, verifier_mode == MONO_VERIFIER_MODE_VALID);
return code_result ? code_result : image_result;
} else
mono_image_close (image);