[PATCH] binutils: Improve symbols lookup

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] binutils: Improve symbols lookup

Borislav Petkov-2
When objdumping the linux kernel, looking up in-line, auxiliary symbols
like this:

  c7 05 d6 61 27 1a 00    movl   $0x0,0x1a2761d6(%rip)        # ffffffff9b6c5000 <__smp_locks_end>

is not optimal because there are multiple symbols at that address:

  729871: ffffffff9b6c5000     0 NOTYPE  GLOBAL DEFAULT   65 __nosave_begin
  790965: ffffffff9b6c5000     4 OBJECT  GLOBAL DEFAULT   65 in_suspend
  804323: ffffffff9b6c5000     0 NOTYPE  GLOBAL DEFAULT   63 __smp_locks_end

and the current binary search can stop somewhere in that set of symbols
with that address.

Add a heuristic which prefers "complete" symbols, i.e., OBJECT and FUNC
symbols to NOTYPE ones with the same address.

With that, the above line points to the correct symbol which is the one
used in the code too:

  8b 05 99 cc 26 1a       mov    0x1a26cc99(%rip),%eax        # ffffffff9b6c5000 <in_suspend>

        * objdump.c (find_symbol_for_address): Add a neuristic to improve
        symbols lookup when multiple symbols with the same address present.
---
 binutils/ChangeLog | 5 +++++
 binutils/objdump.c | 7 +++++++
 2 files changed, 12 insertions(+)

diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index d91298924cfe..95ca9fba4f7e 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,8 @@
+2019-12-03  Borislav Petkov <[hidden email]>
+
+ * objdump.c (find_symbol_for_address): Add a neuristic to improve
+ symbols lookup when multiple symbols with the same address present.
+
 2019-11-22  Andrew Burgess  <[hidden email]>
 
  * dwarf.c (regname_internal_riscv): New function.
diff --git a/binutils/objdump.c b/binutils/objdump.c
index 6a1f142a0ebc..0036020e32e4 100644
--- a/binutils/objdump.c
+++ b/binutils/objdump.c
@@ -1129,6 +1129,13 @@ find_symbol_for_address (bfd_vma vma,
     *place = thisplace;
 
   return sorted_syms[thisplace];
+ } else if (sym_ok (FALSE, abfd, min, sec, inf)) {
+
+ /* Couldn't find a symbol in the current section, try any
+   section but prefer OBJECT or FUNC types to NOTYPE symbols. */
+    if (!(sorted_syms[thisplace]->flags & (BSF_OBJECT | BSF_FUNCTION))
+ && (sorted_syms[min]->flags & (BSF_OBJECT | BSF_FUNCTION)))
+    thisplace = min;
  }
       ++min;
     }
--
2.21.0

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] binutils: Improve symbols lookup

Alan Modra-3
On Wed, Dec 11, 2019 at 05:06:13PM +0100, Borislav Petkov wrote:

> --- a/binutils/objdump.c
> +++ b/binutils/objdump.c
> @@ -1129,6 +1129,13 @@ find_symbol_for_address (bfd_vma vma,
>      *place = thisplace;
>  
>    return sorted_syms[thisplace];
> + } else if (sym_ok (FALSE, abfd, min, sec, inf)) {
> +
> + /* Couldn't find a symbol in the current section, try any
> +   section but prefer OBJECT or FUNC types to NOTYPE symbols. */
> +    if (!(sorted_syms[thisplace]->flags & (BSF_OBJECT | BSF_FUNCTION))
> + && (sorted_syms[min]->flags & (BSF_OBJECT | BSF_FUNCTION)))
> +    thisplace = min;
>   }
>        ++min;
>      }

The right way to prefer function and object symbols is to modify
compare_symbols.

--
Alan Modra
Australia Development Lab, IBM
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] binutils: Improve symbols lookup

Borislav Petkov-2
On Thu, Dec 12, 2019 at 04:07:35PM +1030, Alan Modra wrote:
> The right way to prefer function and object symbols is to modify
> compare_symbols.

Well, the problem there is, is that the section pointer comparison comes
before we even get to look at the flags and we exit there early:

A:           in_suspend, sect: 0x55c40bd0d630
B:      __smp_locks_end, sect: 0x55c40bd0d500
a sec > b sec
A:       __nosave_begin, sect: 0x55c40bd0d630
B:      __smp_locks_end, sect: 0x55c40bd0d500
a sec > b sec
A:       __nosave_begin, sect: 0x55c40bd0d630
B:           in_suspend, sect: 0x55c40bd0d630

leading to this sort order:

779278: 0xffffffff9b230000 __smp_locks_end
779279: 0xffffffff9b230000 in_suspend
779280: 0xffffffff9b230000 __nosave_begin

because __smp_locks_end is in the section with the smaller address. It
is placed earlier in the binary:

718847: ffffffff9b230000     0 NOTYPE  GLOBAL DEFAULT   65 __nosave_begin
779597: ffffffff9b230000     4 OBJECT  GLOBAL DEFAULT   65 in_suspend
792880: ffffffff9b230000     0 NOTYPE  GLOBAL DEFAULT   63 __smp_locks_end

It is in section 63 while the other two are in 65. Which leads to the
first symbol to be selected in this case.

And my currently proposed solution takes care of the issue by doing a
"second pass" only on the symbols in question, so to speak.

I'm open to suggestions, of course, as I might be missing some aspect of
your compare_symbols() suggestion.

Thx.

--
Regards/Gruss,
    Boris.

SUSE Software Solutions Germany GmbH, GF: Felix Imendörffer, HRB 36809, AG Nürnberg
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] binutils: Improve symbols lookup

Alan Modra-3
On Sun, Dec 15, 2019 at 06:48:54PM +0100, Borislav Petkov wrote:

> On Thu, Dec 12, 2019 at 04:07:35PM +1030, Alan Modra wrote:
> > The right way to prefer function and object symbols is to modify
> > compare_symbols.
>
> Well, the problem there is, is that the section pointer comparison comes
> before we even get to look at the flags and we exit there early:
>
> A:           in_suspend, sect: 0x55c40bd0d630
> B:      __smp_locks_end, sect: 0x55c40bd0d500
> a sec > b sec
> A:       __nosave_begin, sect: 0x55c40bd0d630
> B:      __smp_locks_end, sect: 0x55c40bd0d500
> a sec > b sec
> A:       __nosave_begin, sect: 0x55c40bd0d630
> B:           in_suspend, sect: 0x55c40bd0d630
>
> leading to this sort order:
>
> 779278: 0xffffffff9b230000 __smp_locks_end
> 779279: 0xffffffff9b230000 in_suspend
> 779280: 0xffffffff9b230000 __nosave_begin
>
> because __smp_locks_end is in the section with the smaller address. It
> is placed earlier in the binary:
>
> 718847: ffffffff9b230000     0 NOTYPE  GLOBAL DEFAULT   65 __nosave_begin
> 779597: ffffffff9b230000     4 OBJECT  GLOBAL DEFAULT   65 in_suspend
> 792880: ffffffff9b230000     0 NOTYPE  GLOBAL DEFAULT   63 __smp_locks_end
>
> It is in section 63 while the other two are in 65. Which leads to the
> first symbol to be selected in this case.

I see.  Would you mind testing the following patch?  I think it should
do as you want for OBJECT symbols, and fixes some other bugs I noticed.

There is almost certainly going to be some testsuite fallout for some
targets (mips-sgi-irix for one).  I'll fix that with a followup patch.

        * objdump.c (compare_section): New static var.
        (compare_symbols): Sort by current section only.  Don't access
        symbol name out of bounds when checking for file symbols.
        Sort section symbols and object symbols.
        (find_symbol_for_address): Remove bogus debugging and section
        symbol test.
        (disassemble_data): Move symbol sort from here..
        (disassemble_section): ..to here.  Set compare_section.

diff --git a/binutils/objdump.c b/binutils/objdump.c
index c10136edc3..332b12167b 100644
--- a/binutils/objdump.c
+++ b/binutils/objdump.c
@@ -803,6 +803,8 @@ remove_useless_symbols (asymbol **symbols, long count)
   return out_ptr - symbols;
 }
 
+static const asection *compare_section;
+
 /* Sort symbols into value order.  */
 
 static int
@@ -814,8 +816,7 @@ compare_symbols (const void *ap, const void *bp)
   const char *bn;
   size_t anl;
   size_t bnl;
-  bfd_boolean af;
-  bfd_boolean bf;
+  bfd_boolean as, af, bs, bf;
   flagword aflags;
   flagword bflags;
 
@@ -824,10 +825,16 @@ compare_symbols (const void *ap, const void *bp)
   else if (bfd_asymbol_value (a) < bfd_asymbol_value (b))
     return -1;
 
-  if (a->section > b->section)
-    return 1;
-  else if (a->section < b->section)
+  /* Prefer symbols from the section currently being disassembled.
+     Don't sort symbols from other sections by section, since there
+     isn't much reason to prefer one section over another otherwise.
+     See sym_ok comment for why we compare by section name.  */
+  as = strcmp (compare_section->name, a->section->name) == 0;
+  bs = strcmp (compare_section->name, b->section->name) == 0;
+  if (as && !bs)
     return -1;
+  if (!as && bs)
+    return 1;
 
   an = bfd_asymbol_name (a);
   bn = bfd_asymbol_name (b);
@@ -853,7 +860,8 @@ compare_symbols (const void *ap, const void *bp)
 
 #define file_symbol(s, sn, snl) \
   (((s)->flags & BSF_FILE) != 0 \
-   || ((sn)[(snl) - 2] == '.' \
+   || ((snl) > 2 \
+       && (sn)[(snl) - 2] == '.' \
        && ((sn)[(snl) - 1] == 'o' \
    || (sn)[(snl) - 1] == 'a')))
 
@@ -865,8 +873,8 @@ compare_symbols (const void *ap, const void *bp)
   if (! af && bf)
     return -1;
 
-  /* Try to sort global symbols before local symbols before function
-     symbols before debugging symbols.  */
+  /* Sort function and object symbols before global symbols before
+     local symbols before section symbols before debugging symbols.  */
 
   aflags = a->flags;
   bflags = b->flags;
@@ -878,6 +886,13 @@ compare_symbols (const void *ap, const void *bp)
       else
  return -1;
     }
+  if ((aflags & BSF_SECTION_SYM) != (bflags & BSF_SECTION_SYM))
+    {
+      if ((aflags & BSF_SECTION_SYM) != 0)
+ return 1;
+      else
+ return -1;
+    }
   if ((aflags & BSF_FUNCTION) != (bflags & BSF_FUNCTION))
     {
       if ((aflags & BSF_FUNCTION) != 0)
@@ -885,6 +900,13 @@ compare_symbols (const void *ap, const void *bp)
       else
  return 1;
     }
+  if ((aflags & BSF_OBJECT) != (bflags & BSF_OBJECT))
+    {
+      if ((aflags & BSF_OBJECT) != 0)
+ return -1;
+      else
+ return 1;
+    }
   if ((aflags & BSF_LOCAL) != (bflags & BSF_LOCAL))
     {
       if ((aflags & BSF_LOCAL) != 0)
@@ -1102,14 +1124,11 @@ find_symbol_for_address (bfd_vma vma,
 
   /* The symbol we want is now in min, the low end of the range we
      were searching.  If there are several symbols with the same
-     value, we want the first (non-section/non-debugging) one.  */
+     value, we want the first one.  */
   thisplace = min;
   while (thisplace > 0
  && (bfd_asymbol_value (sorted_syms[thisplace])
-     == bfd_asymbol_value (sorted_syms[thisplace - 1]))
- && ((sorted_syms[thisplace - 1]->flags
-      & (BSF_SECTION_SYM | BSF_DEBUGGING)) == 0)
- )
+     == bfd_asymbol_value (sorted_syms[thisplace - 1])))
     --thisplace;
 
   /* Prefer a symbol in the current section if we have multple symbols
@@ -2389,6 +2408,10 @@ disassemble_section (bfd *abfd, asection *section, void *inf)
   pinfo->buffer_length = datasize;
   pinfo->section = section;
 
+  /* Sort the symbols into value and section order.  */
+  compare_section = section;
+  qsort (sorted_syms, sorted_symcount, sizeof (asymbol *), compare_symbols);
+
   /* Skip over the relocs belonging to addresses below the
      start address.  */
   while (rel_pp < rel_ppend
@@ -2632,9 +2655,6 @@ disassemble_data (bfd *abfd)
       ++sorted_symcount;
     }
 
