summaryrefslogtreecommitdiff
path: root/rust/src
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2025-05-07 23:21:06 -0400
committerMason Reed <35282038+emesare@users.noreply.github.com>2025-05-12 17:45:24 -0400
commit074ace03bf11aea9d78f01789c1a7ab569406067 (patch)
tree3f9844b6796a7940f26b594c07589e14ecfea209 /rust/src
parent36a7bb2da7f77074203f5d785dbd82afe1befcad (diff)
[Rust] Correct impls for `Section`
Previously we were comparing the section raw pointer and hashing it
Diffstat (limited to 'rust/src')
-rw-r--r--rust/src/section.rs26
1 files changed, 25 insertions, 1 deletions
diff --git a/rust/src/section.rs b/rust/src/section.rs
index 77e40232..edf19582 100644
--- a/rust/src/section.rs
+++ b/rust/src/section.rs
@@ -15,6 +15,7 @@
//! Sections are [crate::segment::Segment]s that are loaded into memory at run time
use std::fmt;
+use std::hash::{Hash, Hasher};
use std::ops::Range;
use binaryninjacore_sys::*;
@@ -61,7 +62,6 @@ impl From<Semantics> for BNSectionSemantics {
}
}
-#[derive(PartialEq, Eq, Hash)]
pub struct Section {
handle: *mut BNSection,
}
@@ -161,6 +161,30 @@ impl fmt::Debug for Section {
}
}
+impl PartialEq for Section {
+ fn eq(&self, other: &Self) -> bool {
+ // TODO: Do we want to make this complete match like this?
+ self.name() == other.name()
+ && self.address_range() == other.address_range()
+ && self.semantics() == other.semantics()
+ && self.linked_section() == other.linked_section()
+ && self.info_section() == other.info_section()
+ && self.info_data() == other.info_data()
+ && self.align() == other.align()
+ && self.entry_size() == other.entry_size()
+ && self.auto_defined() == other.auto_defined()
+ }
+}
+
+impl Eq for Section {}
+
+impl Hash for Section {
+ fn hash<H: Hasher>(&self, state: &mut H) {
+ self.name().hash(state);
+ self.address_range().hash(state);
+ }
+}
+
impl ToOwned for Section {
type Owned = Ref<Self>;