Skip to content

Commit

Permalink
elf: Only parse the last SHT_SYMTAB, (#297)
Browse files Browse the repository at this point in the history
because all earlier ones are not used anyway.
  • Loading branch information
Lichtso authored Jan 2, 2022
1 parent f2fe5f4 commit 6efb91c
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/elf/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,13 +293,11 @@ if_sylvan! {

let mut syms = Symtab::default();
let mut strtab = Strtab::default();
for shdr in &section_headers {
if shdr.sh_type as u32 == section_header::SHT_SYMTAB {
let size = shdr.sh_entsize;
let count = if size == 0 { 0 } else { shdr.sh_size / size };
syms = Symtab::parse(bytes, shdr.sh_offset as usize, count as usize, ctx)?;
strtab = get_strtab(&section_headers, shdr.sh_link as usize)?;
}
if let Some(shdr) = section_headers.iter().rfind(|shdr| shdr.sh_type as u32 == section_header::SHT_SYMTAB) {
let size = shdr.sh_entsize;
let count = if size == 0 { 0 } else { shdr.sh_size / size };
syms = Symtab::parse(bytes, shdr.sh_offset as usize, count as usize, ctx)?;
strtab = get_strtab(&section_headers, shdr.sh_link as usize)?;
}

let mut soname = None;
Expand Down

0 comments on commit 6efb91c

Please sign in to comment.