Skip to content

Commit

Permalink
actually actually fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
toolCHAINZ committed Oct 16, 2024
1 parent 2785973 commit 2c3cd62
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 26 deletions.
1 change: 0 additions & 1 deletion jingle/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,4 @@ hex = { version = "0.4.3" , optional = true}
[features]
default = []
bin_features = ["dep:clap", "dep:confy", "dep:hex"]
elf = ["jingle_sleigh/elf"]
gimli = ["jingle_sleigh/gimli"]
4 changes: 1 addition & 3 deletions jingle_sleigh/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ cxx = "1.0.122"
serde = { version = "1.0.203", features = ["derive"] }
serde-xml-rs = "0.6.0"
thiserror = { version = "1.0.61", features = [] }
elf = { version = "0.7.4", optional = true }
object = { version = "0.36.0", optional = true }
libz-sys = { version = "1.1.18", default-features = false, features = ["libc"] }
tracing = "0.1.40"
Expand All @@ -33,8 +32,7 @@ tracing = "0.1.40"
cxx-build = "1.0.122"

[features]
elf = ["dep:elf"]
gimli = ["dep:object"]
default = ["elf", "gimli"]
default = ["gimli"]


24 changes: 23 additions & 1 deletion jingle_sleigh/src/ffi/context_ffi.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
use std::pin::Pin;
use crate::ffi::context_ffi::bridge::makeContext;
use bridge::ContextFFI;
use cxx::{Exception, UniquePtr};
use cxx::{Exception, ExternType, UniquePtr};
use std::sync::Mutex;
use crate::context::image::ImageProvider;
use crate::ffi::instruction::bridge::VarnodeInfoFFI;
use crate::VarNode;

type ContextGeneratorFp = fn(&str) -> Result<UniquePtr<ContextFFI>, Exception>;

Expand Down Expand Up @@ -57,4 +59,24 @@ pub(crate) mod bridge {

pub(crate) struct ImageFFI<'a> {
pub(crate) provider: Pin<Box<dyn ImageProvider + 'a>>,
}

impl<'a> ImageFFI<'a> {
pub(crate) fn new<T: ImageProvider + 'a>(provider: T) -> Self {
Self {
provider: Box::pin(provider),
}
}
pub(crate) fn load(&self, vn: &VarnodeInfoFFI, out: &mut [u8]) -> usize {
self.provider.load(&VarNode::from(vn), out)
}

pub(crate) fn has_range(&self, vn: &VarNode) -> bool {
self.provider.has_full_range(vn)
}
}

unsafe impl<'a> ExternType for ImageFFI<'a> {
type Id = cxx::type_id!("ImageFFI");
type Kind = cxx::kind::Opaque;
}
3 changes: 2 additions & 1 deletion jingle_sleigh/src/ffi/cpp/context.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#ifndef JINGLE_SLEIGH_CONTEXT_H
#define JINGLE_SLEIGH_CONTEXT_H

class ContextFFI;
#include "jingle_sleigh/src/ffi/context_ffi.rs.h"
#include "rust/cxx.h"
#include "sleigh/types.h"
#include "addrspace_handle.h"
#include "jingle_sleigh/src/ffi/instruction.rs.h"
#include "sleigh/globalcontext.hh"
#include "sleigh/sleigh.hh"
#include "jingle_sleigh/src/ffi/image.rs.h"
#include "sleigh/loadimage.hh"
#include "dummy_load_image.h"

Expand Down
2 changes: 1 addition & 1 deletion jingle_sleigh/src/ffi/cpp/rust_load_image.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#ifndef JINGLE_SLEIGH_RUST_LOAD_IMAGE_H
#define JINGLE_SLEIGH_RUST_LOAD_IMAGE_H

#include "jingle_sleigh/src/ffi/image.rs.h"
#include "context.h"
#include "sleigh/loadimage.hh"

class RustLoadImage : public ghidra::LoadImage {
Expand Down
1 change: 0 additions & 1 deletion jingle_sleigh/src/ffi/cpp/sleigh_image.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "jingle_sleigh/src/ffi/instruction.rs.h"
#include "sleigh/sleigh.hh"
#include "rust/cxx.h"
#include "jingle_sleigh/src/ffi/image.rs.h"
#include "dummy_load_image.h"

class SleighImage{
Expand Down
18 changes: 0 additions & 18 deletions jingle_sleigh/src/ffi/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,4 @@ use cxx::ExternType;
use crate::ffi::context_ffi::ImageFFI;


impl<'a> ImageFFI<'a> {
pub(crate) fn new<T: ImageProvider + 'a>(provider: T) -> Self {
Self {
provider: Box::pin(provider),
}
}
pub(crate) fn load(&self, vn: &VarnodeInfoFFI, out: &mut [u8]) -> usize {
self.provider.load(&VarNode::from(vn), out)
}

pub(crate) fn has_range(&self, vn: &VarNode) -> bool {
self.provider.has_full_range(vn)
}
}

unsafe impl<'a> ExternType for ImageFFI<'a> {
type Id = cxx::type_id!("ImageFFI");
type Kind = cxx::kind::Opaque;
}

0 comments on commit 2c3cd62

Please sign in to comment.