-  /* Sort the symbols into section and symbol order.  */
-  qsort (sorted_syms, sorted_symcount, sizeof (asymbol *), compare_symbols);
-
   init_disassemble_info (&disasm_info, stdout, (fprintf_ftype) fprintf);
 
   disasm_info.application_data = (void *) &aux;

--
Alan Modra
Australia Development Lab, IBM
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] binutils: Improve symbols lookup

Borislav Petkov-2
On Mon, Dec 16, 2019 at 04:29:23PM +1030, Alan Modra wrote:
> I see.  Would you mind testing the following patch?  I think it should
> do as you want for OBJECT symbols, and fixes some other bugs I noticed.

Yes, it does. Diffing objdump output of an allyesconfig kernel with
and without this patch gives the diff below and from looking at the
different spots in the code, now the symbol name referenced is the
correct one.

So thanks!

:-)

--- /tmp/before.objdump 2019-12-16 14:00:39.887918039 +0100
+++ /tmp/after.objdump 2019-12-16 12:17:36.935947513 +0100
@@ -8497,7 +8497,7 @@ ffffffff81007358: e8 23 95 54 00
 ffffffff8100735d: 85 ed                 test   %ebp,%ebp
 ffffffff8100735f: 0f 84 fd fe ff ff     je     ffffffff81007262 <prepare_exit_to_usermode+0xd2>
 ffffffff81007365: e8 06 94 54 00       callq  ffffffff81550770 <__sanitizer_cov_trace_pc>
-ffffffff8100736a: 0f b6 2d dc 08 d2 16 movzbl 0x16d208dc(%rip),%ebp        # ffffffff97d27c4d <__start_once>
+ffffffff8100736a: 0f b6 2d dc 08 d2 16 movzbl 0x16d208dc(%rip),%ebp        # ffffffff97d27c4d <__warned.54755>
 ffffffff81007371: 31 ff                 xor    %edi,%edi
 ffffffff81007373: 89 ee                 mov    %ebp,%esi
 ffffffff81007375: e8 c6 94 54 00       callq  ffffffff81550840 <__sanitizer_cov_trace_const_cmp1>
@@ -8505,7 +8505,7 @@ ffffffff8100737a: 40 84 ed
 ffffffff8100737d: 0f 85 df fe ff ff     jne    ffffffff81007262 <prepare_exit_to_usermode+0xd2>
 ffffffff81007383: e8 e8 93 54 00       callq  ffffffff81550770 <__sanitizer_cov_trace_pc>
 ffffffff81007388: 48 c7 c7 40 6e 00 8c mov    $0xffffffff8c006e40,%rdi
-ffffffff8100738f: c6 05 b7 08 d2 16 01 movb   $0x1,0x16d208b7(%rip)        # ffffffff97d27c4d <__start_once>
+ffffffff8100738f: c6 05 b7 08 d2 16 01 movb   $0x1,0x16d208b7(%rip)        # ffffffff97d27c4d <__warned.54755>
 ffffffff81007396: e8 c1 f5 32 00       callq  ffffffff8133695c <__warn_printk>
 ffffffff8100739b: 0f 0b                 ud2    
 ffffffff8100739d: e9 c0 fe ff ff       jmpq   ffffffff81007262 <prepare_exit_to_usermode+0xd2>
@@ -8666,7 +8666,7 @@ ffffffff81007625: e8 56 92 54 00
 ffffffff8100762a: 85 ed                 test   %ebp,%ebp
 ffffffff8100762c: 0f 84 1b ff ff ff     je     ffffffff8100754d <syscall_return_slowpath+0x17d>
 ffffffff81007632: e8 39 91 54 00       callq  ffffffff81550770 <__sanitizer_cov_trace_pc>
-ffffffff81007637: 0f b6 2d 0f 06 d2 16 movzbl 0x16d2060f(%rip),%ebp        # ffffffff97d27c4d <__start_once>
+ffffffff81007637: 0f b6 2d 0f 06 d2 16 movzbl 0x16d2060f(%rip),%ebp        # ffffffff97d27c4d <__warned.54755>
 ffffffff8100763e: 31 ff                 xor    %edi,%edi
 ffffffff81007640: 89 ee                 mov    %ebp,%esi
 ffffffff81007642: e8 f9 91 54 00       callq  ffffffff81550840 <__sanitizer_cov_trace_const_cmp1>
@@ -8674,7 +8674,7 @@ ffffffff81007647: 40 84 ed
 ffffffff8100764a: 0f 85 fd fe ff ff     jne    ffffffff8100754d <syscall_return_slowpath+0x17d>
 ffffffff81007650: e8 1b 91 54 00       callq  ffffffff81550770 <__sanitizer_cov_trace_pc>
 ffffffff81007655: 48 c7 c7 40 6e 00 8c mov    $0xffffffff8c006e40,%rdi
-ffffffff8100765c: c6 05 ea 05 d2 16 01 movb   $0x1,0x16d205ea(%rip)        # ffffffff97d27c4d <__start_once>
+ffffffff8100765c: c6 05 ea 05 d2 16 01 movb   $0x1,0x16d205ea(%rip)        # ffffffff97d27c4d <__warned.54755>
 ffffffff81007663: e8 f4 f2 32 00       callq  ffffffff8133695c <__warn_printk>
 ffffffff81007668: 0f 0b                 ud2    
 ffffffff8100766a: e9 de fe ff ff       jmpq   ffffffff8100754d <syscall_return_slowpath+0x17d>
@@ -8915,7 +8915,7 @@ ffffffff81007a5a: e8 21 8e 54 00
 ffffffff81007a5f: 45 85 e4             test   %r12d,%r12d
 ffffffff81007a62: 0f 84 11 ff ff ff     je     ffffffff81007979 <do_syscall_64+0x249>
 ffffffff81007a68: e8 03 8d 54 00       callq  ffffffff81550770 <__sanitizer_cov_trace_pc>
-ffffffff81007a6d: 44 0f b6 25 d8 01 d2 movzbl 0x16d201d8(%rip),%r12d        # ffffffff97d27c4d <__start_once>
+ffffffff81007a6d: 44 0f b6 25 d8 01 d2 movzbl 0x16d201d8(%rip),%r12d        # ffffffff97d27c4d <__warned.54755>
 ffffffff81007a74: 16
 ffffffff81007a75: 31 ff                 xor    %edi,%edi
 ffffffff81007a77: 44 89 e6             mov    %r12d,%esi
@@ -8924,7 +8924,7 @@ ffffffff81007a7f: 45 84 e4
 ffffffff81007a82: 0f 85 f1 fe ff ff     jne    ffffffff81007979 <do_syscall_64+0x249>
 ffffffff81007a88: e8 e3 8c 54 00       callq  ffffffff81550770 <__sanitizer_cov_trace_pc>
 ffffffff81007a8d: 48 c7 c7 40 6e 00 8c mov    $0xffffffff8c006e40,%rdi
-ffffffff81007a94: c6 05 b2 01 d2 16 01 movb   $0x1,0x16d201b2(%rip)        # ffffffff97d27c4d <__start_once>
+ffffffff81007a94: c6 05 b2 01 d2 16 01 movb   $0x1,0x16d201b2(%rip)        # ffffffff97d27c4d <__warned.54755>
 ffffffff81007a9b: e8 bc ee 32 00       callq  ffffffff8133695c <__warn_printk>
 ffffffff81007aa0: 0f 0b                 ud2    
 ffffffff81007aa2: e9 d2 fe ff ff       jmpq   ffffffff81007979 <do_syscall_64+0x249>
@@ -9204,7 +9204,7 @@ ffffffff81007f34: e8 47 89 54 00
 ffffffff81007f39: 45 85 e4             test   %r12d,%r12d
 ffffffff81007f3c: 0f 84 11 ff ff ff     je     ffffffff81007e53 <do_int80_syscall_32+0x263>
 ffffffff81007f42: e8 29 88 54 00       callq  ffffffff81550770 <__sanitizer_cov_trace_pc>
-ffffffff81007f47: 44 0f b6 25 fe fc d1 movzbl 0x16d1fcfe(%rip),%r12d        # ffffffff97d27c4d <__start_once>
+ffffffff81007f47: 44 0f b6 25 fe fc d1 movzbl 0x16d1fcfe(%rip),%r12d        # ffffffff97d27c4d <__warned.54755>
 ffffffff81007f4e: 16
 ffffffff81007f4f: 31 ff                 xor    %edi,%edi
 ffffffff81007f51: 44 89 e6             mov    %r12d,%esi
@@ -9213,7 +9213,7 @@ ffffffff81007f59: 45 84 e4
 ffffffff81007f5c: 0f 85 f1 fe ff ff     jne    ffffffff81007e53 <do_int80_syscall_32+0x263>
 ffffffff81007f62: e8 09 88 54 00       callq  ffffffff81550770 <__sanitizer_cov_trace_pc>
 ffffffff81007f67: 48 c7 c7 40 6e 00 8c mov    $0xffffffff8c006e40,%rdi
-ffffffff81007f6e: c6 05 d8 fc d1 16 01 movb   $0x1,0x16d1fcd8(%rip)        # ffffffff97d27c4d <__start_once>
+ffffffff81007f6e: c6 05 d8 fc d1 16 01 movb   $0x1,0x16d1fcd8(%rip)        # ffffffff97d27c4d <__warned.54755>
 ffffffff81007f75: e8 e2 e9 32 00       callq  ffffffff8133695c <__warn_printk>
 ffffffff81007f7a: 0f 0b                 ud2    
 ffffffff81007f7c: e9 d2 fe ff ff       jmpq   ffffffff81007e53 <do_int80_syscall_32+0x263>
@@ -9518,7 +9518,7 @@ ffffffff81008477: e8 04 84 54 00
 ffffffff8100847c: 45 85 f6             test   %r14d,%r14d
 ffffffff8100847f: 0f 84 d6 fe ff ff     je     ffffffff8100835b <do_fast_syscall_32+0x2fb>
 ffffffff81008485: e8 e6 82 54 00       callq  ffffffff81550770 <__sanitizer_cov_trace_pc>
-ffffffff8100848a: 44 0f b6 35 bb f7 d1 movzbl 0x16d1f7bb(%rip),%r14d        # ffffffff97d27c4d <__start_once>
+ffffffff8100848a: 44 0f b6 35 bb f7 d1 movzbl 0x16d1f7bb(%rip),%r14d        # ffffffff97d27c4d <__warned.54755>
 ffffffff81008491: 16
 ffffffff81008492: 31 ff                 xor    %edi,%edi
 ffffffff81008494: 44 89 f6             mov    %r14d,%esi
@@ -9527,7 +9527,7 @@ ffffffff8100849c: 45 84 f6
 ffffffff8100849f: 0f 85 b6 fe ff ff     jne    ffffffff8100835b <do_fast_syscall_32+0x2fb>
 ffffffff810084a5: e8 c6 82 54 00       callq  ffffffff81550770 <__sanitizer_cov_trace_pc>
 ffffffff810084aa: 48 c7 c7 40 6e 00 8c mov    $0xffffffff8c006e40,%rdi
