]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
objdump --disassemble=sym peculiarities
authorAlan Modra <amodra@gmail.com>
Mon, 1 Apr 2024 20:48:19 +0000 (07:18 +1030)
committerAlan Modra <amodra@gmail.com>
Tue, 2 Apr 2024 00:02:04 +0000 (10:32 +1030)
commitf37f8c46c2e876a524301d6916a04cf7debb6483
tree2db867fc4a086aac2d325d3729ed8904168466fd
parent0ed1e396e4e869970c60d445bf606ed5092f5558
objdump --disassemble=sym peculiarities

Given this testcase:
 .text
 mov $x1,%eax
f1:
 mov $f1,%eax
 .type f1,@function
 .size f1,.-f1

 mov $x2,%eax
f2:
 mov $f2,%eax
 .type f2,@function
 .size f2,.-f2+0x1000 #bad size

objdump --reloc --disassemble=f1 prints
00000000 <f1-0x5>:
   0: b8 00 00 00 00        mov    $0x0,%eax

and objdump --reloc --disassemble=f2 prints
0000000f <f2>:
   f: b8 0f 00 00 00        mov    $0xf,%eax
10: R_386_32 .text

It seems for f1 we get the insn before f1 and no reloc whereas, post
159daa36fa, f2 is disassembled correctly.  Some analysis says that
find_symbol_for_address may return a symbol past the current address,
and reloc skipping is broken.  Fix both of these problems.

* objdump.c (disassemble_jumps, disassemble_bytes): Replace
        relppp with relpp, ie. don't update caller's rel_pp.  Adjust
        calls.
(disassemble_section): Skip over relocs inside loop rather
        than before loop.  Revert 7e538762c2c1.  If given a symbol,
don't start disassembling until its address is reached.
Correct end of function calculation.
binutils/objdump.c