From d1da323089f5b5be67a3d394d7ef2570d4c6b795 Mon Sep 17 00:00:00 2001 From: Philip Craig Date: Thu, 25 Apr 2024 12:15:16 +1000 Subject: [PATCH] read/elf: use SectionIndex for RelocationSections::get --- src/read/elf/relocation.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/read/elf/relocation.rs b/src/read/elf/relocation.rs index 1f43efe5..63a5d5f5 100644 --- a/src/read/elf/relocation.rs +++ b/src/read/elf/relocation.rs @@ -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 { - self.relocations.get(index).cloned().filter(|x| *x != 0) + pub fn get(&self, index: SectionIndex) -> Option { + self.relocations + .get(index.0) + .cloned() + .filter(|x| *x != 0) + .map(SectionIndex) } } @@ -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) {