-ffffffff810084b1: c6 05 95 f7 d1 16 01 movb   $0x1,0x16d1f795(%rip)        # ffffffff97d27c4d <__start_once>
+ffffffff810084b1: c6 05 95 f7 d1 16 01 movb   $0x1,0x16d1f795(%rip)        # ffffffff97d27c4d <__warned.54755>
 ffffffff810084b8: e8 9f e4 32 00       callq  ffffffff8133695c <__warn_printk>
 ffffffff810084bd: 0f 0b                 ud2    
 ffffffff810084bf: e9 97 fe ff ff       jmpq   ffffffff8100835b <do_fast_syscall_32+0x2fb>
@@ -9651,7 +9651,7 @@ ffffffff810086d2: e8 a9 81 54 00
 ffffffff810086d7: 85 ed                 test   %ebp,%ebp
 ffffffff810086d9: 74 34                 je     ffffffff8100870f <do_fast_syscall_32+0x6af>
 ffffffff810086db: e8 90 80 54 00       callq  ffffffff81550770 <__sanitizer_cov_trace_pc>
-ffffffff810086e0: 0f b6 2d 66 f5 d1 16 movzbl 0x16d1f566(%rip),%ebp        # ffffffff97d27c4d <__start_once>
+ffffffff810086e0: 0f b6 2d 66 f5 d1 16 movzbl 0x16d1f566(%rip),%ebp        # ffffffff97d27c4d <__warned.54755>
 ffffffff810086e7: 31 ff                 xor    %edi,%edi
 ffffffff810086e9: 89 ee                 mov    %ebp,%esi
 ffffffff810086eb: e8 50 81 54 00       callq  ffffffff81550840 <__sanitizer_cov_trace_const_cmp1>
@@ -9659,7 +9659,7 @@ ffffffff810086f0: 40 84 ed
 ffffffff810086f3: 75 1a                 jne    ffffffff8100870f <do_fast_syscall_32+0x6af>
 ffffffff810086f5: e8 76 80 54 00       callq  ffffffff81550770 <__sanitizer_cov_trace_pc>
 ffffffff810086fa: 48 c7 c7 40 6e 00 8c mov    $0xffffffff8c006e40,%rdi
-ffffffff81008701: c6 05 45 f5 d1 16 01 movb   $0x1,0x16d1f545(%rip)        # ffffffff97d27c4d <__start_once>
+ffffffff81008701: c6 05 45 f5 d1 16 01 movb   $0x1,0x16d1f545(%rip)        # ffffffff97d27c4d <__warned.54755>
 ffffffff81008708: e8 4f e2 32 00       callq  ffffffff8133695c <__warn_printk>
 ffffffff8100870d: 0f 0b                 ud2    
 ffffffff8100870f: e8 5c 80 54 00       callq  ffffffff81550770 <__sanitizer_cov_trace_pc>
@@ -830381,7 +830381,7 @@ ffffffff8133eb46: ba cd 00 00 00
 ffffffff8133eb4b: be 01 00 00 00       mov    $0x1,%esi
 ffffffff8133eb50: 89 df                 mov    %ebx,%edi
 ffffffff8133eb52: e8 b9 df ff ff       callq  ffffffff8133cb10 <_cpu_up>
-ffffffff8133eb57: 48 8b 3d c2 dc c5 16 mov    0x16c5dcc2(%rip),%rdi        # ffffffff97f9c820 <__start___tracepoint_str>
+ffffffff8133eb57: 48 8b 3d c2 dc c5 16 mov    0x16c5dcc2(%rip),%rdi        # ffffffff97f9c820 <___tp_str.62140>
 ffffffff8133eb5e: 31 d2                 xor    %edx,%edx
 ffffffff8133eb60: 89 de                 mov    %ebx,%esi
 ffffffff8133eb62: 89 c5                 mov    %eax,%ebp
@@ -1063543,7 +1063543,7 @@ ffffffff81426945: e8 d6 b3 42 00
 ffffffff8142694a: 49 8b 45 18           mov    0x18(%r13),%rax
 ffffffff8142694e: e8 8d dc 9d 0a       callq  ffffffff8be045e0 <__x86_indirect_thunk_rax>
 ffffffff81426953: e8 18 9e 12 00       callq  ffffffff81550770 <__sanitizer_cov_trace_pc>
-ffffffff81426958: 44 8b 2d a1 96 e0 19 mov    0x19e096a1(%rip),%r13d        # ffffffff9b230000 <__smp_locks_end>
+ffffffff81426958: 44 8b 2d a1 96 e0 19 mov    0x19e096a1(%rip),%r13d        # ffffffff9b230000 <in_suspend>
 ffffffff8142695f: 31 ff                 xor    %edi,%edi
 ffffffff81426961: 44 89 ee             mov    %r13d,%esi
 ffffffff81426964: e8 17 9f 12 00       callq  ffffffff81550880 <__sanitizer_cov_trace_const_cmp4>
@@ -1063631,7 +1063631,7 @@ ffffffff81426adf: e8 5c 9d 12 00
 ffffffff81426ae4: 45 84 ed             test   %r13b,%r13b
 ffffffff81426ae7: 0f 85 93 01 00 00     jne    ffffffff81426c80 <hibernation_snapshot+0x580>
 ffffffff81426aed: e8 7e 9c 12 00       callq  ffffffff81550770 <__sanitizer_cov_trace_pc>
-ffffffff81426af2: c7 05 04 95 e0 19 01 movl   $0x1,0x19e09504(%rip)        # ffffffff9b230000 <__smp_locks_end>
+ffffffff81426af2: c7 05 04 95 e0 19 01 movl   $0x1,0x19e09504(%rip)        # ffffffff9b230000 <in_suspend>
 ffffffff81426af9: 00 00 00
 ffffffff81426afc: e8 df df 55 09       callq  ffffffff8a984ae0 <save_processor_state>
 ffffffff81426b01: 0f 1f 44 00 00       nopl   0x0(%rax,%rax,1)
@@ -1063703,7 +1063703,7 @@ ffffffff81426c19: e8 62 9c 12 00
 ffffffff81426c1e: 45 85 e4             test   %r12d,%r12d
 ffffffff81426c21: 0f 85 f2 13 00 00     jne    ffffffff81428019 <hibernation_snapshot.cold.5+0x4d>
 ffffffff81426c27: e8 44 9b 12 00       callq  ffffffff81550770 <__sanitizer_cov_trace_pc>
-ffffffff81426c2c: 44 8b 2d cd 93 e0 19 mov    0x19e093cd(%rip),%r13d        # ffffffff9b230000 <__smp_locks_end>
+ffffffff81426c2c: 44 8b 2d cd 93 e0 19 mov    0x19e093cd(%rip),%r13d        # ffffffff9b230000 <in_suspend>
 ffffffff81426c33: 31 ff                 xor    %edi,%edi
 ffffffff81426c35: 44 89 ee             mov    %r13d,%esi
 ffffffff81426c38: e8 43 9c 12 00       callq  ffffffff81550880 <__sanitizer_cov_trace_const_cmp4>
@@ -1063741,7 +1063741,7 @@ ffffffff81426cc4: e8 a7 9a 12 00
 ffffffff81426cc9: ff 14 25 10 22 19 93 callq  *0xffffffff93192210
 ffffffff81426cd0: e8 9b 9a 12 00       callq  ffffffff81550770 <__sanitizer_cov_trace_pc>
 ffffffff81426cd5: e8 46 6c f1 ff       callq  ffffffff8133d920 <enable_nonboot_cpus>
-ffffffff81426cda: 44 8b 2d 1f 93 e0 19 mov    0x19e0931f(%rip),%r13d        # ffffffff9b230000 <__smp_locks_end>
+ffffffff81426cda: 44 8b 2d 1f 93 e0 19 mov    0x19e0931f(%rip),%r13d        # ffffffff9b230000 <in_suspend>
 ffffffff81426ce1: 31 ff                 xor    %edi,%edi
 ffffffff81426ce3: 44 89 ee             mov    %r13d,%esi
 ffffffff81426ce6: e8 95 9b 12 00       callq  ffffffff81550880 <__sanitizer_cov_trace_const_cmp4>
@@ -1063790,7 +1063790,7 @@ ffffffff81426d96: e8 e5 9a 12 00
 ffffffff81426d9b: 45 85 e4             test   %r12d,%r12d
 ffffffff81426d9e: 0f 85 8d 00 00 00     jne    ffffffff81426e31 <hibernation_snapshot+0x731>
 ffffffff81426da4: e8 c7 99 12 00       callq  ffffffff81550770 <__sanitizer_cov_trace_pc>
-ffffffff81426da9: 44 8b 25 50 92 e0 19 mov    0x19e09250(%rip),%r12d        # ffffffff9b230000 <__smp_locks_end>
+ffffffff81426da9: 44 8b 25 50 92 e0 19 mov    0x19e09250(%rip),%r12d        # ffffffff9b230000 <in_suspend>
 ffffffff81426db0: 31 ff                 xor    %edi,%edi
 ffffffff81426db2: 44 89 e6             mov    %r12d,%esi
 ffffffff81426db5: e8 c6 9a 12 00       callq  ffffffff81550880 <__sanitizer_cov_trace_const_cmp4>
@@ -1063798,7 +1063798,7 @@ ffffffff81426dba: 45 85 e4
 ffffffff81426dbd: 0f 85 c8 00 00 00     jne    ffffffff81426e8b <hibernation_snapshot+0x78b>
 ffffffff81426dc3: e8 a8 99 12 00       callq  ffffffff81550770 <__sanitizer_cov_trace_pc>
 ffffffff81426dc8: e8 c3 34 00 00       callq  ffffffff8142a290 <swsusp_free>
-ffffffff81426dcd: 44 8b 25 2c 92 e0 19 mov    0x19e0922c(%rip),%r12d        # ffffffff9b230000 <__smp_locks_end>
+ffffffff81426dcd: 44 8b 25 2c 92 e0 19 mov    0x19e0922c(%rip),%r12d        # ffffffff9b230000 <in_suspend>
 ffffffff81426dd4: 31 ff                 xor    %edi,%edi
 ffffffff81426dd6: 44 89 e6             mov    %r12d,%esi
 ffffffff81426dd9: e8 a2 9a 12 00       callq  ffffffff81550880 <__sanitizer_cov_trace_const_cmp4>
@@ -1063812,7 +1063812,7 @@ ffffffff81426dfc: 31 f6
 ffffffff81426dfe: 31 ff                 xor    %edi,%edi
 ffffffff81426e00: e8 7b 9a 12 00       callq  ffffffff81550880 <__sanitizer_cov_trace_const_cmp4>
 ffffffff81426e05: e8 66 99 12 00       callq  ffffffff81550770 <__sanitizer_cov_trace_pc>
-ffffffff81426e0a: 44 8b 25 ef 91 e0 19 mov    0x19e091ef(%rip),%r12d        # ffffffff9b230000 <__smp_locks_end>
+ffffffff81426e0a: 44 8b 25 ef 91 e0 19 mov    0x19e091ef(%rip),%r12d        # ffffffff9b230000 <in_suspend>
 ffffffff81426e11: 31 ff                 xor    %edi,%edi
 ffffffff81426e13: 44 89 e6             mov    %r12d,%esi
 ffffffff81426e16: e8 65 9a 12 00       callq  ffffffff81550880 <__sanitizer_cov_trace_const_cmp4>
