[android] remove text relocations in AOT/arm32 (mono/mono#16432)
authorBernhard Urban <lewurm@gmail.com>
Mon, 26 Aug 2019 07:46:12 +0000 (09:46 +0200)
committermonojenkins <jo.shields+jenkins@xamarin.com>
Mon, 26 Aug 2019 07:46:12 +0000 (03:46 -0400)
[android] remove text relocations in AOT/arm32

Remove support for "big assemblies" for AOT on Android running on ARM 32bit. This will remove relocations in `.text` which are not allowed in the upcoming Android Q release anymore.

_If_ a customer should run into this problem, the suggested workarounds are:
* Switch to ARM64, or
* Do not use AOT compilation.

Fixes https://github.com/mono/mono/issues/16369

Commit migrated from https://github.com/mono/mono/commit/b6ca76c48415393f09f09977327c0bcd99f10bf4

src/mono/mono/mini/aot-compiler.c
src/mono/mono/mini/aot-runtime.c

index ef43d80..88837e0 100644 (file)
@@ -1589,21 +1589,6 @@ arch_emit_direct_call (MonoAotCompile *acfg, const char *target, gboolean extern
        g_assert_not_reached ();
 #endif
 }
-
-static void
-arch_emit_label_address (MonoAotCompile *acfg, const char *target, gboolean external_call, gboolean thumb, MonoJumpInfo *ji, int *call_size)
-{
-#if defined(TARGET_ARM) && defined(TARGET_ANDROID)
-       /* binutils ld does not support branch islands on arm32 */
-       if (!thumb) {
-               emit_unset_mode (acfg);
-               fprintf (acfg->fp, "ldr pc,=%s\n", target);
-               fprintf (acfg->fp, ".ltorg\n");
-               *call_size = 8;
-       } else
-#endif
-       arch_emit_direct_call (acfg, target, external_call, thumb, ji, call_size);
-}
 #endif
 
 /*
@@ -9924,9 +9909,9 @@ emit_code (MonoAotCompile *acfg)
                int call_size;
 
                if (!ignore_cfg (acfg->cfgs [i])) {
-                       arch_emit_label_address (acfg, acfg->cfgs [i]->asm_symbol, FALSE, acfg->thumb_mixed && acfg->cfgs [i]->compile_llvm, NULL, &call_size);
+                       arch_emit_direct_call (acfg, acfg->cfgs [i]->asm_symbol, FALSE, acfg->thumb_mixed && acfg->cfgs [i]->compile_llvm, NULL, &call_size);
                } else {
-                       arch_emit_label_address (acfg, symbol, FALSE, FALSE, NULL, &call_size);
+                       arch_emit_direct_call (acfg, symbol, FALSE, FALSE, NULL, &call_size);
                }
 #endif
        }
index 86b5e6f..84e0506 100644 (file)
@@ -1940,11 +1940,6 @@ get_call_table_entry (void *table, int index)
        guint32 ins;
        gint32 offset;
 
-       ins_addr = (guint32 *)table + (index * 2);
-       if ((guint32) *ins_addr == (guint32 ) 0xe51ff004) { // ldr pc, =<label>
-               return *((char **) (ins_addr + 1));
-       }
-
        ins_addr = (guint32*)table + index;
        ins = *ins_addr;
        if ((ins >> ARMCOND_SHIFT) == ARMCOND_NV) {
@@ -1952,8 +1947,6 @@ get_call_table_entry (void *table, int index)
                offset = (((int)(((ins & 0xffffff) << 1) | ((ins >> 24) & 0x1))) << 7) >> 7;
                return (char*)ins_addr + (offset * 2) + 8 + 1;
        } else {
-               g_assert ((ins >> ARMCOND_SHIFT) == ARMCOND_AL);
-               /* bl */
                offset = (((int)ins & 0xffffff) << 8) >> 8;
                return (char*)ins_addr + (offset * 4) + 8;
        }