Skip to content

Commit

Permalink
read/elf: use SectionIndex for RelocationSections::get (#677)
Browse files Browse the repository at this point in the history
  • Loading branch information
philipc committed May 4, 2024
1 parent b77473f commit b9154d0
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/read/elf/relocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,12 @@ impl RelocationSections {
///
/// This may also be called with a relocation section index, and it will return the
/// next associated relocation section.
pub fn get(&self, index: usize) -> Option<usize> {
self.relocations.get(index).cloned().filter(|x| *x != 0)
pub fn get(&self, index: SectionIndex) -> Option<SectionIndex> {
self.relocations
.get(index.0)
.cloned()
.filter(|x| *x != 0)
.map(SectionIndex)
}
}

Expand Down Expand Up @@ -201,7 +205,7 @@ where
}
self.relocations = None;
}
self.section_index = SectionIndex(self.file.relocations.get(self.section_index.0)?);
self.section_index = self.file.relocations.get(self.section_index)?;
// The construction of RelocationSections ensures section_index is valid.
let section = self.file.sections.section(self.section_index).unwrap();
match section.sh_type(endian) {
Expand Down

0 comments on commit b9154d0

Please sign in to comment.