From c63cdf1994aed8d9c38b0764613f3cd371199dc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20M=C3=BCller?= Date: Fri, 27 Dec 2024 11:14:15 -0800 Subject: [PATCH] Fix test_elf64_symtab test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/elf/parser.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/elf/parser.rs b/src/elf/parser.rs index 900daa30..cb9d6a84 100644 --- a/src/elf/parser.rs +++ b/src/elf/parser.rs @@ -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]