@@ -1063825,7 +1063825,7 @@ ffffffff81426e2a: 31 ff
 ffffffff81426e2c: e8 4f 9a 12 00       callq  ffffffff81550880 <__sanitizer_cov_trace_const_cmp4>
 ffffffff81426e31: e8 3a 99 12 00       callq  ffffffff81550770 <__sanitizer_cov_trace_pc>
 ffffffff81426e36: e8 55 34 00 00       callq  ffffffff8142a290 <swsusp_free>
-ffffffff81426e3b: 8b 1d bf 91 e0 19     mov    0x19e091bf(%rip),%ebx        # ffffffff9b230000 <__smp_locks_end>
+ffffffff81426e3b: 8b 1d bf 91 e0 19     mov    0x19e091bf(%rip),%ebx        # ffffffff9b230000 <in_suspend>
 ffffffff81426e41: 31 ff                 xor    %edi,%edi
 ffffffff81426e43: 89 de                 mov    %ebx,%esi
 ffffffff81426e45: e8 36 9a 12 00       callq  ffffffff81550880 <__sanitizer_cov_trace_const_cmp4>
@@ -1064932,7 +1064932,7 @@ ffffffff81427fcc: e8 9f 87 12 00
 ffffffff81427fd1: 48 c7 c7 60 f5 10 8c mov    $0xffffffff8c10f560,%rdi
 ffffffff81427fd8: e8 b1 3a 01 00       callq  ffffffff8143ba8e <printk>
 ffffffff81427fdd: e8 ae 22 00 00       callq  ffffffff8142a290 <swsusp_free>
-ffffffff81427fe2: 8b 1d 18 80 e0 19     mov    0x19e08018(%rip),%ebx        # ffffffff9b230000 <__smp_locks_end>
+ffffffff81427fe2: 8b 1d 18 80 e0 19     mov    0x19e08018(%rip),%ebx        # ffffffff9b230000 <in_suspend>
 ffffffff81427fe8: 31 ff                 xor    %edi,%edi
 ffffffff81427fea: 89 de                 mov    %ebx,%esi
 ffffffff81427fec: e8 8f 88 12 00       callq  ffffffff81550880 <__sanitizer_cov_trace_const_cmp4>
@@ -1065208,7 +1065208,7 @@ ffffffff81428423: e8 18 84 12 00
 ffffffff81428428: 45 84 e4             test   %r12b,%r12b
 ffffffff8142842b: 75 d3                 jne    ffffffff81428400 <hibernate.cold.8+0xf2>
 ffffffff8142842d: e8 3e 83 12 00       callq  ffffffff81550770 <__sanitizer_cov_trace_pc>
-ffffffff81428432: 8b 2d c8 7b e0 19     mov    0x19e07bc8(%rip),%ebp        # ffffffff9b230000 <__smp_locks_end>
+ffffffff81428432: 8b 2d c8 7b e0 19     mov    0x19e07bc8(%rip),%ebp        # ffffffff9b230000 <in_suspend>
 ffffffff81428438: 31 ff                 xor    %edi,%edi
 ffffffff8142843a: 89 ee                 mov    %ebp,%esi
 ffffffff8142843c: e8 3f 84 12 00       callq  ffffffff81550880 <__sanitizer_cov_trace_const_cmp4>
@@ -1065251,7 +1065251,7 @@ ffffffff814284d3: e8 a8 83 12 00
 ffffffff814284d8: 41 83 fc 05           cmp    $0x5,%r12d
 ffffffff814284dc: 0f 85 8b 00 00 00     jne    ffffffff8142856d <hibernate.cold.8+0x25f>
 ffffffff814284e2: e8 89 82 12 00       callq  ffffffff81550770 <__sanitizer_cov_trace_pc>
-ffffffff814284e7: c7 05 0f 7b e0 19 00 movl   $0x0,0x19e07b0f(%rip)        # ffffffff9b230000 <__smp_locks_end>
+ffffffff814284e7: c7 05 0f 7b e0 19 00 movl   $0x0,0x19e07b0f(%rip)        # ffffffff9b230000 <in_suspend>
 ffffffff814284ee: 00 00 00
 ffffffff814284f1: e8 0a de 3b 00       callq  ffffffff817e6300 <pm_restore_gfp_mask>
 ffffffff814284f6: e8 45 1a 00 00       callq  ffffffff81429f40 <free_basic_memory_bitmaps>
@@ -1065309,7 +1065309,7 @@ ffffffff814285c4: e8 a7 81 12 00
 ffffffff814285c9: 48 c7 c7 a0 fc 10 8c mov    $0xffffffff8c10fca0,%rdi
 ffffffff814285d0: e8 b9 34 01 00       callq  ffffffff8143ba8e <printk>
 ffffffff814285d5: e8 96 81 12 00       callq  ffffffff81550770 <__sanitizer_cov_trace_pc>
-ffffffff814285da: c7 05 1c 7a e0 19 00 movl   $0x0,0x19e07a1c(%rip)        # ffffffff9b230000 <__smp_locks_end>
+ffffffff814285da: c7 05 1c 7a e0 19 00 movl   $0x0,0x19e07a1c(%rip)        # ffffffff9b230000 <in_suspend>
 ffffffff814285e1: 00 00 00
 ffffffff814285e4: e8 17 dd 3b 00       callq  ffffffff817e6300 <pm_restore_gfp_mask>
 ffffffff814285e9: e8 52 19 00 00       callq  ffffffff81429f40 <free_basic_memory_bitmaps>
@@ -1074738,7 +1074738,7 @@ ffffffff81431916: 48 c7 c7 e0 15 11 8c
 ffffffff8143191d: e8 7e 5d 36 00       callq  ffffffff817976a0 <__might_fault>
 ffffffff81431922: 48 c7 c7 00 00 23 9b mov    $0xffffffff9b230000,%rdi
 ffffffff81431929: e8 c2 02 42 00       callq  ffffffff81851bf0 <__asan_load4>
-ffffffff8143192e: 8b 05 cc e6 df 19     mov    0x19dfe6cc(%rip),%eax        # ffffffff9b230000 <__smp_locks_end>
+ffffffff8143192e: 8b 05 cc e6 df 19     mov    0x19dfe6cc(%rip),%eax        # ffffffff9b230000 <in_suspend>
 ffffffff81431934: 4c 89 f1             mov    %r14,%rcx
 ffffffff81431937: e8 64 78 63 0a       callq  ffffffff8ba691a0 <__put_user_4>
 ffffffff8143193c: 48 c7 c7 20 d3 d7 9b mov    $0xffffffff9bd7d320,%rdi
@@ -1453099,7 +1453099,7 @@ ffffffff815a53e1: 48 83 05 6f 8f 92 1a
 ffffffff815a53e8: 01
 ffffffff815a53e9: eb a7                 jmp    ffffffff815a5392 <ring_buffer_producer_thread+0x1e2>
 ffffffff815a53eb: e8 80 b3 fa ff       callq  ffffffff81550770 <__sanitizer_cov_trace_pc>
-ffffffff815a53f0: 48 8b 1d b1 a4 9d 16 mov    0x169da4b1(%rip),%rbx        # ffffffff97f7f8a8 <__start___trace_bprintk_fmt>
+ffffffff815a53f0: 48 8b 1d b1 a4 9d 16 mov    0x169da4b1(%rip),%rbx        # ffffffff97f7f8a8 <trace_printk_fmt.34335>
 ffffffff815a53f7: 48 83 05 69 8f 92 1a addq   $0x1,0x1a928f69(%rip)        # ffffffff9bece368 <__gcov0.ring_buffer_producer_thread+0x48>
 ffffffff815a53fe: 01
 ffffffff815a53ff: e8 6c b3 fa ff       callq  ffffffff81550770 <__sanitizer_cov_trace_pc>
@@ -14087627,7 +14087627,7 @@ ffffffff84717f2c: 74 3f
 ffffffff84717f2e: e8 3d 88 e3 fc       callq  ffffffff81550770 <__sanitizer_cov_trace_pc>
 ffffffff84717f33: 48 8d 7b 08           lea    0x8(%rbx),%rdi
 ffffffff84717f37: e8 e4 9d 13 fd       callq  ffffffff81851d20 <__asan_load8>
-ffffffff84717f3c: 48 3b 2d d5 2f 67 0e cmp    0xe672fd5(%rip),%rbp        # ffffffff92d8af18 <__end_pci_fixups_suspend_late+0x8>
+ffffffff84717f3c: 48 3b 2d d5 2f 67 0e cmp    0xe672fd5(%rip),%rbp        # ffffffff92d8af18 <__end_builtin_fw+0x8>
 ffffffff84717f43: 75 16                 jne    ffffffff84717f5b <release_firmware+0x6b>
 ffffffff84717f45: eb 4c                 jmp    ffffffff84717f93 <release_firmware+0xa3>
 ffffffff84717f47: e8 24 88 e3 fc       callq  ffffffff81550770 <__sanitizer_cov_trace_pc>
@@ -39093978,7 +39093978,7 @@ ffffffff8a987066: ff b0 90 00 00 00
 ffffffff8a98706c: 9d                   popfq  
 ffffffff8a98706d: 0f 01 90 0b 01 00 00 lgdt   0x10b(%rax)
 ffffffff8a987074: 31 c0                 xor    %eax,%eax
-ffffffff8a987076: 48 89 05 83 8f 8a 10 mov    %rax,0x108a8f83(%rip)        # ffffffff9b230000 <__smp_locks_end>
+ffffffff8a987076: 48 89 05 83 8f 8a 10 mov    %rax,0x108a8f83(%rip)        # ffffffff9b230000 <in_suspend>
 ffffffff8a98707d: c3                   retq  
 ffffffff8a98707e: 90                   nop
 ffffffff8a98707f: 90                   nop
@@ -43314730,7 +43314730,7 @@ ffffffff8ba3324a: 73 5f
 ffffffff8ba3324c: e8 1f d5 b1 f5       callq  ffffffff81550770 <__sanitizer_cov_trace_pc>
 ffffffff8ba33251: 48 89 df             mov    %rbx,%rdi
 ffffffff8ba33254: e8 97 e9 e1 f5       callq  ffffffff81851bf0 <__asan_load4>
-ffffffff8ba33259: 48 63 2d a0 8d 59 0c movslq 0xc598da0(%rip),%rbp        # ffffffff97fcc000 <_edata>
+ffffffff8ba33259: 48 63 2d a0 8d 59 0c movslq 0xc598da0(%rip),%rbp        # ffffffff97fcc000 <__start___bug_table>
 ffffffff8ba33260: 48 81 c5 00 c0 fc 97 add    $0xffffffff97fcc000,%rbp
 ffffffff8ba33267: eb 25                 jmp    ffffffff8ba3328e <find_bug+0x5e>
 ffffffff8ba33269: e8 02 d5 b1 f5       callq  ffffffff81550770 <__sanitizer_cov_trace_pc>
@@ -43314792,7 +43314792,7 @@ ffffffff8ba33317: 73 5e
 ffffffff8ba33319: e8 52 d4 b1 f5       callq  ffffffff81550770 <__sanitizer_cov_trace_pc>
 ffffffff8ba3331e: 48 89 df             mov    %rbx,%rdi
 ffffffff8ba33321: e8 ca e8 e1 f5       callq  ffffffff81851bf0 <__asan_load4>
-ffffffff8ba33326: 4c 63 25 d3 8c 59 0c movslq 0xc598cd3(%rip),%r12        # ffffffff97fcc000 <_edata>
+ffffffff8ba33326: 4c 63 25 d3 8c 59 0c movslq 0xc598cd3(%rip),%r12        # ffffffff97fcc000 <__start___bug_table>
 ffffffff8ba3332d: 48 89 ee             mov    %rbp,%rsi
 ffffffff8ba33330: 49 01 dc             add    %rbx,%r12
 ffffffff8ba33333: 4c 89 e7             mov    %r12,%rdi
