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