aboutsummaryrefslogtreecommitdiff
path: root/binutils
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 /binutils
parent07fcd30112bb071e8dda0a2229a860f2874a7816 (diff)
downloadgdb-bdc4de1b24353c4213e404029252ec75065499de.zip
gdb-bdc4de1b24353c4213e404029252ec75065499de.tar.gz
gdb-bdc4de1b24353c4213e404029252ec75065499de.tar.bz2
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 'binutils')
-rw-r--r--binutils/ChangeLog8
-rw-r--r--binutils/doc/binutils.texi9
-rw-r--r--binutils/objdump.c25
3 files changed, 35 insertions, 7 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 63fefc8..c44146d 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,11 @@
+2015-06-22 Nick Clifton <nickc@redhat.com>
+
+ * 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.
+
2015-06-05 Nick Clifton <nickc@redhat.com>
* dwarf.c (read_debug_line_header): Use reloc_at to detect
diff --git a/binutils/doc/binutils.texi b/binutils/doc/binutils.texi
index 75852e6..0781036 100644
--- a/binutils/doc/binutils.texi
+++ b/binutils/doc/binutils.texi
@@ -2041,6 +2041,15 @@ expected to contain instructions.
Like @option{-d}, but disassemble the contents of all sections, not just
those expected to contain instructions.
+This option also has a subtle effect on the disassembly of
+instructions in code sections. When option @option{-d} is in effect
+objdump will assume that any symbols present in a code section occur
+on the boundary between instructions and it will refuse to disassemble
+across such a boundary. When option @option{-D} is in effect however
+this assumption is supressed. This means that it is possible for the
+output of @option{-d} and @option{-D} to differ if, for example, data
+is stored in code sections.
+
If the target is an ARM architecture this switch also has the effect
of forcing the disassembler to decode pieces of data found in code
sections as if they were instructions.
diff --git a/binutils/objdump.c b/binutils/objdump.c
index f51b6f5..c4387c4 100644
--- a/binutils/objdump.c
+++ b/binutils/objdump.c
@@ -1685,7 +1685,18 @@ disassemble_bytes (struct disassemble_info * inf,
}
}
+ if (! disassemble_all
+ && (section->flags & (SEC_CODE | SEC_HAS_CONTENTS))
+ == (SEC_CODE | SEC_HAS_CONTENTS))
+ /* Set a stop_vma so that the disassembler will not read
+ beyond the next symbol. We assume that symbols appear on
+ the boundaries between instructions. We only do this when
+ disassembling code of course, and when -D is in effect. */
+ inf->stop_vma = section->vma + stop_offset;
+
octets = (*disassemble_fn) (section->vma + addr_offset, inf);
+
+ inf->stop_vma = 0;
inf->fprintf_func = (fprintf_ftype) fprintf;
inf->stream = stdout;
if (insn_width == 0 && inf->bytes_per_line != 0)
@@ -1911,7 +1922,7 @@ disassemble_section (bfd *abfd, asection *section, void *inf)
arelent ** rel_pp = NULL;
arelent ** rel_ppstart = NULL;
arelent ** rel_ppend;
- unsigned long stop_offset;
+ bfd_vma stop_offset;
asymbol * sym = NULL;
long place = 0;
long rel_count;
@@ -2035,7 +2046,7 @@ disassemble_section (bfd *abfd, asection *section, void *inf)
{
bfd_vma addr;
asymbol *nextsym;
- unsigned long nextstop_offset;
+ bfd_vma nextstop_offset;
bfd_boolean insns;
addr = section->vma + addr_offset;
@@ -2330,7 +2341,7 @@ load_specific_debug_section (enum dwarf_section_display_enum debug,
section->num_relocs = reloc_count;
}
}
- }
+ }
return 1;
}
@@ -2794,9 +2805,9 @@ dump_section (bfd *abfd, asection *section, void *dummy ATTRIBUTE_UNUSED)
{
bfd_byte *data = 0;
bfd_size_type datasize;
- bfd_size_type addr_offset;
- bfd_size_type start_offset;
- bfd_size_type stop_offset;
+ bfd_vma addr_offset;
+ bfd_vma start_offset;
+ bfd_vma stop_offset;
unsigned int opb = bfd_octets_per_byte (abfd);
/* Bytes per line. */
const int onaline = 16;
@@ -3451,7 +3462,7 @@ display_any_bfd (bfd *file, int level)
{
bfd *arfile = NULL;
bfd *last_arfile = NULL;
-
+
if (level == 0)
printf (_("In archive %s:\n"), bfd_get_filename (file));
else if (level > 100)