https://sourceware.org/bugzilla/show_bug.cgi?id=22942
Bug ID: 22942 Summary: objdump slow in find_symbol_for_address Product: binutils Version: 2.30 Status: UNCONFIRMED Severity: normal Priority: P2 Component: binutils Assignee: unassigned at sourceware dot org Reporter: manjian2006 at gmail dot com Target Milestone: --- Extremely slow when the aux->dynrelbuf has many members in for (rel_count = aux->dynrelcount, rel_pp = aux->dynrelbuf; rel_count--;) { linear search. Patched with the following binary search patch will perform much better. diff --git a/binutils/objdump.c b/binutils/objdump.c index 6c4d936b26..c80e5c42cf 100644 --- a/binutils/objdump.c +++ b/binutils/objdump.c @@ -1071,13 +1071,14 @@ find_symbol_for_address (bfd_vma vma, /* If we have matched a synthetic symbol, then stick with that. */ && (sorted_syms[thisplace]->flags & BSF_SYNTHETIC) == 0) { - long rel_count; + long low, high; arelent ** rel_pp; - for (rel_count = aux->dynrelcount, rel_pp = aux->dynrelbuf; - rel_count--;) + for (low = 0, high = aux->dynrelcount, rel_pp = aux->dynrelcount; + low + 1 == high;) { - arelent * rel = rel_pp[rel_count]; + long mid = (high - low) / 2 + low; + arelent * rel = rel_pp[mid]; if (rel->address == vma && rel->sym_ptr_ptr != NULL @@ -1088,11 +1089,11 @@ find_symbol_for_address (bfd_vma vma, * place = thisplace; return * rel->sym_ptr_ptr; } - - /* We are scanning backwards, so if we go below the target address - we have failed. */ - if (rel_pp[rel_count]->address < vma) - break; + if (rel->address > vma) { + high = mid; + } else { + low = mid + 1; + } } } -- You are receiving this mail because: You are on the CC list for the bug. _______________________________________________ bug-binutils mailing list bug-binutils@gnu.org https://lists.gnu.org/mailman/listinfo/bug-binutils