Speed up objdump.

Resolves: #1551540
This commit is contained in:
Nick Clifton 2018-03-06 08:06:14 +00:00
parent 5491f5f490
commit 6766a3d6b6
2 changed files with 107 additions and 1 deletions

View File

@ -0,0 +1,97 @@
--- binutils.orig/binutils/objdump.c 2018-03-05 17:04:19.901619738 +0000
+++ binutils-2.29/binutils/objdump.c 2018-03-05 17:10:08.334643096 +0000
@@ -664,9 +664,7 @@ slurp_dynamic_symtab (bfd *abfd)
static bfd_boolean
is_significant_symbol_name (const char * name)
{
- return strcmp (name, ".plt") == 0
- || strcmp (name, ".got") == 0
- || strcmp (name, ".plt.got") == 0;
+ return strncmp (name, ".plt", 4) == 0 || strcmp (name, ".got") == 0;
}
/* Filter out (in place) symbols that are useless for disassembly.
@@ -937,6 +935,7 @@ find_symbol_for_address (bfd_vma vma,
asection *sec;
unsigned int opb;
bfd_boolean want_section;
+ long rel_count;
if (sorted_symcount < 1)
return NULL;
@@ -1065,33 +1064,59 @@ find_symbol_for_address (bfd_vma vma,
and we have dynamic relocations available, then we can produce
a better result by matching a relocation to the address and
using the symbol associated with that relocation. */
+ rel_count = aux->dynrelcount;
if (!want_section
- && aux->dynrelbuf != NULL
&& sorted_syms[thisplace]->value != vma
+ && rel_count > 0
+ && aux->dynrelbuf != NULL
+ && aux->dynrelbuf[0]->address <= vma
+ && aux->dynrelbuf[rel_count - 1]->address >= vma
/* If we have matched a synthetic symbol, then stick with that. */
&& (sorted_syms[thisplace]->flags & BSF_SYNTHETIC) == 0)
{
- long rel_count;
- arelent ** rel_pp;
+ arelent ** rel_low;
+ arelent ** rel_high;
- for (rel_count = aux->dynrelcount, rel_pp = aux->dynrelbuf;
- rel_count--;)
+ rel_low = aux->dynrelbuf;
+ rel_high = rel_low + rel_count - 1;
+ while (rel_low <= rel_high)
{
- arelent * rel = rel_pp[rel_count];
+ arelent ** rel_mid = &rel_low[(rel_high - rel_low) / 2];
+ arelent * rel = *rel_mid;
- if (rel->address == vma
- && rel->sym_ptr_ptr != NULL
- /* Absolute relocations do not provide a more helpful symbolic address. */
- && ! bfd_is_abs_section ((* rel->sym_ptr_ptr)->section))
+ if (rel->address == vma)
{
- if (place != NULL)
- * place = thisplace;
- return * rel->sym_ptr_ptr;
+ /* Absolute relocations do not provide a more helpful
+ symbolic address. Find a non-absolute relocation
+ with the same address. */
+
+ arelent **rel_vma = rel_mid;
+
+ for (rel_mid--;
+ rel_mid >= rel_low && rel_mid[0]->address == vma;
+ rel_mid--)
+ rel_vma = rel_mid;
+
+ for (; rel_vma <= rel_high && rel_vma[0]->address == vma;
+ rel_vma++)
+ {
+ rel = *rel_vma;
+ if (rel->sym_ptr_ptr != NULL
+ && ! bfd_is_abs_section ((* rel->sym_ptr_ptr)->section))
+ {
+ if (place != NULL)
+ * place = thisplace;
+ return * rel->sym_ptr_ptr;
+ }
+ }
+ break;
}
- /* We are scanning backwards, so if we go below the target address
- we have failed. */
- if (rel_pp[rel_count]->address < vma)
+ if (vma < rel->address)
+ rel_high = rel_mid;
+ else if (vma >= rel_mid[1]->address)
+ rel_low = rel_mid + 1;
+ else
break;
}
}

View File

@ -62,7 +62,7 @@
Summary: A GNU collection of binary utilities
Name: %{?cross}binutils%{?_with_debug:-debug}
Version: 2.30
Release: 6%{?dist}
Release: 7%{?dist}
License: GPLv3+
Group: Development/Tools
URL: https://sourceware.org/binutils
@ -163,6 +163,11 @@ Patch12: binutils-page-to-segment-assignment.patch
# Lifetime: Fixed in 2.30.1 and/or 2.31
Patch13: binutils-2.30-allow_R_AARCH64-symbols.patch
# Purpose: Improves objdump's function for locating a symbol to match a
# given address, so that it uses a binary chop algorithm.
# Lifetime: Fixed in 2.31.
Patch14: binutils-speed-up-objdump.patch
#----------------------------------------------------------------------------
Provides: bundled(libiberty)
@ -301,6 +306,7 @@ using libelf instead of BFD.
%patch11 -p1
%patch12 -p1
%patch13 -p1
%patch14 -p1
# We cannot run autotools as there is an exact requirement of autoconf-2.59.
@ -709,6 +715,9 @@ exit 0
#----------------------------------------------------------------------------
%changelog
* Mon Mar 05 2018 Nick Clifton <nickc@redhat.com> 2.30-7
- Speed up objdump. (#1551540)
* Thu Feb 22 2018 Patrick Uiterwijk <patrick@puiterwijk.org> - 2.30-6
- Fix R_AARCH64 symbols (PR 22764) (#1547781)