#x86-64 #codegen #code-generation #compiler

CodeGenLib

A libary to generate x86-64Bit machine code (like LLVM)

1 unstable release

0.0.1 Mar 31, 2024

#71 in #code-generation

MPL-2.0 license

73KB
1.5K SLoC

A libary to generate x86-64Bit machine code

Error: Jit dosn't work

Example

use CodeGenLib::{Builder, ArtifactError};

pub fn main() -> Result<(), ArtifactError>{
    let mut builder = Builder::new();

    builder.add_function("call")
        .call("callme")
        .ret_int(5);

    builder.build("test.o")?;

    Ok(())
}

Documentation

Check out our documentation on https://docs.rs/CodeGenLib

Copyright (C) 2024 Cr0a3

(!) Uses the faerie crate (https://crates.io/crates/faerie)


lib.rs:

CodeGenLib is a rust libary to generate x86-64Bit machine code (like llvm)

Example

use CodeGenLib::{Builder, ArtifactError}

pub fn main() -> Result<(), ArtifactError> {
   let mut builder = Builder::new();

   builder.add_function("call")
    .call("callme")
    .ret_int(1);
   
   builder.build("test.o")?;
   
   Ok(())
}

The examples would make a elf file with a function named call wich just calls a function named callme and then returns a 1

Dependencies

~3MB
~62K SLoC