Previously if the image chose a relocation delta of 0 this test would
fail. Now we check for this state directly.
Bug:
24192015
Change-Id: Ie818701edc5605fed590547f0e8b1e97d1d994e3
#include "class_linker.h"
#include "dex_file-inl.h"
+#include "gc/heap.h"
+#include "gc/space/image_space.h"
#include "mirror/class-inl.h"
+#include "runtime.h"
#include "scoped_thread_state_change.h"
#include "thread.h"
return dex_file.GetOatDexFile();
}
+ static bool isRelocationDeltaZero() {
+ gc::space::ImageSpace* space = Runtime::Current()->GetHeap()->GetImageSpace();
+ return space != nullptr && space->GetImageHeader().GetPatchDelta() == 0;
+ }
+
static bool hasExecutableOat(jclass cls) {
const OatFile::OatDexFile* oat_dex_file = getOatDexFile(cls);
}
};
+extern "C" JNIEXPORT jboolean JNICALL Java_Main_isRelocationDeltaZero(JNIEnv*, jclass) {
+ return NoPatchoatTest::isRelocationDeltaZero();
+}
+
extern "C" JNIEXPORT jboolean JNICALL Java_Main_hasExecutableOat(JNIEnv*, jclass cls) {
return NoPatchoatTest::hasExecutableOat(cls);
}
# Make sure we can run without relocation
echo "Run without dex2oat/patchoat"
-# /bin/false is actually not even there for either, so the exec will fail.
-# Unfortunately there is no equivalent to /bin/false in android.
${RUN} ${flags} --runtime-option -Xnodex2oat
# Make sure we can run with the oat file.
public static void main(String[] args) {
System.loadLibrary(args[0]);
+ // With a relocationDelta of 0, the runtime has no way to determine if the oat file in
+ // ANDROID_DATA has been relocated, since a non-relocated oat file always has a 0 delta.
+ // Hitting this condition should be rare and ideally we would prevent it from happening but
+ // there is no way to do so without major changes to the run-test framework.
boolean executable_correct = (isPic() ?
- hasExecutableOat() == true :
- hasExecutableOat() == isDex2OatEnabled());
+ hasExecutableOat() == true :
+ hasExecutableOat() == (isDex2OatEnabled() || isRelocationDeltaZero()));
System.out.println(
"dex2oat & patchoat are " + ((isDex2OatEnabled()) ? "enabled" : "disabled") +
private native static boolean hasOat();
private native static boolean hasExecutableOat();
+
+ private native static boolean isRelocationDeltaZero();
}