From a9c75b075ceb62e0036a940b8220cc4d1b719448 Mon Sep 17 00:00:00 2001 From: Zoltan Varga Date: Mon, 29 Aug 2016 22:37:22 +0200 Subject: [PATCH] [runtime] Fix pedump by using the normal embedding APIs instead of initializing parts of the runtime. Fixes #43786. --- tools/pedump/Makefile.am | 1 + tools/pedump/pedump.c | 25 +++---------------------- 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/tools/pedump/Makefile.am b/tools/pedump/Makefile.am index d329d1fa9b1e..3c9ccc4a77b9 100644 --- a/tools/pedump/Makefile.am +++ b/tools/pedump/Makefile.am @@ -21,6 +21,7 @@ pedump_LDADD = \ $(top_builddir)/mono/sgen/libmonosgen-static.la \ $(top_builddir)/mono/io-layer/libwapi.la \ $(top_builddir)/mono/utils/libmonoutils.la \ + $(top_builddir)/mono/mini/libmini.la \ $(LLVM_LIBS) \ $(LLVM_LDFLAGS) \ $(GLIB_LIBS) \ diff --git a/tools/pedump/pedump.c b/tools/pedump/pedump.c index 4bbcc699335a..62ae54f53675 100644 --- a/tools/pedump/pedump.c +++ b/tools/pedump/pedump.c @@ -26,6 +26,7 @@ #include #include #include +#include #include "mono/utils/mono-digest.h" #include #include @@ -425,6 +426,8 @@ verify_image_file (const char *fname) "Ok", "Error", "Warning", NULL, "CLS", NULL, NULL, NULL, "Not Verifiable" }; + mono_jit_init_version ("pedump", NULL); + image = mono_image_open_raw (fname, &status); if (!image) { printf ("Could not open %s\n", fname); @@ -459,22 +462,9 @@ verify_image_file (const char *fname) 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); - - mono_init_version ("pedump", image->version); - - mono_install_assembly_preload_hook (pedump_preload, GUINT_TO_POINTER (FALSE)); - - mono_icall_init (); - mono_marshal_init (); - - if (!verify_partial_md && !mono_verifier_verify_full_table_data (image, &errors)) goto invalid_image; - table = &image->tables [MONO_TABLE_TYPEDEF]; for (i = 1; i <= table->rows; ++i) { MonoError error; @@ -653,15 +643,6 @@ main (int argc, char *argv []) if (!file) usage (); - -#ifndef DISABLE_PERFCOUNTERS - mono_perfcounters_init (); -#endif - mono_counters_init (); - mono_metadata_init (); - mono_images_init (); - mono_assemblies_init (); - mono_loader_init (); if (verify_pe) { char *tok = strtok (flags, ",");