Bug 7004 - binutils-2.18's objdump seems to segfault for all "-m arm -b binary -D" input.
Summary: binutils-2.18's objdump seems to segfault for all "-m arm -b binary -D" input.
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: 2.18
: P2 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-11-05 06:35 UTC by Liam Vrilehen
Modified: 2009-01-13 07:17 UTC (History)
1 user (show)

See Also:
Host: x86_64-linux-gnu
Target: arm-linux-gnu
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Liam Vrilehen 2008-11-05 06:35:27 UTC
binutils-2.18's objdump seems to segfault for all 
"-m arm -b binary -D" input.

Trivial example.
objdump-2.16.1 -m arm -b binary a.out -D
| a.out:     file format binary
| 
| Disassembly of section .data:
| 
| 0000000000000000 <.data>:
| 0:   ea000000        b       0x8
| 4:   e1a00000        nop                     (mov r0,r0)
| 8:   e3a00001        mov     r0, #1  ; 0x1
| c:   e0800002        add     r0, r0, r2

objdump-2.18 -m arm -b binary a.out -D
<segfault>


(gdb) Program received signal SIGSEGV, Segmentation fault.
0x00007f79a3cb2ebe in print_insn (pc=0, info=0x7fffac900860, little=1)
    at 
/var/tmp/portage/sys-devel/binutils-2.18-r3/work/binutils-2.18/opcodes/arm-
dis.c:3991
3991    
/var/tmp/portage/sys-devel/binutils-2.18-r3/work/binutils-2.18/opcodes/arm-
dis.c: 
No such file or directory.
        in 
/var/tmp/portage/sys-devel/binutils-2.18-r3/work/binutils-2.18/opcodes/arm-dis.c
(gdb) bt
#0  0x00007f79a3cb2ebe in print_insn (pc=0, info=0x7fffac900860, 
little=1)
    at 
/var/tmp/portage/sys-devel/binutils-2.18-r3/work/binutils-2.18/opcodes/arm-
dis.c:3991
#1  0x0000000000408365 in disassemble_section (abfd=0x6479a0, 
section=0x649310, info=<value optimized out>)
    at 
/var/tmp/portage/sys-devel/binutils-2.18-r3/work/binutils-2.18/binutils/
objdump.c:1472
#2  0x00007f79a3308dce in bfd_map_over_sections (abfd=0x6479a0, 
operation=0x4079a0 <disassemble_section>, user_storage=0x7fffac900860)
    at 
/var/tmp/portage/sys-devel/binutils-2.18-r3/work/binutils-2.18/bfd/
section.c:1226
#3  0x0000000000405f46 in disassemble_data (abfd=0x6479a0) at 
/var/tmp/portage/sys-devel/binutils-2.18-r3/work/binutils-2.18/binutils/
objdump.c:2014
#4  0x0000000000406768 in dump_bfd (abfd=0x6479a0) at 
/var/tmp/portage/sys-devel/binutils-2.18-r3/work/binutils-2.18/binutils/
objdump.c:2896
#5  0x0000000000406ba8 in display_bfd (abfd=0x6479a0) at 
/var/tmp/portage/sys-devel/binutils-2.18-r3/work/binutils-2.18/binutils/
objdump.c:2966
#6  0x0000000000406d58 in display_file (filename=0x7fffac900ec5 "a.out", 
target=0x7fffac900eb7 "binary")
    at 
/var/tmp/portage/sys-devel/binutils-2.18-r3/work/binutils-2.18/binutils/
objdump.c:3027
#7  0x000000000040739d in main (argc=7, argv=0x7fffac900b48)
    at 
