Make constants public as well.

This commit is contained in:
Andy Nguyen 2021-10-25 09:36:45 +02:00
parent 6be7872c8b
commit fd9d1ce342
2 changed files with 16 additions and 15 deletions

View File

@ -14,16 +14,16 @@ import java.lang.reflect.Method;
/** API class to access native data and execute native code. */ /** API class to access native data and execute native code. */
public final class API { public final class API {
static final int INT8_SIZE = 1; public static final int INT8_SIZE = 1;
static final int INT16_SIZE = 2; public static final int INT16_SIZE = 2;
static final int INT32_SIZE = 4; public static final int INT32_SIZE = 4;
static final int INT64_SIZE = 8; public static final int INT64_SIZE = 8;
static final long RTLD_DEFAULT = -2; public static final long RTLD_DEFAULT = -2;
static final long LIBC_MODULE_HANDLE = 0x2; public static final long LIBC_MODULE_HANDLE = 0x2;
static final long LIBKERNEL_MODULE_HANDLE = 0x2001; public static final long LIBKERNEL_MODULE_HANDLE = 0x2001;
static final long LIBJAVA_MODULE_HANDLE = 0x4A; public static final long LIBJAVA_MODULE_HANDLE = 0x4A;
private static final String UNSUPPORTED_DLOPEN_OPERATION_STRING = private static final String UNSUPPORTED_DLOPEN_OPERATION_STRING =
"Unsupported dlopen() operation"; "Unsupported dlopen() operation";

View File

@ -14,11 +14,10 @@ import java.io.RandomAccessFile;
* executable memory. * executable memory.
*/ */
public final class JIT { public final class JIT {
static final int BDJ_MODULE_HANDLE = 0; // We actually have 32MB of code memory, but reserve 8MB for Java JIT.
public static final int MAX_CODE_SIZE = 24 * 1024 * 1024;
static final int MAX_JIT_SIZE = 24 * 1024 * 1024; // Actually max is 30MB, but let's be safe. public static final int PAGE_SIZE = 0x4000;
static final int PAGE_SIZE = 0x4000; public static final int ALIGNMENT = 0x100000;
static final int ALIGNMENT = 0x100000;
private static final int CHUNK_SIZE = 0x30; private static final int CHUNK_SIZE = 0x30;
@ -40,6 +39,8 @@ public final class JIT {
private static final String WRITE_SYMBOL = "write"; private static final String WRITE_SYMBOL = "write";
private static final String READ_SYMBOL = "read"; private static final String READ_SYMBOL = "read";
private static final int BDJ_MODULE_HANDLE = 0;
private static JIT instance; private static JIT instance;
private final API api; private final API api;
@ -116,9 +117,9 @@ public final class JIT {
RandomAccessFile file = new RandomAccessFile(path, "r"); RandomAccessFile file = new RandomAccessFile(path, "r");
// TODO: Currently we just use maximum size so that the address is predictable. // TODO: Currently we just use maximum size so that the address is predictable.
long size = MAX_JIT_SIZE; long size = MAX_CODE_SIZE;
// long size = file.length() + 0x88 + ALIGNMENT - 1; // long size = file.length() + 0x88 + ALIGNMENT - 1;
// if (size >= MAX_JIT_SIZE) { // if (size >= MAX_CODE_SIZE) {
// throw new IllegalArgumentException("Payload is too big."); // throw new IllegalArgumentException("Payload is too big.");
// } // }