Merge pull request #5397 from kumpera/fix_41279
authorRodrigo Kumpera <kumpera@users.noreply.github.com>
Fri, 18 Aug 2017 20:04:08 +0000 (13:04 -0700)
committerGitHub <noreply@github.com>
Fri, 18 Aug 2017 20:04:08 +0000 (13:04 -0700)
[runtime] Format MethodAccessException method names to use the same formating as reflection. Fixes #41279

mcs/class/corlib/Test/System.Reflection/AssemblyNameTest.cs
mono/metadata/assembly.c
mono/metadata/threads.c
mono/mini/tramp-amd64.c

index b707567f1de9e8bae42dce2492e7df4b572f5908..ceac114da7162b26a38bebe2d929b454118bee24 100644 (file)
@@ -1862,6 +1862,26 @@ public class AssemblyNameTest {
 
                Assert.AreEqual ("", an.CultureName);
        }
+
+       [Test]
+       public void TestDecodingEcmaKey ()
+       {
+        var x = new AssemblyName( "System, PublicKey=00000000000000000400000000000000" );
+               Assert.IsNull (x.GetPublicKey (), "#1");
+               Assert.IsNotNull (x.GetPublicKeyToken (), "#2");
+
+               var t = x.GetPublicKeyToken ();
+               Assert.AreEqual (8, t.Length, "#3");
+
+               Assert.AreEqual (0xB7, t [0], "#4.0");
+               Assert.AreEqual (0x7A, t [1], "#4.1");
+               Assert.AreEqual (0x5C, t [2], "#4.2");
+               Assert.AreEqual (0x56, t [3], "#4.3");
+               Assert.AreEqual (0x19, t [4], "#4.4");
+               Assert.AreEqual (0x34, t [5], "#4.5");
+               Assert.AreEqual (0xE0, t [6], "#4.6");
+               Assert.AreEqual (0x89, t [7], "#4.7");
+       }
 }
 
 }
index adfab7def01de117ed63223b45e6b43fd32debd7..684a401c95919b0ccce2a70159eb022884260ffb 100644 (file)
@@ -2372,17 +2372,18 @@ parse_public_key (const gchar *key, gchar** pubkey, gboolean *is_ecma)
        const gchar *pkey;
        gchar header [16], val, *arr, *endp;
        gint i, j, offset, bitlen, keylen, pkeylen;
-       
+
+       //both pubkey and is_ecma are required arguments
+       g_assert (pubkey && is_ecma);
+
        keylen = strlen (key) >> 1;
        if (keylen < 1)
                return FALSE;
 
        /* allow the ECMA standard key */
        if (strcmp (key, "00000000000000000400000000000000") == 0) {
-               if (pubkey) {
-                       *pubkey = g_strdup (key);
-                       *is_ecma = TRUE;
-               }
+               *pubkey = NULL;
+               *is_ecma = TRUE;
                return TRUE;
        }
        *is_ecma = FALSE;
@@ -2427,10 +2428,6 @@ parse_public_key (const gchar *key, gchar** pubkey, gboolean *is_ecma)
        bitlen = read32 (header + 12) >> 3;
        if ((bitlen + 16 + 4) != pkeylen)
                return FALSE;
-
-       /* parsing is OK and the public key itself is not requested back */
-       if (!pubkey)
-               return TRUE;
                
        arr = (gchar *)g_malloc (keylen + 4);
        /* Encode the size of the blob */
@@ -2453,7 +2450,7 @@ build_assembly_name (const char *name, const char *version, const char *culture,
        gint major, minor, build, revision;
        gint len;
        gint version_parts;
-       gchar *pkey, *pkeyptr, *encoded, tok [8];
+       gchar *pkeyptr, *encoded, tok [8];
 
        memset (aname, 0, sizeof (MonoAssemblyName));
 
@@ -2502,17 +2499,16 @@ build_assembly_name (const char *name, const char *version, const char *culture,
        }
 
        if (key) {
-               gboolean is_ecma;
+               gboolean is_ecma = FALSE;
+               gchar *pkey = NULL;
                if (strcmp (key, "null") == 0 || !parse_public_key (key, &pkey, &is_ecma)) {
                        mono_assembly_name_free (aname);
                        return FALSE;
                }
 
                if (is_ecma) {
-                       if (save_public_key)
-                               aname->public_key = (guint8*)pkey;
-                       else
-                               g_free (pkey);
+                       g_assert (pkey == NULL);
+                       aname->public_key = NULL;
                        g_strlcpy ((gchar*)aname->public_key_token, "b77a5c561934e089", MONO_PUBLIC_KEY_TOKEN_LENGTH);
                        return TRUE;
                }
index 120bd1a9458f7e94c26dedf9f03e4dd2b24a9ddf..8eb4fe5f24e474e619a68bb2e17a00cb1f52f043 100644 (file)
@@ -462,8 +462,8 @@ typedef union {
 #define SPECIAL_STATIC_OFFSET_TYPE_THREAD 0
 #define SPECIAL_STATIC_OFFSET_TYPE_CONTEXT 1
 
-#define MAKE_SPECIAL_STATIC_OFFSET(index, offset, type) \
-       ((SpecialStaticOffset) { .fields = { (index), (offset), (type) } }.raw)
+#define MAKE_SPECIAL_STATIC_OFFSET(idx, off, ty) \
+       ((SpecialStaticOffset) { .fields = { .index = (idx), .offset = (off), .type = (ty) } }.raw)
 #define ACCESS_SPECIAL_STATIC_OFFSET(x,f) \
        (((SpecialStaticOffset *) &(x))->fields.f)
 
index 53e3bc2e834c53dd39f310e66e6f4da222d49f72..ea912ba6ce94a94a9c7e0735b15c05a0c24fa550 100644 (file)
@@ -705,8 +705,10 @@ mono_arch_create_rgctx_lazy_fetch_trampoline (guint32 slot, MonoTrampInfo **info
 
        g_free (rgctx_null_jumps);
 
-       /* move the rgctx pointer to the VTABLE register */
-       amd64_mov_reg_reg (code, MONO_ARCH_VTABLE_REG, AMD64_ARG_REG1, sizeof(gpointer));
+       if (MONO_ARCH_VTABLE_REG != AMD64_ARG_REG1) {
+               /* move the rgctx pointer to the VTABLE register */
+               amd64_mov_reg_reg (code, MONO_ARCH_VTABLE_REG, AMD64_ARG_REG1, sizeof(gpointer));
+       }
 
        if (aot) {
                code = mono_arch_emit_load_aotconst (buf, code, &ji, MONO_PATCH_INFO_JIT_ICALL_ADDR, g_strdup_printf ("specific_trampoline_lazy_fetch_%u", slot));