Skip to content

Commit

Permalink
Fix test_elf64_symtab test
Browse files Browse the repository at this point in the history
The test_elf64_symtab test compares the ELF reported symbol size with
the one returned by ElfParser::find_sym(). However, those two are not
guaranteed to match up: if an ELF symbol has a size of 0 its size is
"zero or unknown". As such, we report the size as None instead. Adjust
the logic to deal with this condition properly.

Signed-off-by: Daniel Müller <[email protected]>
  • Loading branch information
d-e-s-o committed Dec 27, 2024
1 parent 9d1978e commit c63cdf1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/elf/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1473,7 +1473,7 @@ mod tests {
let sym = parser.find_sym(addr, &FindSymOpts::Basic).unwrap().unwrap();
assert_eq!(sym.addr, addr);
assert_eq!(sym.name, name);
assert_eq!(sym.size, Some(size));
assert!(sym.size.is_none() && size == 0 || sym.size.unwrap() == size);
}

#[test]
Expand Down

0 comments on commit c63cdf1

Please sign in to comment.