summaryrefslogtreecommitdiff
path: root/opcodes
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2015-06-22 16:53:27 +0100
committerNick Clifton <nickc@redhat.com>2015-06-22 16:53:27 +0100
commitbdc4de1b24353c4213e404029252ec75065499de (patch)
treec3ad4f2c6df81c81c6caae1251ecfd91fbcaee3e /opcodes
parent07fcd30112bb071e8dda0a2229a860f2874a7816 (diff)
downloadbinutils-gdb-bdc4de1b24353c4213e404029252ec75065499de.tar.gz
Stop "objdump -d" from disassembling past a symbolic address.
include * dis-asm.h (struct disassemble_info): Add stop_vma field. binuti * objdump.c (disassemble_bytes): Set the stop_vma field in the disassemble_info structure when disassembling code sections with -d. * doc/binutils.texi (objdump): Document the discrepancy between -d and -D. opcodes * dis-buf.c (buffer_read_memory): Fail is stop_vma is set and the requested region lies beyond it. * bfin-dis.c (print_insn_bfin): Ignore sysop instructions when looking for 32-bit insns. * mcore-dis.c (print_insn_mcore): Disable stop_vma when reading data. * sh-dis.c (print_insn_sh): Likewise. * tic6x-dis.c (print_insn_tic6x): Disable stop_vma when reading blocks of instructions. * vax-dis.c (print_insn_vax): Check that the requested address does not clash with the stop_vma. tests * gas/arm/backslash-at.s: Add extra .byte directives so that the foo symbol does not appear to point half way through an instruction. * gas/arm/backslash-at.d: Update expected disassembly. * gas/i386/ilp32/x86-64-opcode-inval-intel.d: Likewise. * gas/i386/ilp32/x86-64-opcode-inval.d: Likewise. * gas/i386/x86-64-opcode-inval-intel.d: Likewise. * gas/i386/x86-64-opcode-inval.d: Likewise.
Diffstat (limited to 'opcodes')
-rw-r--r--opcodes/ChangeLog14
-rw-r--r--opcodes/bfin-dis.c2
-rw-r--r--opcodes/dis-buf.c4
-rw-r--r--opcodes/mcore-dis.c11
-rw-r--r--opcodes/sh-dis.c2
-rw-r--r--opcodes/tic6x-dis.c3
-rw-r--r--opcodes/vax-dis.c3
7 files changed, 33 insertions, 6 deletions
diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog
index f764473b1b7..0697cbee1dc 100644
--- a/opcodes/ChangeLog
+++ b/opcodes/ChangeLog
@@ -1,3 +1,17 @@
+2015-06-22 Nick Clifton <nickc@redhat.com>
+
+ * dis-buf.c (buffer_read_memory): Fail is stop_vma is set and the
+ requested region lies beyond it.
+ * bfin-dis.c (print_insn_bfin): Ignore sysop instructions when
+ looking for 32-bit insns.
+ * mcore-dis.c (print_insn_mcore): Disable stop_vma when reading
+ data.
+ * sh-dis.c (print_insn_sh): Likewise.
+ * tic6x-dis.c (print_insn_tic6x): Disable stop_vma when reading
+ blocks of instructions.
+ * vax-dis.c (print_insn_vax): Check that the requested address
+ does not clash with the stop_vma.
+
2015-06-19 Peter Bergner <bergner@vnet.ibm.com>
* ppc-dis.h (skip_optional_operands): Use ppc_optional_operand_value.
diff --git a/opcodes/bfin-dis.c b/opcodes/bfin-dis.c
index cf66b797b44..bf2052e3ed1 100644
--- a/opcodes/bfin-dis.c
+++ b/opcodes/bfin-dis.c
@@ -4664,7 +4664,7 @@ _print_insn_bfin (bfd_vma pc, disassemble_info *outf)
return -1;
priv->iw0 = iw0;
- if ((iw0 & 0xc000) == 0xc000)
+ if (((iw0 & 0xc000) == 0xc000) && ((iw0 & 0xff00) != 0xf800))
{
/* 32-bit insn. */
if (ifetch (pc + 2, outf, &iw1))
diff --git a/opcodes/dis-buf.c b/opcodes/dis-buf.c
index cc0e3ad2fba..7c5d9ad4b32 100644
--- a/opcodes/dis-buf.c
+++ b/opcodes/dis-buf.c
@@ -38,7 +38,9 @@ buffer_read_memory (bfd_vma memaddr,
if (memaddr < info->buffer_vma
|| memaddr - info->buffer_vma > max_addr_offset
- || memaddr - info->buffer_vma + end_addr_offset > max_addr_offset)
+ || memaddr - info->buffer_vma + end_addr_offset > max_addr_offset
+ || (info->stop_vma && (memaddr >= info->stop_vma
+ || memaddr + end_addr_offset > info->stop_vma)))
/* Out of bounds. Use EIO because GDB uses it. */
return EIO;
memcpy (myaddr, info->buffer + octets, length);
diff --git a/opcodes/mcore-dis.c b/opcodes/mcore-dis.c
index dc62099e7ae..536f79b4551 100644
--- a/opcodes/mcore-dis.c
+++ b/opcodes/mcore-dis.c
@@ -88,9 +88,8 @@ static const char *crname[] = {
static const unsigned isiz[] = { 2, 0, 1, 0 };
int
-print_insn_mcore (memaddr, info)
- bfd_vma memaddr;
- struct disassemble_info *info;
+print_insn_mcore (bfd_vma memaddr,
+ struct disassemble_info *info)
{
unsigned char ibytes[4];
fprintf_ftype print_func = info->fprintf_func;
@@ -233,6 +232,9 @@ print_insn_mcore (memaddr, info)
val = (memaddr + 2 + ((inst & 0xFF) << 2)) & 0xFFFFFFFC;
+ /* We are not reading an instruction, so allow
+ reads to extend beyond the next symbol. */
+ info->stop_vma = 0;
status = info->read_memory_func (val, ibytes, 4, info);
if (status != 0)
{
@@ -263,6 +265,9 @@ print_insn_mcore (memaddr, info)
val = (memaddr + 2 + ((inst & 0xFF) << 2)) & 0xFFFFFFFC;
+ /* We are not reading an instruction, so allow
+ reads to extend beyond the next symbol. */
+ info->stop_vma = 0;
status = info->read_memory_func (val, ibytes, 4, info);
if (status != 0)
{
diff --git a/opcodes/sh-dis.c b/opcodes/sh-dis.c
index 74de9f6e5da..a3f645db189 100644
--- a/opcodes/sh-dis.c
+++ b/opcodes/sh-dis.c
@@ -905,6 +905,8 @@ print_insn_sh (bfd_vma memaddr, struct disassemble_info *info)
size = 2;
else
size = 4;
+ /* Not reading an instruction - disable stop_vma. */
+ info->stop_vma = 0;
status = info->read_memory_func (disp_pc_addr, bytes, size, info);
if (status == 0)
{
diff --git a/opcodes/tic6x-dis.c b/opcodes/tic6x-dis.c
index e02734059e1..498ffe03569 100644
--- a/opcodes/tic6x-dis.c
+++ b/opcodes/tic6x-dis.c
@@ -249,6 +249,9 @@ print_insn_tic6x (bfd_vma addr, struct disassemble_info *info)
fp_offset = addr & 0x1f;
fp_addr = addr - fp_offset;
+ /* Read in a block of instructions. Since there might be a
+ symbol in the middle of this block, disable stop_vma. */
+ info->stop_vma = 0;
status = info->read_memory_func (fp_addr, fp, 32, info);
if (status)
{
diff --git a/opcodes/vax-dis.c b/opcodes/vax-dis.c
index a7a1ccbec8e..da4ba7cc454 100644
--- a/opcodes/vax-dis.c
+++ b/opcodes/vax-dis.c
@@ -402,7 +402,8 @@ print_insn_vax (bfd_vma memaddr, disassemble_info *info)
argp = NULL;
/* Check if the info buffer has more than one byte left since
the last opcode might be a single byte with no argument data. */
- if (info->buffer_length - (memaddr - info->buffer_vma) > 1)
+ if (info->buffer_length - (memaddr - info->buffer_vma) > 1
+ && (info->stop_vma == 0 || memaddr < (info->stop_vma - 1)))
{
FETCH_DATA (info, buffer + 2);
}