@@ -47107344,7 +47107344,7 @@ ffffffff9a8e6969: 49 29 c6
 ffffffff9a8e696c: eb 06                 jmp    ffffffff9a8e6974 <sme_encrypt_kernel+0x8c>
 ffffffff9a8e696e: 45 31 f6             xor    %r14d,%r14d
 ffffffff9a8e6971: 45 31 e4             xor    %r12d,%r12d
-ffffffff9a8e6974: 4c 8d 2d 85 96 11 05 lea    0x5119685(%rip),%r13        # ffffffff9fa00000 <__init_scratch_begin>
+ffffffff9a8e6974: 4c 8d 2d 85 96 11 05 lea    0x5119685(%rip),%r13        # ffffffff9fa00000 <sme_workarea>
 ffffffff9a8e697b: 4d 8d 8d 00 20 20 00 lea    0x202000(%r13),%r9
 ffffffff9a8e6982: 4c 89 cf             mov    %r9,%rdi
 ffffffff9a8e6985: 4c 29 ff             sub    %r15,%rdi
@@ -47281567,7 +47281567,7 @@ ffffffff9a98dd0d: 45 31 f6
 ffffffff9a98dd10: 45 31 e4             xor    %r12d,%r12d
 ffffffff9a98dd13: 45 31 ed             xor    %r13d,%r13d
 ffffffff9a98dd16: e8 05 40 ec e6       callq  ffffffff81851d20 <__asan_load8>
-ffffffff9a98dd1b: 48 8b 15 0e 43 3d fd mov    -0x2c2bcf2(%rip),%rdx        # ffffffff97d62030 <__start___verbose>
+ffffffff9a98dd1b: 48 8b 15 0e 43 3d fd mov    -0x2c2bcf2(%rip),%rdx        # ffffffff97d62030 <__UNIQUE_ID_ddebug471.65517>
 ffffffff9a98dd22: 4c 89 fb             mov    %r15,%rbx
 ffffffff9a98dd25: c7 44 24 04 00 00 00 movl   $0x0,0x4(%rsp)
 ffffffff9a98dd2c: 00

--
Regards/Gruss,
    Boris.

SUSE Software Solutions Germany GmbH, GF: Felix Imendörffer, HRB 36809, AG Nürnberg
Reply | Threaded
Open this post in threaded view
|

Prefer object over notype symbols when disassembling

Alan Modra-3
On Mon, Dec 16, 2019 at 05:14:24PM +0100, Borislav Petkov wrote:
> On Mon, Dec 16, 2019 at 04:29:23PM +1030, Alan Modra wrote:
> > I see.  Would you mind testing the following patch?  I think it should
> > do as you want for OBJECT symbols, and fixes some other bugs I noticed.
>
> Yes, it does. Diffing objdump output of an allyesconfig kernel with
> and without this patch gives the diff below and from looking at the
> different spots in the code, now the symbol name referenced is the
> correct one.

This is the patch I'm about to commit
----

Changing objdump disassembly output like this always requires some
testsuite changes, with the avr and x64_64 changes simply due to
picking up better symbols, the whole point of the patch.

The mips changes are due to mips-sgi-irix changing STT_NOTYPE symbols
to STT_OBJECT, which objdump now chooses in preference to script
symbols.  The problem is that objdump looks at the first symbol in the
section being disassembled, and if object type, just dumps out bytes
rather than disassembling.  This results in new failures:

FAIL: JAL overflow 2
FAIL: undefined weak symbol overflow
FAIL: undefined weak symbol overflow (n32)
FAIL: undefined weak symbol overflow (n64)

So for mips-sgi-irix function symbols really do need to be function
type.  I fixed a few more than just the required minimum to avoid the
above test fails.

binutils/
        * objdump.c (compare_section): New static var.
        (compare_symbols): Sort by current section only.  Don't access
        symbol name out of bounds when checking for file symbols.
        Sort section symbols and object symbols.
        (find_symbol_for_address): Remove bogus debugging and section
        symbol test.
        (disassemble_data): Move symbol sort from here..
        (disassemble_section): ..to here.  Set compare_section.
ld/
        * testsuite/ld-avr/lds-mega.d: Adjust symbols to suit objdump change.
        * testsuite/ld-avr/lds-tiny.d: Likewise.
        * testsuite/ld-x86-64/load2.d: Likewise.
        * testsuite/ld-mips-elf/compact-eh1.s: Give function symbols
        function type.
        * testsuite/ld-mips-elf/compact-eh1a.s: Likewise.
        * testsuite/ld-mips-elf/compact-eh1b.s: Likewise.
        * testsuite/ld-mips-elf/compact-eh2.s: Likewise.
        * testsuite/ld-mips-elf/compact-eh3.s: Likewise.
        * testsuite/ld-mips-elf/compact-eh3a.s: Likewise.
        * testsuite/ld-mips-elf/eh-frame5.s: Likewise.
        * testsuite/ld-mips-elf/ehdr_start-new.s: Likewise.
        * testsuite/ld-mips-elf/ehdr_start-o32.s: Likewise.
        * testsuite/ld-mips-elf/emit-relocs-1a.s: Likewise.
        * testsuite/ld-mips-elf/jaloverflow-2.s: Likewise.
        * testsuite/ld-mips-elf/jaloverflow.s: Likewise.
        * testsuite/ld-mips-elf/mips16-call-global-1.s: Likewise.
        * testsuite/ld-mips-elf/mips16-intermix-1.s: Likewise.
        * testsuite/ld-mips-elf/mips16-pic-1b.s: Likewise.
        * testsuite/ld-mips-elf/mips16-pic-4c.s: Likewise.
        * testsuite/ld-mips-elf/no-shared-1-n64.s: Likewise.
        * testsuite/ld-mips-elf/no-shared-1-o32.s: Likewise.
        * testsuite/ld-mips-elf/pic-and-nonpic-1b-micromips.s: Likewise.
        * testsuite/ld-mips-elf/pic-and-nonpic-1b.s: Likewise.
        * testsuite/ld-mips-elf/pic-and-nonpic-2a.s: Likewise.
        * testsuite/ld-mips-elf/pic-and-nonpic-3b.s: Likewise.
        * testsuite/ld-mips-elf/pic-and-nonpic-4b.s: Likewise.
        * testsuite/ld-mips-elf/pic-and-nonpic-5a.s: Likewise.
        * testsuite/ld-mips-elf/pic-and-nonpic-6-n32c.s: Likewise.
        * testsuite/ld-mips-elf/pic-and-nonpic-6-n64c.s: Likewise.
        * testsuite/ld-mips-elf/pic-and-nonpic-6-o32c.s: Likewise.
        * testsuite/ld-mips-elf/pie.s: Likewise.
        * testsuite/ld-mips-elf/relax-jalr.s: Likewise.
        * testsuite/ld-mips-elf/reloc-1a.s: Likewise.
        * testsuite/ld-mips-elf/reloc-2a.s: Likewise.
        * testsuite/ld-mips-elf/reloc-4.s: Likewise.
        * testsuite/ld-mips-elf/reloc-5.s: Likewise.
        * testsuite/ld-mips-elf/reloc-6b.s: Likewise.
        * testsuite/ld-mips-elf/textrel-1.s: Likewise.
        * testsuite/ld-mips-elf/undefweak-overflow.s: Likewise.
        * testsuite/ld-mips-elf/undefweak-overflow.d: Adjust.

diff --git a/binutils/objdump.c b/binutils/objdump.c
index c10136edc3..3cc7aec187 100644
--- a/binutils/objdump.c
+++ b/binutils/objdump.c
@@ -803,6 +803,8 @@ remove_useless_symbols (asymbol **symbols, long count)
   return out_ptr - symbols;
 }
 
+static const asection *compare_section;
+
 /* Sort symbols into value order.  */
 
 static int
@@ -814,8 +816,7 @@ compare_symbols (const void *ap, const void *bp)
   const char *bn;
   size_t anl;
   size_t bnl;
-  bfd_boolean af;
-  bfd_boolean bf;
+  bfd_boolean as, af, bs, bf;
   flagword aflags;
   flagword bflags;
 
@@ -824,10 +825,16 @@ compare_symbols (const void *ap, const void *bp)
   else if (bfd_asymbol_value (a) < bfd_asymbol_value (b))
     return -1;
 
-  if (a->section > b->section)
-    return 1;
-  else if (a->section < b->section)
+  /* Prefer symbols from the section currently being disassembled.
+     Don't sort symbols from other sections by section, since there
+     isn't much reason to prefer one section over another otherwise.
+     See sym_ok comment for why we compare by section name.  */
+  as = strcmp (compare_section->name, a->section->name) == 0;
+  bs = strcmp (compare_section->name, b->section->name) == 0;
+  if (as && !bs)
     return -1;
+  if (!as && bs)
+    return 1;
 
   an = bfd_asymbol_name (a);
   bn = bfd_asymbol_name (b);
@@ -853,7 +860,8 @@ compare_symbols (const void *ap, const void *bp)
 
 #define file_symbol(s, sn, snl) \
   (((s)->flags & BSF_FILE) != 0 \
-   || ((sn)[(snl) - 2] == '.' \
+   || ((snl) > 2 \
+       && (sn)[(snl) - 2] == '.' \
        && ((sn)[(snl) - 1] == 'o' \
    || (sn)[(snl) - 1] == 'a')))
 
@@ -865,8 +873,8 @@ compare_symbols (const void *ap, const void *bp)
   if (! af && bf)
     return -1;
 
-  /* Try to sort global symbols before local symbols before function
-     symbols before debugging symbols.  */
+  /* Sort function and object symbols before global symbols before
+     local symbols before section symbols before debugging symbols.  */
 
   aflags = a->flags;
   bflags = b->flags;
@@ -878,6 +886,13 @@ compare_symbols (const void *ap, const void *bp)
       else
  return -1;
     }
+  if ((aflags & BSF_SECTION_SYM) != (bflags & BSF_SECTION_SYM))
+    {
+      if ((aflags & BSF_SECTION_SYM) != 0)
+ return 1;
+      else
+ return -1;
+    }
   if ((aflags & BSF_FUNCTION) != (bflags & BSF_FUNCTION))
     {
       if ((aflags & BSF_FUNCTION) != 0)
@@ -885,6 +900,13 @@ compare_symbols (const void *ap, const void *bp)
       else
  return 1;
     }
+  if ((aflags & BSF_OBJECT) != (bflags & BSF_OBJECT))
+    {
+      if ((aflags & BSF_OBJECT) != 0)
+ return -1;
+      else
+ return 1;
+    }
   if ((aflags & BSF_LOCAL) != (bflags & BSF_LOCAL))
     {
       if ((aflags & BSF_LOCAL) != 0)
@@ -1102,14 +1124,11 @@ find_symbol_for_address (bfd_vma vma,
 
   /* The symbol we want is now in min, the low end of the range we
      were searching.  If there are several symbols with the same
-     value, we want the first (non-section/non-debugging) one.  */
+     value, we want the first one.  */
   thisplace = min;
   while (thisplace > 0
  && (bfd_asymbol_value (sorted_syms[thisplace])
-     == bfd_asymbol_value (sorted_syms[thisplace - 1]))
- && ((sorted_syms[thisplace - 1]->flags
-      & (BSF_SECTION_SYM | BSF_DEBUGGING)) == 0)
- )
+     == bfd_asymbol_value (sorted_syms[thisplace - 1])))
     --thisplace;
 
   /* Prefer a symbol in the current section if we have multple symbols
@@ -2389,6 +2408,10 @@ disassemble_section (bfd *abfd, asection *section, void *inf)
   pinfo->buffer_length = datasize;
   pinfo->section = section;
 
+  /* Sort the symbols into value and section order.  */
+  compare_section = section;
+  qsort (sorted_syms, sorted_symcount, sizeof (asymbol *), compare_symbols);
+
   /* Skip over the relocs belonging to addresses below the
      start address.  */
   while (rel_pp < rel_ppend
@@ -2632,9 +2655,6 @@ disassemble_data (bfd *abfd)
       ++sorted_symcount;
     }
 
