AftonJIT - is a jit compiler for afton bytecode designed simple and flexibility. The current AftonJIT version is 0.1 ,the current format version is 1 and its magic number is 0xFFF. Afton V1 supports 5 instructions:
- push
- rem
- ret
- invoke(without arguments)
- dup
Also it supports functions, without arguments and variables
Now,AftonJIT as target supports only x86_64.
AftonJIT has some ways to built it. Here's they:
- build production version by gcc or tcc:
make gccOr
make tcc- build debug version by gcc or tcc:
make gcc_debugOr
make tcc_debug- Also you may to clean aftonjit binary by:
make cleanThe next map displays mnemonic and its correspond opcode for writing real afton proggrams:
- push [ANY_NUMBER] : 0x00
- rem : 0x01
- ret [RET_VOID or RET_STACK or ANY_NUMBER] : 0x07
- invoke [FUNCTION_NAME_LEN] [FUNCTION_NAME] : 0x0B
- dup : 0x02
- fn [FUNCTION_NAME_LEN] [FUNCTION_NAME] [LOCALS_COUNT] [ARGUMENTS_COUNT] : 0x1F
- end : 0x5F
- end_prg : 0xFE
Here's:
- RET_VOID is magic number notificates AftonJIT not return something from function
- RET_STACK is magic number notificates AftonJIT return the latest value from stack
- end is marker notificates AftonJIT scope of the current function is ended
- end_prg is marker notificates AftonJIT the proggram code is ended
For testing something proggrams,you can execute like this:
make testThat command generates 4 test files and their names you may execute with ./aftonjit command
If you're in the debug mode,you may see the title like "Dumped XX bytes to jit_dump.bin". For seeing what AftonJIT generates based on your proggram,use the command below:
objdump -D -b binary -m i386:x86-64 jit_dump.bin You're seeing like this:
jit_dump.bin: file format binary
Disassembly of section .data:
0000000000000000 <.data>:
0: 55 push %rbp
1: 48 89 e5 mov %rsp,%rbp
4: 58 pop %rax
5: c9 leave
6: c3 ret