Skip to content

Commit

Permalink
adding more archs
Browse files Browse the repository at this point in the history
  • Loading branch information
snf committed Mar 19, 2016
1 parent 821536c commit 1e3d418
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 7 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ It (ab)uses LLVM architecture to insert a BinaryStreamer during the
ASM parsing run and output the binary code to a buffer instead of an
object file. It supports inline and external labels/relocations too.

It supports x86, x86-64, Arm, Armeb, Arm64, Thumb, Mips, Mipsel,
PowerPC, PowerPC64, Sparc and SystemZ.

## Use it

It depends on LLVM >= 3.7, zlib and libedit.
Expand Down
27 changes: 21 additions & 6 deletions src/assembler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,15 @@ mod extern_def {
pub const x86: ::libc::c_uint = 0;
pub const x86_64: ::libc::c_uint = 1;
pub const mips: ::libc::c_uint = 2;
pub const arm: ::libc::c_uint = 3;
pub const arm64: ::libc::c_uint = 4;
pub const thumb: ::libc::c_uint = 5;
pub const ppc32: ::libc::c_uint = 6;
pub const mipsel: ::libc::c_uint = 3;
pub const arm: ::libc::c_uint = 4;
pub const armeb: ::libc::c_uint = 5;
pub const thumb: ::libc::c_uint = 6;
pub const arm64: ::libc::c_uint = 7;
pub const ppc32: ::libc::c_uint = 8;
pub const ppc64: ::libc::c_uint = 9;
pub const sparc: ::libc::c_uint = 10;
pub const systemz: ::libc::c_uint = 11;
#[repr(C)]
#[derive(Copy)]
pub struct Struct_Unnamed1 {
Expand Down Expand Up @@ -70,10 +75,15 @@ pub enum Arch {
X86,
X86_64,
Mips,
Mipsel,
Arm,
Armeb,
Arm64,
Thumb,
PPC32
PPC32,
PPC64,
Sparc,
SystemZ
}

impl Arch {
Expand All @@ -82,10 +92,15 @@ impl Arch {
Arch::X86 => extern_def::x86,
Arch::X86_64 => extern_def::x86_64,
Arch::Mips => extern_def::mips,
Arch::Mipsel => extern_def::mipsel,
Arch::Arm => extern_def::arm,
Arch::Armeb => extern_def::armeb,
Arch::Arm64 => extern_def::arm64,
Arch::Thumb => extern_def::thumb,
Arch::PPC32 => extern_def::ppc32
Arch::PPC32 => extern_def::ppc32,
Arch::PPC64 => extern_def::ppc64,
Arch::Sparc => extern_def::sparc,
Arch::SystemZ => extern_def::systemz
}
}
}
Expand Down
15 changes: 15 additions & 0 deletions src/c/assemble.cc
Original file line number Diff line number Diff line change
Expand Up @@ -551,9 +551,15 @@ int assemble(enum Arch arch, const char *instructions, const uint64_t addr, cons
case mips:
s_arch = "mips";
break;
case mipsel:
s_arch = "mipsel";
break;
case arm:
s_arch = "arm";
break;
case armeb:
s_arch = "armeb";
break;
case arm64:
s_arch = "arm64";
break;
Expand All @@ -563,6 +569,15 @@ int assemble(enum Arch arch, const char *instructions, const uint64_t addr, cons
case ppc32:
s_arch = "ppc32";
break;
case ppc64:
s_arch = "ppc64";
break;
case sparc:
s_arch = "sparc";
break;
case systemz:
s_arch = "systemz";
break;
default:
return -1;
}
Expand Down
7 changes: 6 additions & 1 deletion src/c/assemble.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,15 @@ extern "C" {
x86,
x86_64,
mips,
mipsel,
arm,
arm64,
armeb,
thumb,
arm64,
ppc32,
ppc64,
sparc,
systemz
};

typedef struct {
Expand Down

0 comments on commit 1e3d418

Please sign in to comment.