|
15 | 15 | //! Sections are [crate::segment::Segment]s that are loaded into memory at run time |
16 | 16 |
|
17 | 17 | use std::fmt; |
| 18 | +use std::hash::{Hash, Hasher}; |
18 | 19 | use std::ops::Range; |
19 | 20 |
|
20 | 21 | use binaryninjacore_sys::*; |
@@ -61,7 +62,6 @@ impl From<Semantics> for BNSectionSemantics { |
61 | 62 | } |
62 | 63 | } |
63 | 64 |
|
64 | | -#[derive(PartialEq, Eq, Hash)] |
65 | 65 | pub struct Section { |
66 | 66 | handle: *mut BNSection, |
67 | 67 | } |
@@ -161,6 +161,30 @@ impl fmt::Debug for Section { |
161 | 161 | } |
162 | 162 | } |
163 | 163 |
|
| 164 | +impl PartialEq for Section { |
| 165 | + fn eq(&self, other: &Self) -> bool { |
| 166 | + // TODO: Do we want to make this complete match like this? |
| 167 | + self.name() == other.name() |
| 168 | + && self.address_range() == other.address_range() |
| 169 | + && self.semantics() == other.semantics() |
| 170 | + && self.linked_section() == other.linked_section() |
| 171 | + && self.info_section() == other.info_section() |
| 172 | + && self.info_data() == other.info_data() |
| 173 | + && self.align() == other.align() |
| 174 | + && self.entry_size() == other.entry_size() |
| 175 | + && self.auto_defined() == other.auto_defined() |
| 176 | + } |
| 177 | +} |
| 178 | + |
| 179 | +impl Eq for Section {} |
| 180 | + |
| 181 | +impl Hash for Section { |
| 182 | + fn hash<H: Hasher>(&self, state: &mut H) { |
| 183 | + self.name().hash(state); |
| 184 | + self.address_range().hash(state); |
| 185 | + } |
| 186 | +} |
| 187 | + |
164 | 188 | impl ToOwned for Section { |
165 | 189 | type Owned = Ref<Self>; |
166 | 190 |
|
|
0 commit comments