From be629f49a350d526de2c65981294734cee420b90 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alexander=20K=C3=B6plinger?= Date: Sun, 6 Mar 2022 14:44:33 +0100 Subject: [PATCH] [mono] Remove SkipVerification support from the runtime (#66211) CAS support was removed in .NET Core. This allows us removing a bunch of code that is unused, e.g. the dependency on libiconv. --- src/mono/cmake/config.h.in | 6 - src/mono/cmake/configure.cmake | 9 +- src/mono/cmake/defines-todo.cmake | 1 - src/mono/mono/eglib/eglib-remap.h | 4 - src/mono/mono/eglib/giconv.c | 297 ---------------------------- src/mono/mono/eglib/glib.h | 13 -- src/mono/mono/eglib/test/utf8.c | 109 ---------- src/mono/mono/eventpipe/test/CMakeLists.txt | 2 +- src/mono/mono/metadata/assembly.c | 135 ------------- src/mono/mono/metadata/metadata-internals.h | 7 - src/mono/mono/mini/CMakeLists.txt | 6 +- src/mono/mono/mini/method-to-ir.c | 6 - src/mono/mono/mini/mini.c | 11 -- src/mono/mono/mini/mini.h | 1 - 14 files changed, 5 insertions(+), 602 deletions(-) diff --git a/src/mono/cmake/config.h.in b/src/mono/cmake/config.h.in index 575711f..2797669 100644 --- a/src/mono/cmake/config.h.in +++ b/src/mono/cmake/config.h.in @@ -933,12 +933,6 @@ /* Define to 1 if you have the header file. */ #cmakedefine HAVE_GETOPT_H 1 -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_ICONV_H 1 - -/* Define to 1 if you have the `iconv' library (-liconv). */ -#cmakedefine HAVE_LIBICONV 1 - /* Icall symbol map enabled */ #cmakedefine ENABLE_ICALL_SYMBOL_MAP 1 diff --git a/src/mono/cmake/configure.cmake b/src/mono/cmake/configure.cmake index ee62243..7c3d341 100644 --- a/src/mono/cmake/configure.cmake +++ b/src/mono/cmake/configure.cmake @@ -71,7 +71,7 @@ ac_check_headers ( strings.h stdint.h unistd.h signal.h setjmp.h syslog.h netdb.h utime.h semaphore.h libproc.h alloca.h ucontext.h pwd.h elf.h gnu/lib-names.h netinet/tcp.h netinet/in.h link.h arpa/inet.h unwind.h poll.h wchar.h linux/magic.h android/legacy_signal_inlines.h android/ndk-version.h execinfo.h pthread.h pthread_np.h net/if.h dirent.h - CommonCrypto/CommonDigest.h dlfcn.h getopt.h pwd.h iconv.h alloca.h + CommonCrypto/CommonDigest.h dlfcn.h getopt.h pwd.h alloca.h /usr/include/malloc.h) ac_check_funcs ( @@ -166,13 +166,6 @@ if (HOST_LINUX OR HOST_ANDROID) set(CMAKE_REQUIRED_DEFINITIONS) endif() -# ICONV -set(ICONV_LIB) -find_library(LIBICONV_FOUND iconv) -if(NOT LIBICONV_FOUND STREQUAL "LIBICONV_FOUND-NOTFOUND") - set(ICONV_LIB "iconv") -endif() - if(HOST_WIN32) # checking for this doesn't work for some reason, hardcode result set(HAVE_WINTERNL_H 1) diff --git a/src/mono/cmake/defines-todo.cmake b/src/mono/cmake/defines-todo.cmake index bc08dbd..12dca86 100644 --- a/src/mono/cmake/defines-todo.cmake +++ b/src/mono/cmake/defines-todo.cmake @@ -4,7 +4,6 @@ #option (MAJOR_IN_MKDEV "Define to 1 if `major', `minor', and `makedev' are declared in .") #option (MAJOR_IN_SYSMACROS "Define to 1 if `major', `minor', and `makedev' are declared in .") -#option (HAVE_LIBICONV "Define to 1 if you have the `iconv' library (-liconv).") #option (ANDROID_UNIFIED_HEADERS "Whether Android NDK unified headers are used") #option (MONO_DL_NEED_USCORE "Does dlsym require leading underscore.") #option (GLIBC_BEFORE_2_3_4_SCHED_SETAFFINITY "Have GLIBC_BEFORE_2_3_4_SCHED_SETAFFINITY") diff --git a/src/mono/mono/eglib/eglib-remap.h b/src/mono/mono/eglib/eglib-remap.h index a2e5840..bafeadf 100644 --- a/src/mono/mono/eglib/eglib-remap.h +++ b/src/mono/mono/eglib/eglib-remap.h @@ -27,7 +27,6 @@ #define g_byte_array_set_size monoeg_g_byte_array_set_size #define g_calloc monoeg_g_calloc #define g_clear_error monoeg_g_clear_error -#define g_convert monoeg_g_convert #define g_convert_error_quark monoeg_g_convert_error_quark #define g_fixed_buffer_custom_allocator monoeg_g_fixed_buffer_custom_allocator #define g_dir_close monoeg_g_dir_close @@ -78,9 +77,6 @@ #define g_hash_table_remove_all monoeg_g_hash_table_remove_all #define g_hash_table_iter_init monoeg_g_hash_table_iter_init #define g_hash_table_iter_next monoeg_g_hash_table_iter_next -#define g_iconv monoeg_g_iconv -#define g_iconv_close monoeg_g_iconv_close -#define g_iconv_open monoeg_g_iconv_open #define g_int_equal monoeg_g_int_equal #define g_int_hash monoeg_g_int_hash #define g_list_alloc monoeg_g_list_alloc diff --git a/src/mono/mono/eglib/giconv.c b/src/mono/mono/eglib/giconv.c index 6ab22e1..f549710 100644 --- a/src/mono/mono/eglib/giconv.c +++ b/src/mono/mono/eglib/giconv.c @@ -25,9 +25,6 @@ #include #include #include -#ifdef HAVE_ICONV_H -#include -#endif #include #include "../utils/mono-errno.h" @@ -41,18 +38,6 @@ #define UNROLL_DECODE_UTF8 0 #define UNROLL_ENCODE_UTF8 0 -typedef int (* Decoder) (char *inbuf, size_t inleft, gunichar *outchar); -typedef int (* Encoder) (gunichar c, char *outbuf, size_t outleft); - -struct _GIConv { - Decoder decode; - Encoder encode; - gunichar c; -#ifdef HAVE_LIBICONV - iconv_t cd; -#endif -}; - static int decode_utf32be (char *inbuf, size_t inleft, gunichar *outchar); static int encode_utf32be (gunichar c, char *outbuf, size_t outleft); @@ -83,171 +68,6 @@ static int encode_latin1 (gunichar c, char *outbuf, size_t outleft); #define encode_utf16 encode_utf16be #endif -static struct { - const char *name; - Decoder decoder; - Encoder encoder; -} charsets[] = { - { "ISO-8859-1", decode_latin1, encode_latin1 }, - { "ISO8859-1", decode_latin1, encode_latin1 }, - { "UTF-32BE", decode_utf32be, encode_utf32be }, - { "UTF-32LE", decode_utf32le, encode_utf32le }, - { "UTF-16BE", decode_utf16be, encode_utf16be }, - { "UTF-16LE", decode_utf16le, encode_utf16le }, - { "UTF-32", decode_utf32, encode_utf32 }, - { "UTF-16", decode_utf16, encode_utf16 }, - { "UTF-8", decode_utf8, encode_utf8 }, - { "US-ASCII", decode_latin1, encode_latin1 }, - { "Latin1", decode_latin1, encode_latin1 }, - { "ASCII", decode_latin1, encode_latin1 }, - { "UTF32", decode_utf32, encode_utf32 }, - { "UTF16", decode_utf16, encode_utf16 }, - { "UTF8", decode_utf8, encode_utf8 }, -}; - - -GIConv -g_iconv_open (const char *to_charset, const char *from_charset) -{ -#ifdef HAVE_LIBICONV - iconv_t icd = (iconv_t) -1; -#endif - Decoder decoder = NULL; - Encoder encoder = NULL; - GIConv cd; - guint i; - - if (!to_charset || !from_charset || !to_charset[0] || !from_charset[0]) { - mono_set_errno (EINVAL); - - return (GIConv) -1; - } - - for (i = 0; i < G_N_ELEMENTS (charsets); i++) { - if (!g_ascii_strcasecmp (charsets[i].name, from_charset)) - decoder = charsets[i].decoder; - - if (!g_ascii_strcasecmp (charsets[i].name, to_charset)) - encoder = charsets[i].encoder; - } - - if (!encoder || !decoder) { -#ifdef HAVE_LIBICONV - if ((icd = iconv_open (to_charset, from_charset)) == (iconv_t) -1) - return (GIConv) -1; -#else - mono_set_errno (EINVAL); - - return (GIConv) -1; -#endif - } - - cd = (GIConv) g_malloc (sizeof (struct _GIConv)); - cd->decode = decoder; - cd->encode = encoder; - cd->c = -1; - -#ifdef HAVE_LIBICONV - cd->cd = icd; -#endif - - return cd; -} - -int -g_iconv_close (GIConv cd) -{ -#ifdef HAVE_LIBICONV - if (cd->cd != (iconv_t) -1) - iconv_close (cd->cd); -#endif - - g_free (cd); - - return 0; -} - -gsize -g_iconv (GIConv cd, gchar **inbytes, gsize *inbytesleft, - gchar **outbytes, gsize *outbytesleft) -{ - gsize inleft, outleft; - char *inptr, *outptr; - gunichar c; - int rc = 0; - -#ifdef HAVE_LIBICONV - if (cd->cd != (iconv_t) -1) { - /* Note: gsize may have a different size than size_t, so we need to - remap inbytesleft and outbytesleft to size_t's. */ - size_t *outleftptr, *inleftptr; - size_t n_outleft, n_inleft; - - if (inbytesleft) { - n_inleft = *inbytesleft; - inleftptr = &n_inleft; - } else { - inleftptr = NULL; - } - - if (outbytesleft) { - n_outleft = *outbytesleft; - outleftptr = &n_outleft; - } else { - outleftptr = NULL; - } -// AIX needs this for C++ and GNU iconv -#if defined(__NetBSD__) || defined(_AIX) - return iconv (cd->cd, (const gchar **)inbytes, inleftptr, outbytes, outleftptr); -#else - return iconv (cd->cd, inbytes, inleftptr, outbytes, outleftptr); -#endif - } -#endif - - if (outbytes == NULL || outbytesleft == NULL) { - /* reset converter */ - cd->c = -1; - return 0; - } - - inleft = inbytesleft ? *inbytesleft : 0; - inptr = inbytes ? *inbytes : NULL; - outleft = *outbytesleft; - outptr = *outbytes; - - if ((c = cd->c) != (gunichar) -1) - goto encode; - - while (inleft > 0) { - if ((rc = cd->decode (inptr, inleft, &c)) < 0) - break; - - inleft -= rc; - inptr += rc; - - encode: - if ((rc = cd->encode (c, outptr, outleft)) < 0) - break; - - c = (gunichar) -1; - outleft -= rc; - outptr += rc; - } - - if (inbytesleft) - *inbytesleft = inleft; - - if (inbytes) - *inbytes = inptr; - - *outbytesleft = outleft; - *outbytes = outptr; - cd->c = c; - - return rc < 0 ? -1 : 0; -} - /* * Unicode encoders and decoders */ @@ -605,123 +425,6 @@ g_convert_error_quark (void) { return error_quark; } - -gchar * -g_convert (const gchar *str, gssize len, const gchar *to_charset, const gchar *from_charset, - gsize *bytes_read, gsize *bytes_written, GError **err) -{ - gsize outsize, outused, outleft, inleft, grow, rc; - char *result, *outbuf, *inbuf; - gboolean flush = FALSE; - gboolean done = FALSE; - GIConv cd; - - g_return_val_if_fail (str != NULL, NULL); - g_return_val_if_fail (to_charset != NULL, NULL); - g_return_val_if_fail (from_charset != NULL, NULL); - - if ((cd = g_iconv_open (to_charset, from_charset)) == (GIConv) -1) { - g_set_error (err, G_CONVERT_ERROR, G_CONVERT_ERROR_NO_CONVERSION, - "Conversion from %s to %s not supported.", - from_charset, to_charset); - - if (bytes_written) - *bytes_written = 0; - - if (bytes_read) - *bytes_read = 0; - - return NULL; - } - - inleft = len < 0 ? strlen (str) : len; - inbuf = (char *) str; - - outleft = outsize = MAX (inleft, 8); - outbuf = result = g_malloc (outsize + 4); - - do { - if (!flush) - rc = g_iconv (cd, &inbuf, &inleft, &outbuf, &outleft); - else - rc = g_iconv (cd, NULL, NULL, &outbuf, &outleft); - - if (rc == (gsize) -1) { - switch (errno) { - case E2BIG: - /* grow our result buffer */ - grow = MAX (inleft, 8) << 1; - outused = outbuf - result; - outsize += grow; - outleft += grow; - result = g_realloc (result, outsize + 4); - outbuf = result + outused; - break; - case EINVAL: - /* incomplete input, stop converting and terminate here */ - if (flush) - done = TRUE; - else - flush = TRUE; - break; - case EILSEQ: - /* illegal sequence in the input */ - g_set_error (err, G_CONVERT_ERROR, G_CONVERT_ERROR_ILLEGAL_SEQUENCE, "%s", g_strerror (errno)); - - if (bytes_read) { - /* save offset of the illegal input sequence */ - *bytes_read = (inbuf - str); - } - - if (bytes_written) - *bytes_written = 0; - - g_iconv_close (cd); - g_free (result); - return NULL; - default: - /* unknown errno */ - g_set_error (err, G_CONVERT_ERROR, G_CONVERT_ERROR_FAILED, "%s", g_strerror (errno)); - - if (bytes_written) - *bytes_written = 0; - - if (bytes_read) - *bytes_read = 0; - - g_iconv_close (cd); - g_free (result); - return NULL; - } - } else if (flush) { - /* input has been converted and output has been flushed */ - break; - } else { - /* input has been converted, need to flush the output */ - flush = TRUE; - } - } while (!done); - - g_iconv_close (cd); - - /* Note: not all charsets can be null-terminated with a single - null byte. UCS2, for example, needs 2 null bytes and UCS4 - needs 4. I hope that 4 null bytes is enough to terminate all - multibyte charsets? */ - - /* null-terminate the result */ - memset (outbuf, 0, 4); - - if (bytes_written) - *bytes_written = outbuf - result; - - if (bytes_read) - *bytes_read = inbuf - str; - - return result; -} - - /* * Unicode conversion */ diff --git a/src/mono/mono/eglib/glib.h b/src/mono/mono/eglib/glib.h index 4c42ab3..baf9f5b 100644 --- a/src/mono/mono/eglib/glib.h +++ b/src/mono/mono/eglib/glib.h @@ -1172,19 +1172,6 @@ int g_mkdir_with_parents (const gchar *pathname, int mode); #define g_mkdir mkdir /* - * Character set conversion - */ -typedef struct _GIConv *GIConv; - -gsize g_iconv (GIConv cd, gchar **inbytes, gsize *inbytesleft, gchar **outbytes, gsize *outbytesleft); -GIConv g_iconv_open (const gchar *to_charset, const gchar *from_charset); -int g_iconv_close (GIConv cd); - -gchar *g_convert (const gchar *str, gssize len, - const gchar *to_codeset, const gchar *from_codeset, - gsize *bytes_read, gsize *bytes_written, GError **gerror); - -/* * Unicode manipulation */ extern const guchar g_utf8_jump_table[256]; diff --git a/src/mono/mono/eglib/test/utf8.c b/src/mono/mono/eglib/test/utf8.c index 132ca6d..d36dbfa 100644 --- a/src/mono/mono/eglib/test/utf8.c +++ b/src/mono/mono/eglib/test/utf8.c @@ -295,114 +295,6 @@ test_utf8_to_utf16_with_nuls (void) return OK; } -typedef struct { - char *content; - size_t length; -} convert_result_t; - -static RESULT -test_convert (void) -{ - static const char *charsets[] = { "UTF-8", "UTF-16LE", "UTF-16BE", "UTF-32LE", "UTF-32BE" }; - gsize length, converted_length, n; - char *content, *converted, *path; - convert_result_t **expected; - GError *err = NULL; - const char *srcdir; - gboolean loaded; - guint i, j, k; - char c; - - if (!(srcdir = getenv ("srcdir")) && !(srcdir = getenv ("PWD"))) - return FAILED ("srcdir not defined!"); - - expected = g_malloc (sizeof (convert_result_t *) * G_N_ELEMENTS (charsets)); - - /* first load all our test samples... */ - for (i = 0; i < G_N_ELEMENTS (charsets); i++) { - path = g_strdup_printf ("%s%c%s.txt", srcdir, G_DIR_SEPARATOR, charsets[i]); - loaded = g_file_get_contents (path, &content, &length, &err); - g_free (path); - - if (!loaded) { - for (j = 0; j < i; j++) { - g_free (expected[j]->content); - g_free (expected[j]); - } - - g_free (expected); - - return FAILED ("Failed to load content for %s: %s", charsets[i], err->message); - } - - expected[i] = g_malloc (sizeof (convert_result_t)); - expected[i]->content = content; - expected[i]->length = length; - } - - /* test conversion from every charset to every other charset */ - for (i = 0; i < G_N_ELEMENTS (charsets); i++) { - for (j = 0; j < G_N_ELEMENTS (charsets); j++) { - converted = g_convert (expected[i]->content, expected[i]->length, charsets[j], - charsets[i], NULL, &converted_length, NULL); - - if (converted == NULL) { - for (k = 0; k < G_N_ELEMENTS (charsets); k++) { - g_free (expected[k]->content); - g_free (expected[k]); - } - - g_free (expected); - - return FAILED ("Failed to convert from %s to %s: NULL", charsets[i], charsets[j]); - } - - if (converted_length != expected[j]->length) { - length = expected[j]->length; - - for (k = 0; k < G_N_ELEMENTS (charsets); k++) { - g_free (expected[k]->content); - g_free (expected[k]); - } - - g_free (converted); - g_free (expected); - - return FAILED ("Failed to convert from %s to %s: expected %u bytes, got %u", - charsets[i], charsets[j], length, converted_length); - } - - for (n = 0; n < converted_length; n++) { - if (converted[n] != expected[j]->content[n]) { - c = expected[j]->content[n]; - - for (k = 0; k < G_N_ELEMENTS (charsets); k++) { - g_free (expected[k]->content); - g_free (expected[k]); - } - - g_free (converted); - g_free (expected); - - return FAILED ("Failed to convert from %s to %s: expected 0x%x at offset %u, got 0x%x", - charsets[i], charsets[j], c, n, converted[n]); - } - } - - g_free (converted); - } - } - - for (k = 0; k < G_N_ELEMENTS (charsets); k++) { - g_free (expected[k]->content); - g_free (expected[k]); - } - - g_free (expected); - - return OK; -} - static RESULT ucs4_to_utf16_check_result (const gunichar2 *result_str, const gunichar2 *expected_str, glong result_items_read, glong expected_items_read, @@ -809,7 +701,6 @@ static Test utf8_tests [] = { {"g_utf8_to_utf16", test_utf8_to_utf16}, {"g_utf8_to_utf16_with_nuls", test_utf8_to_utf16_with_nuls}, {"g_utf8_seq", test_utf8_seq}, - {"g_convert", test_convert }, {"g_ucs4_to_utf16", test_ucs4_to_utf16 }, {"g_utf16_to_ucs4", test_utf16_to_ucs4 }, {"g_utf8_strlen", test_utf8_strlen }, diff --git a/src/mono/mono/eventpipe/test/CMakeLists.txt b/src/mono/mono/eventpipe/test/CMakeLists.txt index 65784b8..401da52 100644 --- a/src/mono/mono/eventpipe/test/CMakeLists.txt +++ b/src/mono/mono/eventpipe/test/CMakeLists.txt @@ -33,7 +33,7 @@ if(ENABLE_PERFTRACING) set(CMAKE_SKIP_RPATH 1) add_executable(ep-test ${EVENTPIPE_TEST_SOURCES} ${EVENTPIPE_TEST_HEADERS}) target_sources(ep-test PRIVATE "${mono-components-objects}") - target_link_libraries(ep-test monosgen-static ${OS_LIBS} ${ICONV_LIB} ${LLVM_LIBS} ${ICU_LIBS}) + target_link_libraries(ep-test monosgen-static ${OS_LIBS} ${LLVM_LIBS} ${ICU_LIBS}) if(ICU_LDFLAGS) set_target_properties(ep-test PROPERTIES LINK_FLAGS ${ICU_LDFLAGS}) endif() diff --git a/src/mono/mono/metadata/assembly.c b/src/mono/mono/metadata/assembly.c index 9d9bfa1..6c54753 100644 --- a/src/mono/mono/metadata/assembly.c +++ b/src/mono/mono/metadata/assembly.c @@ -3370,141 +3370,6 @@ mono_register_bundled_satellite_assemblies (const MonoBundledSatelliteAssembly * satellite_bundles = assemblies; } -#define MONO_DECLSEC_FORMAT_10 0x3C -#define MONO_DECLSEC_FORMAT_20 0x2E -#define MONO_DECLSEC_FIELD 0x53 -#define MONO_DECLSEC_PROPERTY 0x54 - -#define SKIP_VISIBILITY_XML_ATTRIBUTE ("\"SkipVerification\"") -#define SKIP_VISIBILITY_ATTRIBUTE_NAME ("System.Security.Permissions.SecurityPermissionAttribute") -#define SKIP_VISIBILITY_ATTRIBUTE_SIZE (sizeof (SKIP_VISIBILITY_ATTRIBUTE_NAME) - 1) -#define SKIP_VISIBILITY_PROPERTY_NAME ("SkipVerification") -#define SKIP_VISIBILITY_PROPERTY_SIZE (sizeof (SKIP_VISIBILITY_PROPERTY_NAME) - 1) - -static gboolean -mono_assembly_try_decode_skip_verification_param (const char *p, const char **resp, gboolean *abort_decoding) -{ - int len; - switch (*p++) { - case MONO_DECLSEC_PROPERTY: - break; - case MONO_DECLSEC_FIELD: - default: - *abort_decoding = TRUE; - return FALSE; - break; - } - - if (*p++ != MONO_TYPE_BOOLEAN) { - *abort_decoding = TRUE; - return FALSE; - } - - /* property name length */ - len = mono_metadata_decode_value (p, &p); - - if (len >= SKIP_VISIBILITY_PROPERTY_SIZE && !memcmp (p, SKIP_VISIBILITY_PROPERTY_NAME, SKIP_VISIBILITY_PROPERTY_SIZE)) { - p += len; - return *p; - } - p += len + 1; - - *resp = p; - return FALSE; -} - -static gboolean -mono_assembly_try_decode_skip_verification (const char *p, const char *endn) -{ - int i, j, num, len, params_len; - - if (*p == MONO_DECLSEC_FORMAT_10) { - gsize read, written; - char *res = g_convert (p, endn - p, "UTF-8", "UTF-16LE", &read, &written, NULL); - if (res) { - gboolean found = strstr (res, SKIP_VISIBILITY_XML_ATTRIBUTE) != NULL; - g_free (res); - return found; - } - return FALSE; - } - if (*p++ != MONO_DECLSEC_FORMAT_20) - return FALSE; - - /* number of encoded permission attributes */ - num = mono_metadata_decode_value (p, &p); - for (i = 0; i < num; ++i) { - gboolean is_valid = FALSE; - gboolean abort_decoding = FALSE; - - /* attribute name length */ - len = mono_metadata_decode_value (p, &p); - - /* We don't really need to fully decode the type. Comparing the name is enough */ - is_valid = len >= SKIP_VISIBILITY_ATTRIBUTE_SIZE && !memcmp (p, SKIP_VISIBILITY_ATTRIBUTE_NAME, SKIP_VISIBILITY_ATTRIBUTE_SIZE); - - p += len; - - /*size of the params table*/ - params_len = mono_metadata_decode_value (p, &p); - if (is_valid) { - const char *params_end = p + params_len; - - /* number of parameters */ - len = mono_metadata_decode_value (p, &p); - - for (j = 0; j < len; ++j) { - if (mono_assembly_try_decode_skip_verification_param (p, &p, &abort_decoding)) - return TRUE; - if (abort_decoding) - break; - } - p = params_end; - } else { - p += params_len; - } - } - - return FALSE; -} - - -gboolean -mono_assembly_has_skip_verification (MonoAssembly *assembly) -{ - MonoTableInfo *t; - guint32 cols [MONO_DECL_SECURITY_SIZE]; - const char *blob; - int i, len; - - if (MONO_SECMAN_FLAG_INIT (assembly->skipverification)) - return MONO_SECMAN_FLAG_GET_VALUE (assembly->skipverification); - - t = &assembly->image->tables [MONO_TABLE_DECLSECURITY]; - - int rows = table_info_get_rows (t); - for (i = 0; i < rows; ++i) { - mono_metadata_decode_row (t, i, cols, MONO_DECL_SECURITY_SIZE); - if ((cols [MONO_DECL_SECURITY_PARENT] & MONO_HAS_DECL_SECURITY_MASK) != MONO_HAS_DECL_SECURITY_ASSEMBLY) - continue; - if (cols [MONO_DECL_SECURITY_ACTION] != SECURITY_ACTION_REQMIN) - continue; - - blob = mono_metadata_blob_heap (assembly->image, cols [MONO_DECL_SECURITY_PERMISSIONSET]); - len = mono_metadata_decode_blob_size (blob, &blob); - if (!len) - continue; - - if (mono_assembly_try_decode_skip_verification (blob, blob + len)) { - MONO_SECMAN_FLAG_SET_VALUE (assembly->skipverification, TRUE); - return TRUE; - } - } - - MONO_SECMAN_FLAG_SET_VALUE (assembly->skipverification, FALSE); - return FALSE; -} - /** * mono_assembly_is_jit_optimizer_disabled: * diff --git a/src/mono/mono/metadata/metadata-internals.h b/src/mono/mono/metadata/metadata-internals.h index ed4627d..c3d8ae3 100644 --- a/src/mono/mono/metadata/metadata-internals.h +++ b/src/mono/mono/metadata/metadata-internals.h @@ -146,10 +146,6 @@ mono_sizeof_aggregate_modifiers (uint8_t num_mods); MonoAggregateModContainer * mono_metadata_get_canonical_aggregate_modifiers (MonoAggregateModContainer *candidate); -#define MONO_SECMAN_FLAG_INIT(x) (x & 0x2) -#define MONO_SECMAN_FLAG_GET_VALUE(x) (x & 0x1) -#define MONO_SECMAN_FLAG_SET_VALUE(x,y) do { x = ((y) ? 0x3 : 0x2); } while (0) - #define MONO_PUBLIC_KEY_TOKEN_LENGTH 17 #define MONO_PROCESSOR_ARCHITECTURE_NONE 0 @@ -215,8 +211,6 @@ struct _MonoAssembly { guint8 jit_optimizer_disabled_inited; guint8 runtime_marshalling_enabled; guint8 runtime_marshalling_enabled_inited; - /* security manager flags (one bit is for lazy initialization) */ - guint32 skipverification:2; /* Has SecurityPermissionFlag.SkipVerification permission */ }; typedef struct { @@ -946,7 +940,6 @@ mono_metadata_generic_param_equal (MonoGenericParam *p1, MonoGenericParam *p2); void mono_dynamic_stream_reset (MonoDynamicStream* stream); void mono_assembly_load_friends (MonoAssembly* ass); -gboolean mono_assembly_has_skip_verification (MonoAssembly* ass); MONO_API gint32 mono_assembly_addref (MonoAssembly *assembly); diff --git a/src/mono/mono/mini/CMakeLists.txt b/src/mono/mono/mini/CMakeLists.txt index 73711c8..a4dfad3 100644 --- a/src/mono/mono/mini/CMakeLists.txt +++ b/src/mono/mono/mini/CMakeLists.txt @@ -338,7 +338,7 @@ if(NOT DISABLE_SHARED_LIBS) # to avoid a conflict we rename the import library with the .import.lib suffix set_target_properties(monosgen-shared PROPERTIES IMPORT_SUFFIX ".import.lib") endif() - target_link_libraries(monosgen-shared PRIVATE ${OS_LIBS} ${ICONV_LIB} ${LLVM_LIBS} ${ICU_LIBS} ${Z_LIBS}) + target_link_libraries(monosgen-shared PRIVATE ${OS_LIBS} ${LLVM_LIBS} ${ICU_LIBS} ${Z_LIBS}) if(ICU_LDFLAGS) set_property(TARGET monosgen-shared APPEND_STRING PROPERTY LINK_FLAGS " ${ICU_LDFLAGS}") endif() @@ -389,7 +389,7 @@ if(NOT DISABLE_SHARED_LIBS) add_library(${frameworkconfig} SHARED $) target_compile_definitions(${frameworkconfig} PRIVATE -DMONO_DLL_EXPORT) target_sources(${frameworkconfig} PRIVATE $) - target_link_libraries(${frameworkconfig} PRIVATE ${OS_LIBS} ${ICONV_LIB} ${LLVM_LIBS} ${ICU_LIBS} ${Z_LIBS}) + target_link_libraries(${frameworkconfig} PRIVATE ${OS_LIBS} ${LLVM_LIBS} ${ICU_LIBS} ${Z_LIBS}) if(ICU_LDFLAGS) set_property(TARGET ${frameworkconfig} APPEND_STRING PROPERTY LINK_FLAGS " ${ICU_LDFLAGS}") endif() @@ -463,7 +463,7 @@ if(NOT DISABLE_EXECUTABLES) if(MONO_CROSS_COMPILE_EXECUTABLE_NAME) set_target_properties(mono-sgen PROPERTIES OUTPUT_NAME mono-aot-cross) endif() - target_link_libraries(mono-sgen PRIVATE monoapi monosgen-static ${OS_LIBS} ${ICONV_LIB} ${LLVM_LIBS} ${ICU_LIBS} ${Z_LIBS}) + target_link_libraries(mono-sgen PRIVATE monoapi monosgen-static ${OS_LIBS} ${LLVM_LIBS} ${ICU_LIBS} ${Z_LIBS}) if(NOT DISABLE_COMPONENTS AND STATIC_COMPONENTS AND NOT DISABLE_LINK_STATIC_COMPONENTS) # if components are built statically, link them into runtime. target_sources(mono-sgen PRIVATE "${mono-components-objects}") diff --git a/src/mono/mono/mini/method-to-ir.c b/src/mono/mono/mini/method-to-ir.c index e56b2d3..0dda7e4 100644 --- a/src/mono/mono/mini/method-to-ir.c +++ b/src/mono/mono/mini/method-to-ir.c @@ -6278,12 +6278,6 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b method_definition = imethod->declaring; } - /* SkipVerification is not allowed if core-clr is enabled */ - if (!dont_verify && mini_assembly_can_skip_verification (method)) { - dont_verify = TRUE; - dont_verify_stloc = TRUE; - } - if (sig->is_inflated) generic_context = mono_method_get_context (method); else if (generic_container) diff --git a/src/mono/mono/mini/mini.c b/src/mono/mono/mini/mini.c index 9b90212..16d9103 100644 --- a/src/mono/mono/mini/mini.c +++ b/src/mono/mono/mini/mini.c @@ -941,17 +941,6 @@ mono_create_jump_table (MonoCompile *cfg, MonoInst *label, MonoBasicBlock **bbs, cfg->patch_info = ji; } -gboolean -mini_assembly_can_skip_verification (MonoMethod *method) -{ - MonoAssembly *assembly = m_class_get_image (method->klass)->assembly; - if (method->wrapper_type != MONO_WRAPPER_NONE && method->wrapper_type != MONO_WRAPPER_DYNAMIC_METHOD) - return FALSE; - if (assembly->image == mono_defaults.corlib) - return FALSE; - return mono_assembly_has_skip_verification (assembly); -} - typedef struct { MonoClass *vtype; GList *active, *inactive; diff --git a/src/mono/mono/mini/mini.h b/src/mono/mono/mini/mini.h index f950d6b..1e4b66d 100644 --- a/src/mono/mono/mini/mini.h +++ b/src/mono/mono/mini/mini.h @@ -2198,7 +2198,6 @@ void mono_empty_compile (MonoCompile *cfg); MonoJitICallInfo *mono_find_jit_opcode_emulation (int opcode); void mono_print_ins_index (int i, MonoInst *ins); void mono_print_ins (MonoInst *ins); -gboolean mini_assembly_can_skip_verification (MonoMethod *method); MonoInst *mono_get_got_var (MonoCompile *cfg); void mono_add_seq_point (MonoCompile *cfg, MonoBasicBlock *bb, MonoInst *ins, int native_offset); void mono_add_var_location (MonoCompile *cfg, MonoInst *var, gboolean is_reg, int reg, int offset, int from, int to); -- 2.7.4