From cdb34147d4ae37cf6f1560eb992ef06b83300b17 Mon Sep 17 00:00:00 2001 From: marirs <251870+marirs@users.noreply.github.com> Date: Sun, 5 May 2024 21:04:15 +0530 Subject: [PATCH] refactor --- src/elf/dynamic.rs | 6 +++--- src/parser.rs | 2 +- src/workspace.rs | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/elf/dynamic.rs b/src/elf/dynamic.rs index 1074caf..71f2005 100755 --- a/src/elf/dynamic.rs +++ b/src/elf/dynamic.rs @@ -117,9 +117,9 @@ pub const DT_HIPROC: u64 = 0x7fff_ffff; pub const DT_ADDRRNGLO: u64 = 0x6fff_fe00; /// GNU-style hash table pub const DT_GNU_HASH: u64 = 0x6fff_fef5; -/// +/// TLDESC PLT pub const DT_TLSDESC_PLT: u64 = 0x6fff_fef6; -/// +/// TLDESC GOT pub const DT_TLSDESC_GOT: u64 = 0x6fff_fef7; /// Start of conflict section pub const DT_GNU_CONFLICT: u64 = 0x6fff_fef8; @@ -137,7 +137,7 @@ pub const DT_PLTPAD: u64 = 0x6fff_fefd; pub const DT_MOVETAB: u64 = 0x6fff_fefe; /// Syminfo table pub const DT_SYMINFO: u64 = 0x6fff_feff; -/// +/// SYMINFO pub const DT_ADDRRNGHI: u64 = 0x6fff_feff; //DT_ADDRTAGIDX(tag) (DT_ADDRRNGHI - (tag)) /* Reverse order! */ diff --git a/src/parser.rs b/src/parser.rs index 5d50003..5be1f45 100755 --- a/src/parser.rs +++ b/src/parser.rs @@ -17,7 +17,7 @@ pub fn parse_file(mut workspace: VivWorkspace, filename: &str, _base_addr: Optio let contents = fs::read(filename).expect("Error reading the file."); let mut cursor = Cursor::new(contents); let mut shdr = Vec::with_capacity(offset); - cursor.read(&mut shdr).unwrap(); + cursor.read_exact(&mut shdr).unwrap(); let mut sbytes = Vec::new(); cursor.read_to_end(&mut sbytes).unwrap(); let fname: String = workspace.add_file(filename, 0, sbytes.clone()); diff --git a/src/workspace.rs b/src/workspace.rs index 0d55e47..267fe0a 100755 --- a/src/workspace.rs +++ b/src/workspace.rs @@ -279,7 +279,7 @@ impl VivWorkspace { /// Example: /// vw.set_comment(callva, "This actually calls FOO...") pub fn set_comment(&mut self, va: i32, comment: &str, check: bool) { - if check && self.comments.get(&va).is_some() { + if check && self.comments.contains_key(&va) { return; } todo!(); @@ -1122,7 +1122,7 @@ impl VivWorkspace { } pub fn is_function(&self, func_va: i32) -> bool { - self.funcmeta.get(&func_va).is_some() + self.funcmeta.contains_key(&func_va) } /// Returns the name of the specified virtual address (or None). @@ -1243,7 +1243,7 @@ impl VivWorkspace { /// Return the VA for this function. This will search code blocks /// and check for a function va. pub fn get_function(&self, va: i32) -> Option { - if self.funcmeta.get(&va).is_some() { + if self.funcmeta.contains_key(&va) { return Some(va); } let cbtup = self.get_code_block(va);