-  /* Sort the symbols into section and symbol order.  */
-  qsort (sorted_syms, sorted_symcount, sizeof (asymbol *), compare_symbols);
-
   init_disassemble_info (&disasm_info, stdout, (fprintf_ftype) fprintf);
 
   disasm_info.application_data = (void *) &aux;
diff --git a/ld/testsuite/ld-avr/lds-mega.d b/ld/testsuite/ld-avr/lds-mega.d
index 078bf73807..1537b8f752 100644
--- a/ld/testsuite/ld-avr/lds-mega.d
+++ b/ld/testsuite/ld-avr/lds-mega.d
@@ -11,7 +11,7 @@
 Disassembly of section .text:
 
 00000000 <main>:
-   0: 80 91 00 01 lds r24, 0x0100 ; 0x800100 <_edata>
+   0: 80 91 00 01 lds r24, 0x0100 ; 0x800100 <myvar1>
    4: 08 2e       mov r0, r24
    6: 00 0c       add r0, r0
    8: 99 0b       sbc r25, r25
diff --git a/ld/testsuite/ld-avr/lds-tiny.d b/ld/testsuite/ld-avr/lds-tiny.d
index 405546ad0a..957606f89f 100644
--- a/ld/testsuite/ld-avr/lds-tiny.d
+++ b/ld/testsuite/ld-avr/lds-tiny.d
@@ -11,7 +11,7 @@
 Disassembly of section .text:
 
 00000000 <main>:
-   0: 20 a1       lds r18, 0x40 ; 0x800040 <_edata>
+   0: 20 a1       lds r18, 0x40 ; 0x800040 <myvar1>
    2: 42 a1       lds r20, 0x42 ; 0x800042 <myvar2\+0x1>
    4: 53 a1       lds r21, 0x43 ; 0x800043 <_end>
    6: 08 95       ret
diff --git a/ld/testsuite/ld-mips-elf/compact-eh1.s b/ld/testsuite/ld-mips-elf/compact-eh1.s
index 941ac8f447..81c3008674 100644
--- a/ld/testsuite/ld-mips-elf/compact-eh1.s
+++ b/ld/testsuite/ld-mips-elf/compact-eh1.s
@@ -6,6 +6,7 @@
  .cfi_personality_id 0x2
  .cfi_lsda 0x1b,.LLSDA3
  .global main
+ .type main, @function
 main:
 .LEHB0 = .
  jal compact1a
diff --git a/ld/testsuite/ld-mips-elf/compact-eh1a.s b/ld/testsuite/ld-mips-elf/compact-eh1a.s
index 3f5c7ec086..3b12bfec00 100644
--- a/ld/testsuite/ld-mips-elf/compact-eh1a.s
+++ b/ld/testsuite/ld-mips-elf/compact-eh1a.s
@@ -1,6 +1,7 @@
  .cfi_sections .eh_frame_entry
  .section .text.compact1a,"ax",@progbits
- .globl compact1a
+ .globl compact1a
+ .type compact1a, @function
  .cfi_startproc
 compact1a:
  sw $2,16($fp)
diff --git a/ld/testsuite/ld-mips-elf/compact-eh1b.s b/ld/testsuite/ld-mips-elf/compact-eh1b.s
index e96289a81e..1aabe5f906 100644
--- a/ld/testsuite/ld-mips-elf/compact-eh1b.s
+++ b/ld/testsuite/ld-mips-elf/compact-eh1b.s
@@ -1,6 +1,7 @@
  .cfi_sections .eh_frame_entry
  .section .text.compact1b,"ax",@progbits
  .globl compact1b
+ .type compact1b, @function
  .cfi_startproc
 compact1b:
  lw $31,44($sp)
diff --git a/ld/testsuite/ld-mips-elf/compact-eh2.s b/ld/testsuite/ld-mips-elf/compact-eh2.s
index b899e563c3..234297b7be 100644
--- a/ld/testsuite/ld-mips-elf/compact-eh2.s
+++ b/ld/testsuite/ld-mips-elf/compact-eh2.s
@@ -6,6 +6,7 @@
  .cfi_personality_id 0x2
  .cfi_lsda 0x1b,.LLSDA3
  .global main
+ .type main, @function
 main:
 .LEHB0 = .
  move $4,$2
diff --git a/ld/testsuite/ld-mips-elf/compact-eh3.s b/ld/testsuite/ld-mips-elf/compact-eh3.s
index 2bcf5ca6c3..9ee7558dc9 100644
--- a/ld/testsuite/ld-mips-elf/compact-eh3.s
+++ b/ld/testsuite/ld-mips-elf/compact-eh3.s
@@ -6,6 +6,7 @@
  .cfi_personality_id 0x2
  .cfi_lsda 0x1b,.LLSDA3
  .global main
+ .type main, @function
 main:
 .LEHB0 = .
  move $4,$2
diff --git a/ld/testsuite/ld-mips-elf/compact-eh3a.s b/ld/testsuite/ld-mips-elf/compact-eh3a.s
index 3780cf23e3..a1276ab575 100644
--- a/ld/testsuite/ld-mips-elf/compact-eh3a.s
+++ b/ld/testsuite/ld-mips-elf/compact-eh3a.s
@@ -1,6 +1,7 @@
  .cfi_sections .eh_frame_entry
  .section .text.compact3a,"ax",@progbits
  .globl compact3a
+ .type compact3a, @function
  .cfi_startproc
 compact3a:
  lw $31,44($sp)
diff --git a/ld/testsuite/ld-mips-elf/eh-frame5.s b/ld/testsuite/ld-mips-elf/eh-frame5.s
index 741a021685..cf5a11c37a 100644
--- a/ld/testsuite/ld-mips-elf/eh-frame5.s
+++ b/ld/testsuite/ld-mips-elf/eh-frame5.s
@@ -2,6 +2,7 @@
  .cfi_personality 0x0,local_pers
  .cfi_lsda 0x0,LSDA
  .ent f1
+ .type f1, @function
 f1:
  nop
  .end f1
@@ -11,6 +12,7 @@ f1:
  .cfi_personality 0x0,hidden_pers
  .cfi_lsda 0x0,LSDA
  .ent f2
+ .type f2, @function
 f2:
  nop
  .end f2
@@ -20,6 +22,7 @@ f2:
  .cfi_personality 0x0,global_pers
  .cfi_lsda 0x0,LSDA
  .ent f3
+ .type f3, @function
 f3:
  nop
  .end f3
@@ -29,6 +32,7 @@ f3:
  .cfi_personality 0x0,extern_pers
  .cfi_lsda 0x0,LSDA
  .ent f4
+ .type f4, @function
 f4:
  nop
  .end f4
@@ -38,6 +42,7 @@ f4:
  .cfi_personality 0x80,local_indirect_ptr
  .cfi_lsda 0x0,LSDA
  .ent f5
+ .type f5, @function
 f5:
  nop
  .end f5
@@ -47,6 +52,7 @@ f5:
  .cfi_personality 0x80,hidden_indirect_ptr
  .cfi_lsda 0x0,LSDA
  .ent f6
+ .type f6, @function
 f6:
  nop
  .end f6
@@ -56,6 +62,7 @@ f6:
  .cfi_personality 0x80,global_indirect_ptr
  .cfi_lsda 0x0,LSDA
  .ent f7
+ .type f7, @function
 f7:
  nop
  .end f7
@@ -65,6 +72,7 @@ f7:
  .cfi_personality 0x80,extern_indirect_ptr
  .cfi_lsda 0x0,LSDA
  .ent f8
+ .type f8, @function
 f8:
  nop
  .end f8
@@ -72,6 +80,7 @@ f8:
 
 
  .ent local_pers
+ .type local_pers, @function
 local_pers:
  nop
  .end local_pers
@@ -79,12 +88,14 @@ local_pers:
  .globl hidden_pers
  .hidden hidden_pers
  .ent hidden_pers
+ .type hidden_pers, @function
 hidden_pers:
  nop
  .end hidden_pers
 
  .globl global_pers
  .ent global_pers
+ .type global_pers, @function
 global_pers:
  nop
  .end global_pers
diff --git a/ld/testsuite/ld-mips-elf/ehdr_start-new.s b/ld/testsuite/ld-mips-elf/ehdr_start-new.s
index 5ee00dc4ad..ccf20db024 100644
--- a/ld/testsuite/ld-mips-elf/ehdr_start-new.s
+++ b/ld/testsuite/ld-mips-elf/ehdr_start-new.s
@@ -2,6 +2,7 @@
  .text
  .weak __ehdr_start
  .globl __start
+ .type __start, @function
  .ent __start
  .frame $29, 0, $31
  .mask 0x00000000, 0
diff --git a/ld/testsuite/ld-mips-elf/ehdr_start-o32.s b/ld/testsuite/ld-mips-elf/ehdr_start-o32.s
index 09734473fa..60a5854b9b 100644
--- a/ld/testsuite/ld-mips-elf/ehdr_start-o32.s
+++ b/ld/testsuite/ld-mips-elf/ehdr_start-o32.s
@@ -2,6 +2,7 @@
  .text
  .weak __ehdr_start
  .globl __start
+ .type __start, @function
  .ent __start
  .frame $29, 0, $31
  .mask 0x00000000, 0
diff --git a/ld/testsuite/ld-mips-elf/emit-relocs-1a.s b/ld/testsuite/ld-mips-elf/emit-relocs-1a.s
index 35c3a6f84d..c8fd7d6151 100644
--- a/ld/testsuite/ld-mips-elf/emit-relocs-1a.s
+++ b/ld/testsuite/ld-mips-elf/emit-relocs-1a.s
@@ -1,6 +1,7 @@
  .text
  .align 4
  .globl _start
+ .type _start, @function
 _start:
  jr $31
 
diff --git a/ld/testsuite/ld-mips-elf/jaloverflow-2.s b/ld/testsuite/ld-mips-elf/jaloverflow-2.s
index 71acf296ea..48ede45a48 100644
--- a/ld/testsuite/ld-mips-elf/jaloverflow-2.s
+++ b/ld/testsuite/ld-mips-elf/jaloverflow-2.s
@@ -2,6 +2,7 @@
 # overflowing
 
  .globl start
+ .type start, @function
  .weak foo
 start:
  jal foo
diff --git a/ld/testsuite/ld-mips-elf/jaloverflow.s b/ld/testsuite/ld-mips-elf/jaloverflow.s
index 4dd98b80f8..e6de2e08c3 100644
--- a/ld/testsuite/ld-mips-elf/jaloverflow.s
+++ b/ld/testsuite/ld-mips-elf/jaloverflow.s
@@ -1,6 +1,7 @@
 # This file gets linked to start at 0xffffff0, so the call is an overflow.
  .text
  .global start
+ .type start, @function
  .set noreorder
 start:
  nop
diff --git a/ld/testsuite/ld-mips-elf/mips16-call-global-1.s b/ld/testsuite/ld-mips-elf/mips16-call-global-1.s
index 4c6d0a43aa..485e77c31e 100644
--- a/ld/testsuite/ld-mips-elf/mips16-call-global-1.s
+++ b/ld/testsuite/ld-mips-elf/mips16-call-global-1.s
@@ -1,6 +1,7 @@
  .set mips16
 
  .globl __start
