Commit Graph

19 Commits

Author SHA1 Message Date
mio 67f08b1c27
Bump version and generate bindings 2024-09-21 23:00:57 +08:00
Robert Xiao f55e7834ba Replace javah by javac -h, only write new constant files if something changes.
The const_generator changes help to ensure that e.g. Java rebuilds don't keep
rebuilding everything.
2023-07-06 20:12:36 -07:00
Robert Xiao dfdc8e7e8e Switch to Maven to build the Java bits.
Maven is now used to update the constants, build the Java code, call make to
build the native library, and run all the tests. I have removed the "install"
and "uninstall" targets; instead, the expectation will be that the JNI library
will be placed somewhere on java.library.path and the JAR file will be used as
usual (e.g. in a downstream Maven project, or placed on the classpath of your
project).

Since Maven is now running our tests, this eliminates the need to bundle test
dependencies in `testdep`, and makes the project structured more like a typical
Java project.
2023-06-29 16:08:18 -07:00
Robert Xiao 3fab8abca7 Restore some of the less problematic old APIs for backwards compatibility. 2023-06-17 14:19:10 -07:00
Robert Xiao aa430587cc Rewrite the Java bindings.
This brings the Java API up to par with Python feature-wise and substantially
simplifies the hook implementation, enabling proper bounds-checked hooks.

The rewrite strives for compatibility with the previous API, but there are some
breaking changes. It is possible to push closer to full backwards compatibility
if required, at the cost of reintroducing some of the suboptimal designs. Here
are the main points of breakage:

- ReadHook and WriteHook are gone, replaced simply by MemHook. Hooking valid
  memory accesses now requires a type parameter. This enables fetch and
  read-after hooks with a unified API and a single callback object.
- mem_read now takes an int, not a long. We are unable to allocate more than 2GB
  in a single request anyway (Java limitation).
- Instruction hooks now require specifying the instruction explicitly, instead
  of guessing based on the hook type. This is necessary to distinguish
  sysenter/syscall and ARM64 mrs/msr/sys/sysl, without excessively bloating the
  library with redundant hook types. Bounds must also be specified, to support
  bounds-checked instruction hooks.
- Reading object-type registers (any register larger than 64 bits, or registers
  with special formats) requires a second argument to reg_read. This allows us
  to provide a fast reg_read that returns a long for the common cases, while
  still supporting a more general reg_read for other registers.
- mem_map_ptr is rewritten to take a *direct* java.nio.Buffer, which enables
  many more use cases than a simple byte array, and improves performance (a
  byte array cannot really be used as a mapped buffer without GC-pinning it,
  which hurts the GC performance).
- Context handling API is redesigned to be safer and more object-oriented.

A lot of bugs are fixed with this implementation:
- Unicorn instances can be properly garbage-collected, instead of hanging around
  forever in the Unicorn.unicorns table.
- Hooks no longer fire outside of their bounds (#1164), and in fact, hook bounds
  are properly respected (previously, all hooks were just registered globally to
  all addresses).
- Hooks are substantially faster, as they are now dispatched directly via a
  single method call rather than being indirected through invokeCallbacks.
- Loading vector registers works now, rather than crashing the VM (#1539).

Several features are now enabled in the Java implementation:

- All of the current ctl_* calls are implemented.
- mmio_map is implemented.
- New virtual TLB mode is implemented.
- reading/writing Context registers is implemented.
- New hook types are added: TcgOpcodeHook, EdgeGeneratedHook,
  InvalidInstructionHook, TlbFillHook, and the instruction hooks Arm64SysHook,
  CpuidHook.
- All known special registers are supported.
2023-06-17 14:19:10 -07:00
Robert Xiao 66c8965f96 Set up testing infrastructure ("make test") 2023-06-17 14:19:10 -07:00
Robert Xiao 4b471e16e9 Remove redundant Makefile 2023-06-17 14:19:10 -07:00
lazymio 9e1443013b
Fix gen_const 2021-10-26 13:10:59 +02:00
lazymio e695686c15
Remove AFL Integration by reverting 2021-10-26 11:22:21 +02:00
lazymio f08b7d6b5b
Make gen_const work and updates constants 2021-10-25 00:57:32 +02:00
Nguyen Anh Quynh 1f408ce359 java: cleanup Makefile 2018-03-12 13:41:38 +08:00
Jeremy Sears 94b1168776 Fix Java Makefile on Darwin (#936)
* Fixes the logic for Dylib extensions on macOS.
* Adds an uninstall task and documentation.
2018-03-12 20:40:40 +07:00
Chris Eagle 347a01d6b5 spaces to tabs in Makefile 2015-09-25 00:20:02 -07:00
Chris Eagle 0e680fbafa Hack to make gen_const work even if java not installed 2015-09-24 22:45:59 -07:00
Chris Eagle e29cdbe867 File permissions 2015-08-28 20:56:16 -07:00
Chris Eagle 1d6bd17a13 Update java bindings for new version of uc_mem_map 2015-08-28 20:54:05 -07:00
Jonathon Reinhart 60d0004329 remove executable bit from mode of source files
http://stackoverflow.com/questions/1580596/how-do-i-make-git-ignore-file-mode-chmod-changes
2015-08-26 05:34:31 -04:00
Chris Eagle fafdac516a Make a bad Makefile slightly less bad 2015-08-25 11:41:14 -07:00
Chris Eagle 0359c44462 Initial checkin of unicorn java binding 2015-08-25 03:21:47 -07:00