From 1316c8b37f7e034b92e26695eea207e9a4cf25a0 Mon Sep 17 00:00:00 2001
From: Nick Clifton <nickc@redhat.com>
Date: Mon, 15 Jun 2009 11:37:26 +0000
Subject: [PATCH]         PR 10263         * arm-dis.c (print_insn): Ignore
 is_data if the user has requested         the disassembly of data as well as
 instructions.

        * objdump.c (disassemble_bytes): Set the DISASSEMBLE_DATA bit in
        the flags field of the disassemble_info structure if the -D switch
        is in operation.

        * dis-asm.h (struct disassemble_info): New value for the flags
        field.
---
 binutils/ChangeLog |  7 +++++++
 binutils/objdump.c |  4 ++--
 include/ChangeLog  |  5 +++++
 include/dis-asm.h  | 26 ++++++++++++++++----------
 opcodes/ChangeLog  |  6 ++++++
 opcodes/arm-dis.c  |  9 +++++----
 6 files changed, 41 insertions(+), 16 deletions(-)

diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index cc1e87d400f..e008e955ef7 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,10 @@
+2009-06-15  Nick Clifton  <nickc@redhat.com>
+
+	PR 10263
+	* objdump.c (disassemble_bytes): Set the DISASSEMBLE_DATA bit in
+	the flags field of the disassemble_info structure if the -D switch
+	is in operation.
+
 2009-06-12  Homer Xing  <homer.xing@yahoo.com>
 
 	* NEWS: Mention new feature added to gprof.
diff --git a/binutils/objdump.c b/binutils/objdump.c
index 265a8ead44f..3cf03f7eddb 100644
--- a/binutils/objdump.c
+++ b/binutils/objdump.c
@@ -1525,7 +1525,7 @@ disassemble_bytes (struct disassemble_info * info,
 	      info->stream = &sfile;
 	      info->bytes_per_line = 0;
 	      info->bytes_per_chunk = 0;
-	      info->flags = 0;
+	      info->flags = disassemble_all ? DISASSEMBLE_DATA : 0;
 
 	      if (info->disassembler_needs_relocs
 		  && (bfd_get_file_flags (aux->abfd) & EXEC_P) == 0
@@ -1554,7 +1554,7 @@ disassemble_bytes (struct disassemble_info * info,
 		      || (distance_to_rel > 0
 			  && distance_to_rel < (bfd_signed_vma) (previous_octets/ opb)))
 		    {
-		      info->flags = INSN_HAS_RELOC;
+		      info->flags |= INSN_HAS_RELOC;
 		      aux->reloc = **relppp;
 		    }
 		  else
diff --git a/include/ChangeLog b/include/ChangeLog
index 1af04e80bc7..82b10459186 100644
--- a/include/ChangeLog
+++ b/include/ChangeLog
@@ -1,3 +1,8 @@
+2009-06-15  Nick Clifton  <nickc@redhat.com>
+
+	* dis-asm.h (struct disassemble_info): New value for the flags
+	field.
+
 2009-06-02  Ian Lance Taylor  <iant@google.com>
 
 	* ansidecl.h (EXPORTED_CONST): Define.
diff --git a/include/dis-asm.h b/include/dis-asm.h
index 95d141ffa23..3872f8b2d42 100644
--- a/include/dis-asm.h
+++ b/include/dis-asm.h
@@ -1,6 +1,6 @@
 /* Interface between the opcode library and its callers.
 
-   Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+   Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009
    Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
@@ -39,14 +39,14 @@ extern "C" {
 
 enum dis_insn_type
 {
-  dis_noninsn,			/* Not a valid instruction */
-  dis_nonbranch,		/* Not a branch instruction */
-  dis_branch,			/* Unconditional branch */
-  dis_condbranch,		/* Conditional branch */
-  dis_jsr,			/* Jump to subroutine */
-  dis_condjsr,			/* Conditional jump to subroutine */
-  dis_dref,			/* Data reference instruction */
-  dis_dref2			/* Two data references in instruction */
+  dis_noninsn,			/* Not a valid instruction.  */
+  dis_nonbranch,		/* Not a branch instruction.  */
+  dis_branch,			/* Unconditional branch.  */
+  dis_condbranch,		/* Conditional branch.  */
+  dis_jsr,			/* Jump to subroutine.  */
+  dis_condjsr,			/* Conditional jump to subroutine.  */
+  dis_dref,			/* Data reference instruction.  */
+  dis_dref2			/* Two data references in instruction.  */
 };
 
 /* This struct is passed into the instruction decoding routine,
@@ -108,7 +108,13 @@ typedef struct disassemble_info
      The top 16 bits are reserved for public use (and are documented here).
      The bottom 16 bits are for the internal use of the disassembler.  */
   unsigned long flags;
-#define INSN_HAS_RELOC	0x80000000
+  /* Set if the disassembler has determined that there are one or more
+     relocations associated with the instruction being disassembled.  */
+#define INSN_HAS_RELOC	 (1 << 31)
+  /* Set if the user has requested the disassembly of data as well as code.  */
+#define DISASSEMBLE_DATA (1 << 30)
+
+  /* Use internally by the target specific disassembly code.  */
   void *private_data;
 
   /* Function used to get bytes to disassemble.  MEMADDR is the
diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog
index d70992a52c3..93d5d0205da 100644
--- a/opcodes/ChangeLog
+++ b/opcodes/ChangeLog
@@ -1,3 +1,9 @@
+2009-06-15  Nick Clifton  <nickc@redhat.com>
+
+	PR 10263
+	* arm-dis.c (print_insn): Ignore is_data if the user has requested
+	the disassembly of data as well as instructions.
+
 2009-06-11  Doug Evans  <dje@sebabeach.org>
 
 	* cgen.sh: Handle multiple simultaneous runs for parallel makes.
diff --git a/opcodes/arm-dis.c b/opcodes/arm-dis.c
index 884b5aec185..cb3bc998515 100644
--- a/opcodes/arm-dis.c
+++ b/opcodes/arm-dis.c
@@ -1,6 +1,6 @@
 /* Instruction printing code for the ARM
-   Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
-   2007, Free Software Foundation, Inc.
+   Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
+   2004, 2007, 2009  Free Software Foundation, Inc.
    Contributed by Richard Earnshaw (rwe@pegasus.esprit.ec.org)
    Modification by James G. Smith (jsmith@cygnus.co.uk)
 
@@ -4120,11 +4120,12 @@ print_insn (bfd_vma pc, struct disassemble_info *info, bfd_boolean little)
 
   info->bytes_per_line = 4;
 
-  if (is_data)
+  /* PR 10263: Disassemble data if requested to do so by the user.  */
+  if (is_data && ((info->flags & DISASSEMBLE_DATA) == 0))
     {
       int i;
 
-      /* size was already set above.  */
+      /* Size was already set above.  */
       info->bytes_per_chunk = size;
       printer = print_insn_data;
 
-- 
GitLab