+ .type __start, @function
  .ent __start
  .align 4
 __start:
diff --git a/ld/testsuite/ld-mips-elf/mips16-intermix-1.s b/ld/testsuite/ld-mips-elf/mips16-intermix-1.s
index c596619c94..56527ea217 100644
--- a/ld/testsuite/ld-mips-elf/mips16-intermix-1.s
+++ b/ld/testsuite/ld-mips-elf/mips16-intermix-1.s
@@ -1,6 +1,7 @@
  .text
  .align 2
  .globl __start
+ .type __start, @function
  .set nomips16
  .ent __start
 __start:
diff --git a/ld/testsuite/ld-mips-elf/mips16-pic-1b.s b/ld/testsuite/ld-mips-elf/mips16-pic-1b.s
index 9a17072f2e..1fc03c40eb 100644
--- a/ld/testsuite/ld-mips-elf/mips16-pic-1b.s
+++ b/ld/testsuite/ld-mips-elf/mips16-pic-1b.s
@@ -12,6 +12,7 @@
  callpic used21,mips16
 
  .globl __start
+ .type __start, @function
  .ent __start
  .set nomips16
 __start:
diff --git a/ld/testsuite/ld-mips-elf/mips16-pic-4c.s b/ld/testsuite/ld-mips-elf/mips16-pic-4c.s
index 338d378d75..985a7f150d 100644
--- a/ld/testsuite/ld-mips-elf/mips16-pic-4c.s
+++ b/ld/testsuite/ld-mips-elf/mips16-pic-4c.s
@@ -7,6 +7,7 @@
 
  .section .mips16.call.f2, "ax", @progbits
  .ent __call
+ .type __call, @function
 __call:
  la $25,f2
  jr $25
@@ -18,6 +19,7 @@ __call:
 
  .section .mips16.call.fp.f3, "ax", @progbits
  .ent __call_fp
+ .type __call_fp, @function
 __call_fp:
  la $25,f3
  jr $25
diff --git a/ld/testsuite/ld-mips-elf/no-shared-1-n64.s b/ld/testsuite/ld-mips-elf/no-shared-1-n64.s
index 8eedf12157..c63b8c879c 100644
--- a/ld/testsuite/ld-mips-elf/no-shared-1-n64.s
+++ b/ld/testsuite/ld-mips-elf/no-shared-1-n64.s
@@ -1,6 +1,7 @@
  .abicalls
  .text
  .globl __start
+ .type __start, @function
  .ent __start
 __start:
  lui $2,%hi(__gnu_local_gp)
diff --git a/ld/testsuite/ld-mips-elf/no-shared-1-o32.s b/ld/testsuite/ld-mips-elf/no-shared-1-o32.s
index f00fc4ba91..80be39bf36 100644
--- a/ld/testsuite/ld-mips-elf/no-shared-1-o32.s
+++ b/ld/testsuite/ld-mips-elf/no-shared-1-o32.s
@@ -1,6 +1,7 @@
  .abicalls
  .text
  .globl __start
+ .type __start, @function
  .ent __start
 __start:
  lui $2,%hi(__gnu_local_gp)
diff --git a/ld/testsuite/ld-mips-elf/pic-and-nonpic-1b-micromips.s b/ld/testsuite/ld-mips-elf/pic-and-nonpic-1b-micromips.s
index 1eff3093c8..abd0156891 100644
--- a/ld/testsuite/ld-mips-elf/pic-and-nonpic-1b-micromips.s
+++ b/ld/testsuite/ld-mips-elf/pic-and-nonpic-1b-micromips.s
@@ -1,6 +1,7 @@
  .abicalls
  .option pic0
  .global __start
+ .type __start, @function
  .set micromips
  .ent __start
 __start:
diff --git a/ld/testsuite/ld-mips-elf/pic-and-nonpic-1b.s b/ld/testsuite/ld-mips-elf/pic-and-nonpic-1b.s
index 5739fef104..2615f24a22 100644
--- a/ld/testsuite/ld-mips-elf/pic-and-nonpic-1b.s
+++ b/ld/testsuite/ld-mips-elf/pic-and-nonpic-1b.s
@@ -1,6 +1,7 @@
  .abicalls
  .option pic0
  .global __start
+ .type __start, @function
  .ent __start
 __start:
  jal f1
diff --git a/ld/testsuite/ld-mips-elf/pic-and-nonpic-2a.s b/ld/testsuite/ld-mips-elf/pic-and-nonpic-2a.s
index 45a490f945..f360b0eb2d 100644
--- a/ld/testsuite/ld-mips-elf/pic-and-nonpic-2a.s
+++ b/ld/testsuite/ld-mips-elf/pic-and-nonpic-2a.s
@@ -1,6 +1,7 @@
  .abicalls
  .option pic0
  .global __start
+ .type __start, @function
  .ent __start
 __start:
  jal foo
diff --git a/ld/testsuite/ld-mips-elf/pic-and-nonpic-3b.s b/ld/testsuite/ld-mips-elf/pic-and-nonpic-3b.s
index 571c774cdf..2a9ad89dee 100644
--- a/ld/testsuite/ld-mips-elf/pic-and-nonpic-3b.s
+++ b/ld/testsuite/ld-mips-elf/pic-and-nonpic-3b.s
@@ -1,6 +1,7 @@
  .abicalls
  .option pic0
  .global __start
+ .type __start, @function
  .ent __start
 __start:
  jal foo
@@ -8,6 +9,7 @@ __start:
  .end __start
 
  .global ext
+ .type ext, @function
  .ent ext
 ext:
  lui $gp,%hi(__gnu_local_gp)
diff --git a/ld/testsuite/ld-mips-elf/pic-and-nonpic-4b.s b/ld/testsuite/ld-mips-elf/pic-and-nonpic-4b.s
index 7e25bf48bf..863a01b02c 100644
--- a/ld/testsuite/ld-mips-elf/pic-and-nonpic-4b.s
+++ b/ld/testsuite/ld-mips-elf/pic-and-nonpic-4b.s
@@ -1,6 +1,7 @@
  .abicalls
  .option pic0
  .global __start
+ .type __start, @function
  .ent __start
 __start:
  lui $2,%hi(obj1)
diff --git a/ld/testsuite/ld-mips-elf/pic-and-nonpic-5a.s b/ld/testsuite/ld-mips-elf/pic-and-nonpic-5a.s
index 7452f5e8e3..e85655fbe1 100644
--- a/ld/testsuite/ld-mips-elf/pic-and-nonpic-5a.s
+++ b/ld/testsuite/ld-mips-elf/pic-and-nonpic-5a.s
@@ -1,6 +1,7 @@
  .abicalls
  .option pic0
  .global __start
+ .type __start, @function
  .ent __start
 __start:
  lui $2,%hi(foo)
diff --git a/ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n32c.s b/ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n32c.s
index 578626a18c..3d5660c2ad 100644
--- a/ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n32c.s
+++ b/ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n32c.s
@@ -2,6 +2,7 @@
  .option pic0
  .set noreorder
  .global __start
+ .type __start, @function
  .ent __start
 __start:
  jal f1
diff --git a/ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n64c.s b/ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n64c.s
index 578626a18c..3d5660c2ad 100644
--- a/ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n64c.s
+++ b/ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n64c.s
@@ -2,6 +2,7 @@
  .option pic0
  .set noreorder
  .global __start
+ .type __start, @function
  .ent __start
 __start:
  jal f1
diff --git a/ld/testsuite/ld-mips-elf/pic-and-nonpic-6-o32c.s b/ld/testsuite/ld-mips-elf/pic-and-nonpic-6-o32c.s
index 578626a18c..3d5660c2ad 100644
--- a/ld/testsuite/ld-mips-elf/pic-and-nonpic-6-o32c.s
+++ b/ld/testsuite/ld-mips-elf/pic-and-nonpic-6-o32c.s
@@ -2,6 +2,7 @@
  .option pic0
  .set noreorder
  .global __start
+ .type __start, @function
  .ent __start
 __start:
  jal f1
diff --git a/ld/testsuite/ld-mips-elf/pie.s b/ld/testsuite/ld-mips-elf/pie.s
index c7f2b206b9..442de01500 100644
--- a/ld/testsuite/ld-mips-elf/pie.s
+++ b/ld/testsuite/ld-mips-elf/pie.s
@@ -1,5 +1,6 @@
  .abicalls
  .global __start
+ .type __start, @function
  .ent __start
 __start:
  jr $31
diff --git a/ld/testsuite/ld-mips-elf/relax-jalr.s b/ld/testsuite/ld-mips-elf/relax-jalr.s
index ba7ea1a04d..b8478faef0 100644
--- a/ld/testsuite/ld-mips-elf/relax-jalr.s
+++ b/ld/testsuite/ld-mips-elf/relax-jalr.s
@@ -1,6 +1,7 @@
-.globl __start
+ .globl __start
+ .type __start, @function
  .space 8
-.ent __start
+ .ent __start
 __start:
 .Lstart:
  .space 16
@@ -9,7 +10,7 @@ __start:
         jal __start
  .space 64
  jal .Lstart
-.end __start
+ .end __start
 
 # make objdump print ...
  .space 8
diff --git a/ld/testsuite/ld-mips-elf/reloc-1a.s b/ld/testsuite/ld-mips-elf/reloc-1a.s
index 5fcd4bb18c..2d1c9f1f52 100644
--- a/ld/testsuite/ld-mips-elf/reloc-1a.s
+++ b/ld/testsuite/ld-mips-elf/reloc-1a.s
@@ -1,4 +1,5 @@
  .globl _start
+ .type _start, @function
  .globl sdg
  .set noreorder
  .ent tstarta
diff --git a/ld/testsuite/ld-mips-elf/reloc-2a.s b/ld/testsuite/ld-mips-elf/reloc-2a.s
index 0ea830a9da..570b724823 100644
--- a/ld/testsuite/ld-mips-elf/reloc-2a.s
+++ b/ld/testsuite/ld-mips-elf/reloc-2a.s
@@ -1,4 +1,5 @@
  .globl _start
+ .type _start, @function
  .globl sdg
  .set noreorder
  .ent tstarta
diff --git a/ld/testsuite/ld-mips-elf/reloc-4.s b/ld/testsuite/ld-mips-elf/reloc-4.s
index 061fa80715..d379e05963 100644
--- a/ld/testsuite/ld-mips-elf/reloc-4.s
+++ b/ld/testsuite/ld-mips-elf/reloc-4.s
@@ -1,5 +1,6 @@
  .text
  .globl _start
+ .type _start, @function
 _start:
         li.d    $f2,1.10000000000000000000e0
 
diff --git a/ld/testsuite/ld-mips-elf/reloc-5.s b/ld/testsuite/ld-mips-elf/reloc-5.s
index a4b31b7fa0..25c722a549 100644
--- a/ld/testsuite/ld-mips-elf/reloc-5.s
+++ b/ld/testsuite/ld-mips-elf/reloc-5.s
@@ -1,5 +1,6 @@
  .text
  .globl _start
+ .type _start, @function
 _start:
         lw $2, %gp_rel(i)($28)
 
diff --git a/ld/testsuite/ld-mips-elf/reloc-6b.s b/ld/testsuite/ld-mips-elf/reloc-6b.s
index ae4e9bcf8a..e75060e151 100644
--- a/ld/testsuite/ld-mips-elf/reloc-6b.s
+++ b/ld/testsuite/ld-mips-elf/reloc-6b.s
@@ -1,4 +1,5 @@
  .globl __start .text
+ .type __start, @function
  .globl gs .text
 __start:
 gs:
