| Index: base/android/linker/linker_jni.cc
|
| diff --git a/base/android/linker/linker_jni.cc b/base/android/linker/linker_jni.cc
|
| index be4a5ed30df2c3b6ca99830020bb11835153200b..bf74fc36cf64d1da02b221ca92942ed24c414f79 100644
|
| --- a/base/android/linker/linker_jni.cc
|
| +++ b/base/android/linker/linker_jni.cc
|
| @@ -17,6 +17,7 @@
|
| #include <crazy_linker.h>
|
| #include <jni.h>
|
| #include <stdlib.h>
|
| +#include <sys/mman.h>
|
| #include <unistd.h>
|
|
|
| // Set this to 1 to enable debug traces to the Android log.
|
| @@ -566,6 +567,18 @@ jlong GetPageSize(JNIEnv* env, jclass clazz) {
|
| return result;
|
| }
|
|
|
| +jlong GetRandomBaseLoadAddress(JNIEnv* env, jclass clazz, jlong bytes) {
|
| + void* address =
|
| + mmap(NULL, bytes, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
|
| + if (address == MAP_FAILED) {
|
| + LOG_INFO("%s: Random base load address not determinable\n", __FUNCTION__);
|
| + return 0;
|
| + }
|
| + munmap(address, bytes);
|
| + LOG_INFO("%s: Random base load address is %p\n", __FUNCTION__, address);
|
| + return static_cast<jlong>(reinterpret_cast<intptr_t>(address));
|
| +}
|
| +
|
| const JNINativeMethod kNativeMethods[] = {
|
| {"nativeLoadLibrary",
|
| "("
|
| @@ -614,7 +627,13 @@ const JNINativeMethod kNativeMethods[] = {
|
| "("
|
| ")"
|
| "J",
|
| - reinterpret_cast<void*>(&GetPageSize)}, };
|
| + reinterpret_cast<void*>(&GetPageSize)},
|
| + {"nativeGetRandomBaseLoadAddress",
|
| + "("
|
| + "J"
|
| + ")"
|
| + "J",
|
| + reinterpret_cast<void*>(&GetRandomBaseLoadAddress)}, };
|
|
|
| } // namespace
|
|
|
|
|