Prefer object over notype symbols when disassembling
authorAlan Modra <amodra@gmail.com>
Tue, 17 Dec 2019 08:36:02 +0000 (19:06 +1030)
committerAlan Modra <amodra@gmail.com>
Tue, 17 Dec 2019 10:13:00 +0000 (20:43 +1030)
commit660df28acfa1b58c978d65d9cb26d37023f791ce
treeed6b67cf8188b675c32949db065d58f584bbaaea
parent260bcd09bfb98ebc5d8f0eb564edca21872e9f7f
Prefer object over notype symbols when disassembling

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.
43 files changed:
binutils/ChangeLog
binutils/objdump.c
ld/ChangeLog
ld/testsuite/ld-avr/lds-mega.d
ld/testsuite/ld-avr/lds-tiny.d
ld/testsuite/ld-mips-elf/compact-eh1.s
ld/testsuite/ld-mips-elf/compact-eh1a.s
ld/testsuite/ld-mips-elf/compact-eh1b.s
ld/testsuite/ld-mips-elf/compact-eh2.s
ld/testsuite/ld-mips-elf/compact-eh3.s
ld/testsuite/ld-mips-elf/compact-eh3a.s
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/emit-relocs-1a.s
ld/testsuite/ld-mips-elf/jaloverflow-2.s
ld/testsuite/ld-mips-elf/jaloverflow.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
ld/testsuite/ld-mips-elf/reloc-1a.s
ld/testsuite/ld-mips-elf/reloc-2a.s
ld/testsuite/ld-mips-elf/reloc-4.s
ld/testsuite/ld-mips-elf/reloc-5.s
ld/testsuite/ld-mips-elf/reloc-6b.s
ld/testsuite/ld-mips-elf/textrel-1.s
ld/testsuite/ld-mips-elf/undefweak-overflow.d
ld/testsuite/ld-mips-elf/undefweak-overflow.s
ld/testsuite/ld-x86-64/load2.d