Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions symbolic-debuginfo/src/elf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,25 @@ impl<'data> ElfObject<'data> {
return_partial_on_err!(elf::Symtab::parse(data, dyn_info.symtab, num_syms, ctx));
}

// If the dynamic symbol table is empty, try to parse it from the section headers.
if obj.dynsyms.is_empty() {
for shdr in &obj.section_headers {
if shdr.sh_type == elf::section_header::SHT_DYNSYM {
let size = shdr.sh_entsize;
let count = if size == 0 { 0 } else { shdr.sh_size / size };
obj.dynsyms = return_partial_on_err!(elf::Symtab::parse(
data,
shdr.sh_offset as usize,
count as usize,
ctx
));

obj.dynstrtab = return_partial_on_err!(get_strtab(&obj.section_headers, shdr.sh_link as usize));
Copy link

Copilot AI May 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After successfully parsing the dynamic symbol table and string table, consider breaking out of the loop to prevent potential overwrites if multiple SHT_DYNSYM sections are present.

Suggested change
obj.dynstrtab = return_partial_on_err!(get_strtab(&obj.section_headers, shdr.sh_link as usize));
obj.dynstrtab = return_partial_on_err!(get_strtab(&obj.section_headers, shdr.sh_link as usize));
break;

Copilot uses AI. Check for mistakes.
break;
}
}
}

obj.shdr_relocs = vec![];
for (idx, section) in obj.section_headers.iter().enumerate() {
let is_rela = section.sh_type == elf::section_header::SHT_RELA;
Expand Down