Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update with fugue-core change to use iset #1

Merged
merged 3 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,5 @@ jobs:
with:
submodules: 'recursive'

- name: add registry
run: |
mkdir -p ~/.cargo
echo '[registries]' >> ~/.cargo/config.toml
echo 'fugue = { index = "ssh://git@github.com/fugue-re/fugue-oss-registry" }' >> ~/.cargo/config.toml

- name: build
run: cargo build --features="fugue-db/fixed-u64" --verbose
run: cargo build --features="fixed-u64" --no-default-features --verbose
17 changes: 11 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@ name = "fugue-radare"
version = "0.2.3"
edition = "2018"

[features]
default = ["bigint"]
bigint = ["fugue-db/bigint"]
fixed-u64 = ["fugue-db/fixed-u64"]
fixed-u128 = ["fugue-db/fixed-u128"]

[dependencies]
flatbuffers = "2.0"
fugue-db = { version = "0.2", registry = "fugue", default-features = false }
intervals = { version = "0.1", registry = "fugue" }
fugue-db = { version = "0.2", default-features = false }
iset = "0.2"
itertools = "0.10"
md5 = "0.7"
sha2 = "0.9"
Expand All @@ -18,10 +23,10 @@ shared_memory = "0.12"
thiserror = "1"
which = "4"
url = "2.2"
flatbuffers = "23.1.21"

[build-dependencies]
flatc-rust = "0.2"
flatc = { version = "0.2.1", registry = "fugue" }
flatcc = "23.1.21"

[dev-dependencies]
fugue = { version = "0.2", registry = "fugue" }
fugue = { version = "0.2", features = ["db"] }
8 changes: 2 additions & 6 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
use std::path::Path;
use std::env;

fn main() {
flatc_rust::Flatc::from_path(flatc::flatc()).run(flatc_rust::Args {
inputs: &[&env::current_dir().unwrap().join("schema/fugue.fbs")],
out_dir: Path::new(&env::var("OUT_DIR").unwrap()),
..Default::default()
}).expect("schema compiled successfully");
flatcc::build(env::current_dir().unwrap().join("schema/fugue.fbs"))
.expect("schema compiled successfully");
}
20 changes: 12 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ use fugue_db::backend::{Backend, Imported};
use fugue_db::Error as ExportError;

use itertools::Itertools;
use intervals::Interval;
use intervals::collections::IntervalSet;
use iset::IntervalSet;
use r2pipe::R2Pipe;

pub use r2pipe::R2PipeSpawnOptions;
Expand Down Expand Up @@ -83,13 +82,17 @@ struct MetadataBin<'d> {
#[derive(Debug, Deserialize)]
struct MetadataCore<'d> {
file: &'d str,
#[allow(unused)]
size: u32,
}

#[derive(Debug, Deserialize)]
struct MetadataHashes<'d> {
#[allow(unused)]
md5: &'d str,
#[allow(unused)]
sha1: &'d str,
#[allow(unused)]
sha256: &'d str,
}

Expand Down Expand Up @@ -189,6 +192,7 @@ struct Symbol<'d> {
#[serde(default)]
vaddr: u64,
#[serde(default)]
#[allow(unused)]
paddr: u64,
is_imported: bool,
}
Expand Down Expand Up @@ -389,10 +393,10 @@ impl<'db> RadareExporter<'db> {
let input_path = self.builder.create_string(&corebin.core.file);
let input_md5 = self
.builder
.create_vector_direct(&*md5);
.create_vector(&*md5);
let input_sha256 = self
.builder
.create_vector_direct(&*sha256);
.create_vector(&*sha256);
let input_format = self
.builder
.create_string(Metadata::format(&corebin.bin.bintype)?);
Expand Down Expand Up @@ -425,7 +429,7 @@ impl<'db> RadareExporter<'db> {
}

let name = self.builder.create_string(seg.name);
let bytes = self.builder.create_vector_direct(&content);
let bytes = self.builder.create_vector(&content);

let mut sbuilder = schema::SegmentBuilder::new(&mut self.builder);

Expand Down Expand Up @@ -461,7 +465,7 @@ impl<'db> RadareExporter<'db> {
None
} else {
let vaddr = s.address()?;
seg_ivt.insert(Interval::from(vaddr..=vaddr+(s.vsize as u64 - 1)));
seg_ivt.insert(vaddr..vaddr+(s.vsize as u64));
Some(self.export_segment(s))
})
.collect::<Result<Vec<_>, Error>>()?;
Expand Down Expand Up @@ -578,7 +582,7 @@ impl<'db> RadareExporter<'db> {
let mut blk_ibps_map =
HashMap::<u64, (u64, BasicBlock, Vec<u64>, Vec<u64>)>::with_capacity(blks.len());

for (i, blk) in blks.into_iter().filter(|b| seg_ivt.overlaps(b.addr..=b.addr)).enumerate() {
for (i, blk) in blks.into_iter().filter(|b| seg_ivt.has_overlap(b.addr..=b.addr)).enumerate() {
let bid = (id as u64) << 32 | (i as u64);
let addr = blk.addr;

Expand All @@ -598,7 +602,7 @@ impl<'db> RadareExporter<'db> {

blk_map.insert(addr, bid);

let mut ibps = blk_ibps_map.entry(addr).or_default();
let ibps = blk_ibps_map.entry(addr).or_default();
ibps.0 = bid;
ibps.1 = blk;
ibps.3.extend(succs.into_iter());
Expand Down
Loading