diff --git a/ld/testsuite/ld-mips-elf/textrel-1.s b/ld/testsuite/ld-mips-elf/textrel-1.s
index f6b4a6a70d..43143f7c93 100644
--- a/ld/testsuite/ld-mips-elf/textrel-1.s
+++ b/ld/testsuite/ld-mips-elf/textrel-1.s
@@ -1,4 +1,5 @@
         .globl foo
+ .type foo, @function
 foo:
         .cfi_startproc
         nop
diff --git a/ld/testsuite/ld-mips-elf/undefweak-overflow.d b/ld/testsuite/ld-mips-elf/undefweak-overflow.d
index bbed9970df..72fcc65cb7 100644
--- a/ld/testsuite/ld-mips-elf/undefweak-overflow.d
+++ b/ld/testsuite/ld-mips-elf/undefweak-overflow.d
@@ -3,38 +3,38 @@
 #ld: -Ttext=0x20000000 -e start
 #objdump: -dr --show-raw-insn
 #...
-[0-9a-f]+ <_ftext>:
-[ 0-9a-f]+: d85fffff beqzc v0,20000000 <_ftext>
+[0-9a-f]+ <start>:
+[ 0-9a-f]+: d85fffff beqzc v0,20000000 <start>
 [ 0-9a-f]+: 00000000 nop
-[ 0-9a-f]+: f85ffffd bnezc v0,20000000 <_ftext>
-[ 0-9a-f]+: ec4ffffd lwpc v0,20000000 <_ftext>
-[ 0-9a-f]+: ec5bfffe ldpc v0,20000000 <_ftext>
-[ 0-9a-f]+: cbfffffa bc 20000000 <_ftext>
-[ 0-9a-f]+: 1000fff9 b 20000000 <_ftext>
+[ 0-9a-f]+: f85ffffd bnezc v0,20000000 <start>
+[ 0-9a-f]+: ec4ffffd lwpc v0,20000000 <start>
+[ 0-9a-f]+: ec5bfffe ldpc v0,20000000 <start>
+[ 0-9a-f]+: cbfffffa bc 20000000 <start>
+[ 0-9a-f]+: 1000fff9 b 20000000 <start>
 [ 0-9a-f]+: 00000000 nop
-[ 0-9a-f]+: 0411fff7 bal 20000000 <_ftext>
+[ 0-9a-f]+: 0411fff7 bal 20000000 <start>
 [ 0-9a-f]+: 3c...... lui a0,0x....
-[ 0-9a-f]+: 0c000000 jal 20000000 <_ftext>
+[ 0-9a-f]+: 0c000000 jal 20000000 <start>
 [ 0-9a-f]+: 00000000 nop
-[ 0-9a-f]+: 08000000 j 20000000 <_ftext>
+[ 0-9a-f]+: 08000000 j 20000000 <start>
 [ 0-9a-f]+: 00000000 nop
 
 [0-9a-f]+ <micro>:
-[ 0-9a-f]+: 8e63       beqz a0,20000000 <_ftext>
+[ 0-9a-f]+: 8e63       beqz a0,20000000 <start>
 [ 0-9a-f]+: 0c00       nop
-[ 0-9a-f]+: cfe1       b 20000000 <_ftext>
+[ 0-9a-f]+: cfe1       b 20000000 <start>
 [ 0-9a-f]+: 0c00       nop
-[ 0-9a-f]+: 9400 ffde b 20000000 <_ftext>
+[ 0-9a-f]+: 9400 ffde b 20000000 <start>
 [ 0-9a-f]+: 0c00       nop
-[ 0-9a-f]+: 4060 ffdb bal 20000000 <_ftext>
+[ 0-9a-f]+: 4060 ffdb bal 20000000 <start>
 [ 0-9a-f]+: 0000 0000 nop
-[ 0-9a-f]+: f400 0000 jal 20000000 <_ftext>
+[ 0-9a-f]+: f400 0000 jal 20000000 <start>
 [ 0-9a-f]+: 0000 0000 nop
-[ 0-9a-f]+: d400 0000 j 20000000 <_ftext>
+[ 0-9a-f]+: d400 0000 j 20000000 <start>
 [ 0-9a-f]+: 0c00       nop
 
 [0-9a-f]+ <mips16>:
-[ 0-9a-f]+: f7df 1010 b 20000000 <_ftext>
-[ 0-9a-f]+: 1800 0000 jal 20000000 <_ftext>
+[ 0-9a-f]+: f7df 1010 b 20000000 <start>
+[ 0-9a-f]+: 1800 0000 jal 20000000 <start>
 [ 0-9a-f]+: 6500       nop
 #pass
diff --git a/ld/testsuite/ld-mips-elf/undefweak-overflow.s b/ld/testsuite/ld-mips-elf/undefweak-overflow.s
index d439d7c7c7..a8370ac6a5 100644
--- a/ld/testsuite/ld-mips-elf/undefweak-overflow.s
+++ b/ld/testsuite/ld-mips-elf/undefweak-overflow.s
@@ -3,6 +3,7 @@
 
  .module mips64r6
  .globl start
+ .type start, @function
  .weak foo
 start:
  .set noreorder
diff --git a/ld/testsuite/ld-x86-64/load2.d b/ld/testsuite/ld-x86-64/load2.d
index f76ba9d55f..0ae721c816 100644
--- a/ld/testsuite/ld-x86-64/load2.d
+++ b/ld/testsuite/ld-x86-64/load2.d
@@ -14,5 +14,5 @@ Disassembly of section .text:
 [ ]*[a-f0-9]+: 48 8d 05 ([0-9a-f]{2} ){4} * lea    -0x[a-f0-9]+\(%rip\),%rax        # [a-f0-9]+ <foo>
 [ ]*[a-f0-9]+: 4c 8d 1d ([0-9a-f]{2} ){4} * lea    0x[a-f0-9]+\(%rip\),%r11        # [a-f0-9]+ <bar>
 [ ]*[a-f0-9]+: 48 8d 05 ([0-9a-f]{2} ){4} * lea    0x[a-f0-9]+\(%rip\),%rax        # [a-f0-9]+ <__start_my_section>
-[ ]*[a-f0-9]+: 4c 8d 1d ([0-9a-f]{2} ){4} * lea    0x[a-f0-9]+\(%rip\),%r11        # [a-f0-9]+ <__stop_my_section>
+[ ]*[a-f0-9]+: 4c 8d 1d ([0-9a-f]{2} ){4} * lea    0x[a-f0-9]+\(%rip\),%r11        # [a-f0-9]+ <(__stop_my_section|pad)>
 #pass


--
Alan Modra
Australia Development Lab, IBM
Reply | Threaded
Open this post in threaded view
|

Re: Prefer object over notype symbols when disassembling

Borislav Petkov-2
On Tue, Dec 17, 2019 at 08:45:59PM +1030, Alan Modra wrote:
> Changing objdump disassembly output like this always requires some
> testsuite changes, with the avr and x64_64 changes simply due to

"x86_64"

> picking up better symbols, the whole point of the patch.
>
> The mips changes are due to mips-sgi-irix changing STT_NOTYPE symbols
> to STT_OBJECT, which objdump now chooses in preference to script
> symbols.  The problem is that objdump looks at the first symbol in the
> section being disassembled, and if object type, just dumps out bytes
> rather than disassembling.  This results in new failures:

Yeah, exactly. So I have no clue how long you guys do objdump testing
but considering this fix might cause some grief due to the symbols
ordering change, it might be prudent to expose it to testers a lot
longer...

Just a thought anyway.

Thanks for the fix!

--
Regards/Gruss,
    Boris.

SUSE Software Solutions Germany GmbH, GF: Felix Imendörffer, HRB 36809, AG Nürnberg
Reply | Threaded
Open this post in threaded view
|

Re: Prefer object over notype symbols when disassembling

Maciej W. Rozycki
In reply to this post by Alan Modra-3
On Tue, 17 Dec 2019, Alan Modra wrote:

> diff --git a/ld/testsuite/ld-mips-elf/eh-frame5.s b/ld/testsuite/ld-mips-elf/eh-frame5.s
> index 741a021685..cf5a11c37a 100644
> --- a/ld/testsuite/ld-mips-elf/eh-frame5.s
> +++ b/ld/testsuite/ld-mips-elf/eh-frame5.s
> @@ -2,6 +2,7 @@
>   .cfi_personality 0x0,local_pers
>   .cfi_lsda 0x0,LSDA
>   .ent f1
> + .type f1, @function
>  f1:
>   nop
>   .end f1

 If this and similar changes throughout are required, then we have a bug
somewhere, probably in GAS, because `.ent' is supposed to set STT_FUNCTION
for the symbol named, making a `.type' pseudo-op to do the same redundant.  
Cf. `s_mips_ent' and:

  symbol_get_bfdsym (symbolP)->flags |= BSF_FUNCTION;

I'd rather keep the old arrangement in the test suite to provide coverage
for this semantics.

  Maciej
Reply | Threaded
Open this post in threaded view
|

Re: Prefer object over notype symbols when disassembling

Alan Modra-3
On Mon, Jan 06, 2020 at 02:11:23PM +0000, Maciej W. Rozycki wrote:

> On Tue, 17 Dec 2019, Alan Modra wrote:
>
> > diff --git a/ld/testsuite/ld-mips-elf/eh-frame5.s b/ld/testsuite/ld-mips-elf/eh-frame5.s
> > index 741a021685..cf5a11c37a 100644
> > --- a/ld/testsuite/ld-mips-elf/eh-frame5.s
> > +++ b/ld/testsuite/ld-mips-elf/eh-frame5.s
> > @@ -2,6 +2,7 @@
> >   .cfi_personality 0x0,local_pers
> >   .cfi_lsda 0x0,LSDA
> >   .ent f1
> > + .type f1, @function
> >  f1:
> >   nop
> >   .end f1
>
>  If this and similar changes throughout are required, then we have a bug
> somewhere, probably in GAS, because `.ent' is supposed to set STT_FUNCTION
> for the symbol named, making a `.type' pseudo-op to do the same redundant.  
> Cf. `s_mips_ent' and:
>
>   symbol_get_bfdsym (symbolP)->flags |= BSF_FUNCTION;
>
> I'd rather keep the old arrangement in the test suite to provide coverage
> for this semantics.

I'll admit to going wild and adding .type @function in lots of places
after finding it was needed for some mips tests on mips-sgi-irix.  It
looks like the following files should have my change reverted.  I'll
test and commit.

ld/testsuite/ld-mips-elf/eh-frame5.s
ld/testsuite/ld-mips-elf/ehdr_start-new.s
ld/testsuite/ld-mips-elf/ehdr_start-o32.s
ld/testsuite/ld-mips-elf/mips16-call-global-1.s
ld/testsuite/ld-mips-elf/mips16-intermix-1.s
ld/testsuite/ld-mips-elf/mips16-pic-1b.s
ld/testsuite/ld-mips-elf/mips16-pic-4c.s
ld/testsuite/ld-mips-elf/no-shared-1-n64.s
ld/testsuite/ld-mips-elf/no-shared-1-o32.s
ld/testsuite/ld-mips-elf/pic-and-nonpic-1b-micromips.s
ld/testsuite/ld-mips-elf/pic-and-nonpic-1b.s
ld/testsuite/ld-mips-elf/pic-and-nonpic-2a.s
ld/testsuite/ld-mips-elf/pic-and-nonpic-3b.s
ld/testsuite/ld-mips-elf/pic-and-nonpic-4b.s
ld/testsuite/ld-mips-elf/pic-and-nonpic-5a.s
ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n32c.s
ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n64c.s
ld/testsuite/ld-mips-elf/pic-and-nonpic-6-o32c.s
ld/testsuite/ld-mips-elf/pie.s
ld/testsuite/ld-mips-elf/relax-jalr.s

--
Alan Modra
Australia Development Lab, IBM