ART: Fix run-test inline assembly
Use assembly that both Clang and GCC support. Use a minimal 2-byte
encoding.
Bug: 22876261
Change-Id: I11724b3cf09869fa341907dcb9acc1bee919e3c8
diff --git a/test/004-SignalTest/signaltest.cc b/test/004-SignalTest/signaltest.cc
index 34e331b..6dd6355 100644
--- a/test/004-SignalTest/signaltest.cc
+++ b/test/004-SignalTest/signaltest.cc
@@ -62,9 +62,12 @@
struct ucontext *uc = reinterpret_cast<struct ucontext*>(context);
struct sigcontext *sc = reinterpret_cast<struct sigcontext*>(&uc->uc_mcontext);
sc->pc += 4; // Skip instruction causing segv.
-#elif defined(__i386__) || defined(__x86_64__)
+#elif defined(__i386__)
struct ucontext *uc = reinterpret_cast<struct ucontext*>(context);
uc->CTX_EIP += 3;
+#elif defined(__x86_64__)
+ struct ucontext *uc = reinterpret_cast<struct ucontext*>(context);
+ uc->CTX_EIP += 2;
#else
UNUSED(context);
#endif
@@ -97,9 +100,9 @@
// On supported architectures we cause a real SEGV.
*go_away_compiler = 'a';
#elif defined(__x86_64__)
- // Cause a SEGV using an instruction known to be 3 bytes long to account for hardcoded jump
+ // Cause a SEGV using an instruction known to be 2 bytes long to account for hardcoded jump
// in the signal handler
- asm volatile("movl $0, %%eax;" "movb $1, (%%al);" : : : "%eax");
+ asm volatile("movl $0, %%eax;" "movb %%ah, (%%rax);" : : : "%eax");
#else
// On other architectures we simulate SEGV.
kill(getpid(), SIGSEGV);
diff --git a/test/115-native-bridge/nativebridge.cc b/test/115-native-bridge/nativebridge.cc
index 702e779..948273a 100644
--- a/test/115-native-bridge/nativebridge.cc
+++ b/test/115-native-bridge/nativebridge.cc
@@ -206,9 +206,9 @@
#if defined(__arm__) || defined(__i386__) || defined(__aarch64__)
*go_away_compiler = 'a';
#elif defined(__x86_64__)
- // Cause a SEGV using an instruction known to be 3 bytes long to account for hardcoded jump
+ // Cause a SEGV using an instruction known to be 2 bytes long to account for hardcoded jump
// in the signal handler
- asm volatile("movl $0, %%eax;" "movb $1, (%%al);" : : : "%eax");
+ asm volatile("movl $0, %%eax;" "movb %%ah, (%%rax);" : : : "%eax");
#else
// On other architectures we simulate SEGV.
kill(getpid(), SIGSEGV);
@@ -403,9 +403,12 @@
struct ucontext *uc = reinterpret_cast<struct ucontext*>(context);
struct sigcontext *sc = reinterpret_cast<struct sigcontext*>(&uc->uc_mcontext);
sc->pc += 4; // Skip instruction causing segv & sigill.
-#elif defined(__i386__) || defined(__x86_64__)
+#elif defined(__i386__)
struct ucontext *uc = reinterpret_cast<struct ucontext*>(context);
uc->CTX_EIP += 3;
+#elif defined(__x86_64__)
+ struct ucontext *uc = reinterpret_cast<struct ucontext*>(context);
+ uc->CTX_EIP += 2;
#else
UNUSED(context);
#endif