[PATCH] Fix return code in _bfd_dwarf2_find_nearest_line().
Steinar H. Gunderson
sesse@google.com
Mon Mar 21 12:43:33 GMT 2022
If we find a function name through the debug ranges, but no line
information, we will have found = false (unless we happened to be
in the last compilation unit).
This means _bfd_dwarf2_find_nearest_line() will return 0 (not found)
instead of 2 (partial information found), causing the caller
(_bfd_elf_find_nearest_line) to go through an expensive linear
traversal of all symbols (_bfd_elf_find_function) in a fallback
effort to find a function name. Fix the return code for this case.
---
bfd/dwarf2.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c
index edbcb5069ae..4d232ba1f79 100644
--- a/bfd/dwarf2.c
+++ b/bfd/dwarf2.c
@@ -5602,7 +5602,11 @@ _bfd_dwarf2_find_nearest_line (bfd *abfd,
done:
if (functionname_ptr && function && function->is_linkage)
- *functionname_ptr = function->name;
+ {
+ *functionname_ptr = function->name;
+ if (!found)
+ found = 2;
+ }
else if (functionname_ptr
&& (!*functionname_ptr
|| (function && !function->is_linkage)))
--
2.35.1
More information about the Binutils
mailing list