/var/tmp/portage/sys-devel/binutils-2.18-r3/work/binutils-2.18/binutils/
objdump.c:3266
(gdb) print info
$1 = (struct disassemble_info *) 0x7fffac900860
(gdb) print *info
$2 = {fprintf_func = 0x4092a0 <objdump_sprintf>, stream = 
0x7fffac9007b0, application_data = 0x7fffac900950, flavour = 
bfd_target_unknown_flavour, 
  arch = bfd_arch_arm, mach = 0, endian = BFD_ENDIAN_UNKNOWN, insn_sets 
= 0x0, section = 0x649310, symbols = 0x0, num_symbols = 0, 
  symtab = 0x649d40, symtab_pos = -1, symtab_size = 0, flags = 0, 
private_data = 0x0, read_memory_func = 0x7f79a3ca83f0 
<buffer_read_memory>, 
  memory_error_func = 0x7f79a3ca8340 <perror_memory>, print_address_func 
= 0x405160 <objdump_print_address>, 
  symbol_at_address_func = 0x4043e0 <objdump_symbol_at_address>, 
symbol_is_valid = 0x7f79a3cae940 <arm_symbol_is_valid>, buffer = 
0x649d60 "", 
  buffer_vma = 0, buffer_length = 16, bytes_per_line = 0, 
bytes_per_chunk = 0, display_endian = BFD_ENDIAN_UNKNOWN, 
octets_per_byte = 1, 
  skip_zeroes = 8, skip_zeroes_at_end = 3, disassembler_needs_relocs = 
1, insn_info_valid = 0 '\0', branch_delay_insns = 0 '\0', data_size = 0 
'\0', 
  insn_type = dis_noninsn, target = 0, target2 = 0, disassembler_options 
= 0x0}
(gdb) disassemble 0x00007f79a3cb2eb0 0x00007f79a3cb2ec0
Dump of assembler code from 0x7f79a3cb2eb0 to 0x7f79a3cb2ec0:
0x00007f79a3cb2eb0 <print_insn+160>:    add    %cl,-0x75(%rcx)
0x00007f79a3cb2eb3 <print_insn+163>:    rex.WR and    $0x50,%al
0x00007f79a3cb2eb6 <print_insn+166>:    test   %rcx,%rcx
0x00007f79a3cb2eb9 <print_insn+169>:    je     0x7f79a3cb2ecf 
<print_insn+191>
0x00007f79a3cb2ebb <print_insn+171>:    mov    (%rcx),%rax
0x00007f79a3cb2ebe <print_insn+174>:    mov    (%rax),%rax
End of assembler dump.
(gdb) info registers 
rax            0x0      0
rbx            0x0      0
rcx            0x649d40 6593856
rdx            0x1      1
rsi            0x7fffac900860   140736088508512
rdi            0x0      0
rbp            0x3      0x3
rsp            0x7fffac900580   0x7fffac900580
r8             0x1      1
r9             0x1      1
r10            0x7f79a48c66f0   140160428435184
r11            0x0      0
r12            0x7fffac900860   140736088508512
r13            0x7fffac900860   140736088508512
r14            0x4079a0 4225440
r15            0x0      0
rip            0x7f79a3cb2ebe   0x7f79a3cb2ebe <print_insn+174>
eflags         0x10202  [ IF RF ]
cs             0x33     51
ss             0x2b     43
ds             0x0      0
es             0x0      0
fs             0x0      0
gs             0x0      0
fctrl          0x37f    895
fstat          0x0      0
ftag           0xffff   65535
fiseg          0x0      0
fioff          0x0      0
foseg          0x0      0
fooff          0x0      0
fop            0x0      0
mxcsr          0x1f80   [ IM DM ZM OM UM PM ]
Comment 1 Nick Clifton 2008-11-06 13:20:58 UTC
Hi Liam,

  I am unable to reproduce this problem.  Please could you try using a version
of objdump built from either the current head of the binutils CVS repository or
else the recently created v2.19 release sources and see if the problem persists.
 If it does, please could you upload the test binary file that you have been
using so that I can try again.

Cheers
  Nick
Comment 2 thomas 2008-11-07 13:32:58 UTC
I can reproduce this issue with Gentoo's 2.18 binutils but neither with Gentoo's
2.19.50.0.1 nor the vanilla 2.19.50.0.1.

(Can't test vanilla 2.18 because it fails to compile on my system.)
Comment 3 Alan Modra 2009-01-13 07:17:59 UTC
This was fixed with:

2007-10-26  Nick Clifton  <nickc@redhat.com>

	* arm-dis.c (print_insn): Check for a symtab that exists but is
	empty.