Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
marirs committed May 5, 2024
1 parent 1c9cfc8 commit cdb3414
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/elf/dynamic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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! */
Expand Down
2 changes: 1 addition & 1 deletion src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
6 changes: 3 additions & 3 deletions src/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!();
Expand Down Expand Up @@ -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).
Expand Down Expand Up @@ -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<i32> {
if self.funcmeta.get(&va).is_some() {
if self.funcmeta.contains_key(&va) {
return Some(va);
}
let cbtup = self.get_code_block(va);
Expand Down

0 comments on commit cdb3414

Please sign in to comment.