Correct for signal, native bridge test hard-coded signal handling values
Added inline assembly to ensure that the instruction causing a segfault
in x86/x86_64 for the 004-SignalTest and 115-native-bridge test always
has a size of 3 bytes, in response to a bug that caused the test to fail
when this instruction had variable sizes.
Bug: 22876261
Change-Id: I474a04782a446439956c22360c71cea2655f8a1b
diff --git a/test/004-SignalTest/signaltest.cc b/test/004-SignalTest/signaltest.cc
index 1414715..34e331b 100644
--- a/test/004-SignalTest/signaltest.cc
+++ b/test/004-SignalTest/signaltest.cc
@@ -93,13 +93,16 @@
char *go_away_compiler = nullptr;
extern "C" JNIEXPORT jint JNICALL Java_Main_testSignal(JNIEnv*, jclass) {
-#if defined(__arm__) || defined(__i386__) || defined(__x86_64__) || defined(__aarch64__)
+#if defined(__arm__) || defined(__i386__) || defined(__aarch64__)
// 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
+ // in the signal handler
+ asm volatile("movl $0, %%eax;" "movb $1, (%%al);" : : : "%eax");
#else
// On other architectures we simulate SEGV.
kill(getpid(), SIGSEGV);
#endif
return 1234;
}
-
diff --git a/test/115-native-bridge/nativebridge.cc b/test/115-native-bridge/nativebridge.cc
index 04326b3..702e779 100644
--- a/test/115-native-bridge/nativebridge.cc
+++ b/test/115-native-bridge/nativebridge.cc
@@ -206,8 +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
- asm volatile("movl $0, %%eax;" "movb $1, (%%eax);" : : : "%eax");
+ // Cause a SEGV using an instruction known to be 3 bytes long to account for hardcoded jump
+ // in the signal handler
+ asm volatile("movl $0, %%eax;" "movb $1, (%%al);" : : : "%eax");
#else
// On other architectures we simulate SEGV.
kill(getpid(), SIGSEGV);