]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
binutils/objdump: Fix disassemble for huge elf sections
authorRavi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
Fri, 14 Jul 2017 07:56:27 +0000 (13:26 +0530)
committerAlan Modra <amodra@gmail.com>
Fri, 14 Jul 2017 13:21:01 +0000 (22:51 +0930)
commit0f6329bd7fcc8952aed5a386617d12529771415d
treed65ecc2014d5890e847a89242b84a866901d9ae2
parent86038de0d810f8639d22573921d2589a99829b36
binutils/objdump: Fix disassemble for huge elf sections

When elf section size is beyond unsigned int max value, objdump fails
to disassemble from that section. Ex on PowerPC,

  $ objdump -h /proc/kcore
    Idx  Name   Size       VMA
      4  load2  100000000  c000000000000000

Here, size of load2 section is 0x100000000. Also note that, 0xc00....
address range is kernel space for PowerPC. Now let's try to disassemble
do_sys_open() using /proc/kcore.

  $ cat /proc/kallsyms | grep -A1 -w do_sys_open
    c00000000036c000 T do_sys_open
    c00000000036c2d0 T SyS_open

Before patch:

  $ objdump -d --start-address=0xc00000000036c000 --stop-address=0xc00000000036c2d0 /proc/kcore
    /proc/kcore:    file format elf64-powerpcle

    Disassembly of section load2:

    c00000000036c000 <load2+0x36c000>:
    c00000000036c000:    Address 0xc00000000036c000 is out of bounds.

Fix this by changing type of 'buffer_length' from unsigned int to
size_t. After patch:

  $ objdump -d --start-address=0xc00000000036c000 --stop-address=0xc00000000036c2d0 /proc/kcore
    /proc/kcore:    file format elf64-powerpcle

    Disassembly of section load2:

    c00000000036c000 <load2+0x36c000>:
    c00000000036c000: fc 00 4c 3c     addis   r2,r12,252
    c00000000036c004: 00 53 42 38     addi    r2,r2,21248
    c00000000036c008: a6 02 08 7c     mflr    r0

include/
* dis-asm.h (struct disassemble_info): Change type of buffer_length
field to size_t.
opcodes/
* dis-buf.c (buffer_read_memory): Change type of end_addr_offset,
max_addr_offset and octets variables to size_t.
include/ChangeLog
include/dis-asm.h
opcodes/ChangeLog
opcodes/dis-buf.c