c2fj is an compiler from C code to FlipJump code (by compiling it to RiscV first). Any program in C can become just a bunch of flips in memory. This project is a compiler, and is a python package too.
c2fj is a powerful tool designed to compile C code into the innovative FlipJump programming language through an intermediate RISC-V representation. It takes a C source file and transforms it into a series of format conversions, eventually outputting a .fjm file ready to be executed.
int main() {
printf("Calculate primes up to: ");
int max_number;
scanf("%d", &max_number);
for (int p = 3; p <= max_number; p += 2) {
if (non_prime[p] == false) {
for (int i = p*p; i <= max_number; i += p) {
non_prime[i] = true;
}
printf("%d\n", p);
}
}
return 0;
}
After compilation, you can see traces of execution like:
Calculate primes up to: 20
2
3
5
7
11
13
17
19
Program exited with exit code 0x0.
To use c2fj, simply run:
python3 c2fj.py file.c
This will compile the specified C file into ELF, then into FlipJump files, and finally produce the executable .fjm file.
c2fj offers various flags for customization:
--breakpoints: Set breakpoints at specified RISC-V addresses.--single-step: Enable single-step execution mode.--unify_fj: Consolidate multiple generated .fj files into one.--finish-after: Halt compilation at a specific step.--build-dir: Define a directory for storing builds.Projects involving multiple C files can leverage c2fj by specifying a Makefile instead of a single C file. The Makefile should define specific constants that c2fj will fill during the build process, enabling efficient management of source files and dependencies.
During compilation, c2fj generates additional files to manage memory and facilitate control flow through jump tables, supporting a robust execution environment.
c2fj is thoroughly tested on Linux with Python 3.13. To execute tests, simply use:
pytest
Explore c2fj for seamless C programming to FlipJump compilation and leverage the benefits of reverse engineering with this modern tool.
No comments yet.
Sign in to be the first to comment.