Blame SOURCES/binutils-rh1060282.patch

d570a8
diff -Nrup a/binutils/doc/binutils.texi b/binutils/doc/binutils.texi
d570a8
--- a/binutils/doc/binutils.texi	2013-02-27 13:28:03.000000000 -0700
d570a8
+++ b/binutils/doc/binutils.texi	2015-06-23 09:44:23.938269022 -0600
d570a8
@@ -1957,6 +1957,15 @@ expected to contain instructions.
d570a8
 Like @option{-d}, but disassemble the contents of all sections, not just
d570a8
 those expected to contain instructions.
d570a8
 
d570a8
+This option also has a subtle effect on the disassembly of
d570a8
+instructions in code sections.  When option @option{-d} is in effect
d570a8
+objdump will assume that any symbols present in a code section occur
d570a8
+on the boundary between instructions and it will refuse to disassemble
d570a8
+across such a boundary.  When option @option{-D} is in effect however
d570a8
+this assumption is supressed.  This means that it is possible for the
d570a8
+output of @option{-d} and @option{-D} to differ if, for example, data
d570a8
+is stored in code sections.
d570a8
+
d570a8
 If the target is an ARM architecture this switch also has the effect
d570a8
 of forcing the disassembler to decode pieces of data found in code
d570a8
 sections as if they were instructions.
d570a8
diff -Nrup a/binutils/objdump.c b/binutils/objdump.c
d570a8
--- a/binutils/objdump.c	2015-06-23 07:38:21.000000000 -0600
d570a8
+++ b/binutils/objdump.c	2015-06-23 09:44:23.939269001 -0600
d570a8
@@ -1667,7 +1667,18 @@ disassemble_bytes (struct disassemble_in
d570a8
 		    }
d570a8
 		}
d570a8
 
d570a8
+	      if (! disassemble_all
d570a8
+		  && (section->flags & (SEC_CODE | SEC_HAS_CONTENTS))
d570a8
+		  == (SEC_CODE | SEC_HAS_CONTENTS))
d570a8
+		/* Set a stop_vma so that the disassembler will not read
d570a8
+		   beyond the next symbol.  We assume that symbols appear on
d570a8
+		   the boundaries between instructions.  We only do this when
d570a8
+		   disassembling code of course, and when -D is in effect.  */
d570a8
+		inf->stop_vma = section->vma + stop_offset;
d570a8
+	      
d570a8
 	      octets = (*disassemble_fn) (section->vma + addr_offset, inf);
d570a8
+
d570a8
+	      inf->stop_vma = 0;
d570a8
 	      inf->fprintf_func = (fprintf_ftype) fprintf;
d570a8
 	      inf->stream = stdout;
d570a8
 	      if (insn_width == 0 && inf->bytes_per_line != 0)
d570a8
@@ -1893,7 +1904,7 @@ disassemble_section (bfd *abfd, asection
d570a8
   arelent **                   rel_pp = NULL;
d570a8
   arelent **                   rel_ppstart = NULL;
d570a8
   arelent **                   rel_ppend;
d570a8
-  unsigned long                stop_offset;
d570a8
+  bfd_vma                      stop_offset;
d570a8
   asymbol *                    sym = NULL;
d570a8
   long                         place = 0;
d570a8
   long                         rel_count;
d570a8
@@ -2015,7 +2026,7 @@ disassemble_section (bfd *abfd, asection
d570a8
     {
d570a8
       bfd_vma addr;
d570a8
       asymbol *nextsym;
d570a8
-      unsigned long nextstop_offset;
d570a8
+      bfd_vma nextstop_offset;
d570a8
       bfd_boolean insns;
d570a8
 
d570a8
       addr = section->vma + addr_offset;
d570a8
@@ -2703,9 +2714,9 @@ dump_section (bfd *abfd, asection *secti
d570a8
 {
d570a8
   bfd_byte *data = 0;
d570a8
   bfd_size_type datasize;
d570a8
-  bfd_size_type addr_offset;
d570a8
-  bfd_size_type start_offset;
d570a8
-  bfd_size_type stop_offset;
d570a8
+  bfd_vma addr_offset;
d570a8
+  bfd_vma start_offset;
d570a8
+  bfd_vma stop_offset;
d570a8
   unsigned int opb = bfd_octets_per_byte (abfd);
d570a8
   /* Bytes per line.  */
d570a8
   const int onaline = 16;
d570a8
diff -Nrup a/gas/testsuite/gas/arm/backslash-at.d b/gas/testsuite/gas/arm/backslash-at.d
d570a8
--- a/gas/testsuite/gas/arm/backslash-at.d	2013-02-27 13:28:03.000000000 -0700
d570a8
+++ b/gas/testsuite/gas/arm/backslash-at.d	2015-06-23 09:51:10.167721356 -0600
d570a8
@@ -5,13 +5,13 @@
d570a8
 
d570a8
 Disassembly of section .text:
d570a8
 0+000 <.*>.*615c.*
d570a8
-0+002 <foo> e3a00000 	mov	r0, #0
d570a8
-0+006 <foo\+0x4> e3a00000 	mov	r0, #0
d570a8
-0+00a <foo\+0x8> e3a00000 	mov	r0, #0
d570a8
-0+00e <foo\+0xc> e3a00001 	mov	r0, #1
d570a8
-0+012 <foo\+0x10> e3a00001 	mov	r0, #1
d570a8
-0+016 <foo\+0x14> e3a00001 	mov	r0, #1
d570a8
-0+01a <foo\+0x18> e3a00002 	mov	r0, #2
d570a8
-0+01e <foo\+0x1c> e3a00002 	mov	r0, #2
d570a8
-0+022 <foo\+0x20> e3a00002 	mov	r0, #2
d570a8
+0+004 <foo> e3a00000 	mov	r0, #0
d570a8
+0+008 <foo\+0x4> e3a00000 	mov	r0, #0
d570a8
+0+00c <foo\+0x8> e3a00000 	mov	r0, #0
d570a8
+0+010 <foo\+0xc> e3a00001 	mov	r0, #1
d570a8
+0+014 <foo\+0x10> e3a00001 	mov	r0, #1
d570a8
+0+018 <foo\+0x14> e3a00001 	mov	r0, #1
d570a8
+0+01c <foo\+0x18> e3a00002 	mov	r0, #2
d570a8
+0+020 <foo\+0x1c> e3a00002 	mov	r0, #2
d570a8
+0+024 <foo\+0x20> e3a00002 	mov	r0, #2
d570a8
 #...
d570a8
Binary files a/gas/testsuite/gas/arm/.backslash-at.d.rej.swp and b/gas/testsuite/gas/arm/.backslash-at.d.rej.swp differ
d570a8
diff -Nrup a/gas/testsuite/gas/arm/backslash-at.s b/gas/testsuite/gas/arm/backslash-at.s
d570a8
--- a/gas/testsuite/gas/arm/backslash-at.s	2013-02-27 13:28:03.000000000 -0700
d570a8
+++ b/gas/testsuite/gas/arm/backslash-at.s	2015-06-23 09:44:23.939269001 -0600
d570a8
@@ -6,9 +6,10 @@
d570a8
 	mov	r0, #\@ @comment
d570a8
 .endm
d570a8
 
d570a8
-.byte	'\\
d570a8
-.byte	'\a
d570a8
-
d570a8
+	.byte	'\\
d570a8
+	.byte	'\a
d570a8
+	.byte 	0
d570a8
+	.byte	0
d570a8
 foo:
d570a8
 	bar
d570a8
 	bar
d570a8
diff -Nrup a/gas/testsuite/gas/i386/ilp32/x86-64-opcode-inval.d b/gas/testsuite/gas/i386/ilp32/x86-64-opcode-inval.d
d570a8
--- a/gas/testsuite/gas/i386/ilp32/x86-64-opcode-inval.d	2013-02-27 13:28:03.000000000 -0700
d570a8
+++ b/gas/testsuite/gas/i386/ilp32/x86-64-opcode-inval.d	2015-06-23 09:44:23.940268980 -0600
d570a8
@@ -12,26 +12,26 @@ Disassembly of section .text:
d570a8
 
d570a8
 0+1 <aad0>:
d570a8
 [ 	]*[a-f0-9]+:	d5                   	\(bad\)  
d570a8
-[ 	]*[a-f0-9]+:	0a d5                	or     %ch,%dl
d570a8
+[ 	]*[a-f0-9]+:	0a                   	.byte 0xa
d570a8
 
d570a8
 0+3 <aad1>:
d570a8
 [ 	]*[a-f0-9]+:	d5                   	\(bad\)  
d570a8
-[ 	]*[a-f0-9]+:	02 d4                	add    %ah,%dl
d570a8
+[ 	]*[a-f0-9]+:	02                   	.byte 0x2
d570a8
 
d570a8
 0+5 <aam0>:
d570a8
 [ 	]*[a-f0-9]+:	d4                   	\(bad\)  
d570a8
-[ 	]*[a-f0-9]+:	0a d4                	or     %ah,%dl
d570a8
+[ 	]*[a-f0-9]+:	0a                   	.byte 0xa
d570a8
 
d570a8
 0+7 <aam1>:
d570a8
 [ 	]*[a-f0-9]+:	d4                   	\(bad\)  
d570a8
-[ 	]*[a-f0-9]+:	02 3f                	add    \(%rdi\),%bh
d570a8
+[ 	]*[a-f0-9]+:	02                   	.byte 0x2
d570a8
 
d570a8
 0+9 <aas>:
d570a8
 [ 	]*[a-f0-9]+:	3f                   	\(bad\)  
d570a8
 
d570a8
 0+a <bound>:
d570a8
-[ 	]*[a-f0-9]+:	62                   	\(bad\)  
d570a8
-[ 	]*[a-f0-9]+:	10 27                	adc    %ah,\(%rdi\)
d570a8
+[ 	]*[a-f0-9]+:	62                   	.byte 0x62
d570a8
+[ 	]*[a-f0-9]+:	10                   	.byte 0x10
d570a8
 
d570a8
 0+c <daa>:
d570a8
 [ 	]*[a-f0-9]+:	27                   	\(bad\)  
d570a8
diff -Nrup a/gas/testsuite/gas/i386/ilp32/x86-64-opcode-inval-intel.d b/gas/testsuite/gas/i386/ilp32/x86-64-opcode-inval-intel.d
d570a8
--- a/gas/testsuite/gas/i386/ilp32/x86-64-opcode-inval-intel.d	2013-02-27 13:28:03.000000000 -0700
d570a8
+++ b/gas/testsuite/gas/i386/ilp32/x86-64-opcode-inval-intel.d	2015-06-23 09:44:23.939269001 -0600
d570a8
@@ -12,26 +12,26 @@ Disassembly of section .text:
d570a8
 
d570a8
 0+1 <aad0>:
d570a8
 [ 	]*[a-f0-9]+:	d5                   	\(bad\)  
d570a8
-[ 	]*[a-f0-9]+:	0a d5                	or     dl,ch
d570a8
+[ 	]*[a-f0-9]+:	0a                   	.byte 0xa
d570a8
 
d570a8
 0+3 <aad1>:
d570a8
 [ 	]*[a-f0-9]+:	d5                   	\(bad\)  
d570a8
-[ 	]*[a-f0-9]+:	02 d4                	add    dl,ah
d570a8
+[ 	]*[a-f0-9]+:	02                   	.byte 0x2
d570a8
 
d570a8
 0+5 <aam0>:
d570a8
 [ 	]*[a-f0-9]+:	d4                   	\(bad\)  
d570a8
-[ 	]*[a-f0-9]+:	0a d4                	or     dl,ah
d570a8
+[ 	]*[a-f0-9]+:	0a                   	.byte 0xa
d570a8
 
d570a8
 0+7 <aam1>:
d570a8
 [ 	]*[a-f0-9]+:	d4                   	\(bad\)  
d570a8
-[ 	]*[a-f0-9]+:	02 3f                	add    bh,BYTE PTR \[rdi\]
d570a8
+[ 	]*[a-f0-9]+:	02                   	.byte 0x2
d570a8
 
d570a8
 0+9 <aas>:
d570a8
 [ 	]*[a-f0-9]+:	3f                   	\(bad\)  
d570a8
 
d570a8
 0+a <bound>:
d570a8
-[ 	]*[a-f0-9]+:	62                   	\(bad\)  
d570a8
-[ 	]*[a-f0-9]+:	10 27                	adc    BYTE PTR \[rdi\],ah
d570a8
+[ 	]*[a-f0-9]+:	62                   	.byte 0x62
d570a8
+[ 	]*[a-f0-9]+:	10                   	.byte 0x10
d570a8
 
d570a8
 0+c <daa>:
d570a8
 [ 	]*[a-f0-9]+:	27                   	\(bad\)  
d570a8
diff -Nrup a/gas/testsuite/gas/i386/x86-64-opcode-inval.d b/gas/testsuite/gas/i386/x86-64-opcode-inval.d
d570a8
--- a/gas/testsuite/gas/i386/x86-64-opcode-inval.d	2013-02-27 13:28:03.000000000 -0700
d570a8
+++ b/gas/testsuite/gas/i386/x86-64-opcode-inval.d	2015-06-23 09:44:23.940268980 -0600
d570a8
@@ -11,26 +11,26 @@ Disassembly of section .text:
d570a8
 
d570a8
 0+1 <aad0>:
d570a8
 [ 	]*[a-f0-9]+:	d5                   	\(bad\)  
d570a8
-[ 	]*[a-f0-9]+:	0a d5                	or     %ch,%dl
d570a8
+[ 	]*[a-f0-9]+:	0a                   	.byte 0xa
d570a8
 
d570a8
 0+3 <aad1>:
d570a8
 [ 	]*[a-f0-9]+:	d5                   	\(bad\)  
d570a8
-[ 	]*[a-f0-9]+:	02 d4                	add    %ah,%dl
d570a8
+[ 	]*[a-f0-9]+:	02                   	.byte 0x2
d570a8
 
d570a8
 0+5 <aam0>:
d570a8
 [ 	]*[a-f0-9]+:	d4                   	\(bad\)  
d570a8
-[ 	]*[a-f0-9]+:	0a d4                	or     %ah,%dl
d570a8
+[ 	]*[a-f0-9]+:	0a                   	.byte 0xa
d570a8
 
d570a8
 0+7 <aam1>:
d570a8
 [ 	]*[a-f0-9]+:	d4                   	\(bad\)  
d570a8
-[ 	]*[a-f0-9]+:	02 3f                	add    \(%rdi\),%bh
d570a8
+[ 	]*[a-f0-9]+:	02                   	.byte 0x2
d570a8
 
d570a8
 0+9 <aas>:
d570a8
 [ 	]*[a-f0-9]+:	3f                   	\(bad\)  
d570a8
 
d570a8
 0+a <bound>:
d570a8
-[ 	]*[a-f0-9]+:	62                   	\(bad\)  
d570a8
-[ 	]*[a-f0-9]+:	10 27                	adc    %ah,\(%rdi\)
d570a8
+[ 	]*[a-f0-9]+:	62                   	.byte 0x62
d570a8
+[ 	]*[a-f0-9]+:	10                   	.byte 0x10
d570a8
 
d570a8
 0+c <daa>:
d570a8
 [ 	]*[a-f0-9]+:	27                   	\(bad\)  
d570a8
diff -Nrup a/gas/testsuite/gas/i386/x86-64-opcode-inval-intel.d b/gas/testsuite/gas/i386/x86-64-opcode-inval-intel.d
d570a8
--- a/gas/testsuite/gas/i386/x86-64-opcode-inval-intel.d	2013-02-27 13:28:03.000000000 -0700
d570a8
+++ b/gas/testsuite/gas/i386/x86-64-opcode-inval-intel.d	2015-06-23 09:44:23.940268980 -0600
d570a8
@@ -12,26 +12,26 @@ Disassembly of section .text:
d570a8
 
d570a8
 0+1 <aad0>:
d570a8
 [ 	]*[a-f0-9]+:	d5                   	\(bad\)  
d570a8
-[ 	]*[a-f0-9]+:	0a d5                	or     dl,ch
d570a8
+[ 	]*[a-f0-9]+:	0a                   	.byte 0xa
d570a8
 
d570a8
 0+3 <aad1>:
d570a8
 [ 	]*[a-f0-9]+:	d5                   	\(bad\)  
d570a8
-[ 	]*[a-f0-9]+:	02 d4                	add    dl,ah
d570a8
+[ 	]*[a-f0-9]+:	02                   	.byte 0x2
d570a8
 
d570a8
 0+5 <aam0>:
d570a8
 [ 	]*[a-f0-9]+:	d4                   	\(bad\)  
d570a8
-[ 	]*[a-f0-9]+:	0a d4                	or     dl,ah
d570a8
+[ 	]*[a-f0-9]+:	0a                   	.byte 0xa
d570a8
 
d570a8
 0+7 <aam1>:
d570a8
 [ 	]*[a-f0-9]+:	d4                   	\(bad\)  
d570a8
-[ 	]*[a-f0-9]+:	02 3f                	add    bh,BYTE PTR \[rdi\]
d570a8
+[ 	]*[a-f0-9]+:	02                   	.byte 0x2
d570a8
 
d570a8
 0+9 <aas>:
d570a8
 [ 	]*[a-f0-9]+:	3f                   	\(bad\)  
d570a8
 
d570a8
 0+a <bound>:
d570a8
-[ 	]*[a-f0-9]+:	62                   	\(bad\)  
d570a8
-[ 	]*[a-f0-9]+:	10 27                	adc    BYTE PTR \[rdi\],ah
d570a8
+[ 	]*[a-f0-9]+:	62                   	.byte 0x62
d570a8
+[ 	]*[a-f0-9]+:	10                   	.byte 0x10
d570a8
 
d570a8
 0+c <daa>:
d570a8
 [ 	]*[a-f0-9]+:	27                   	\(bad\)  
d570a8
diff -Nrup a/include/dis-asm.h b/include/dis-asm.h
d570a8
--- a/include/dis-asm.h	2013-02-27 13:28:03.000000000 -0700
d570a8
+++ b/include/dis-asm.h	2015-06-23 09:44:23.940268980 -0600
d570a8
@@ -213,6 +213,14 @@ typedef struct disassemble_info
d570a8
   /* Command line options specific to the target disassembler.  */
d570a8
   char * disassembler_options;
d570a8
 
d570a8
+  /* If non-zero then try not disassemble beyond this address, even if
d570a8
+     there are values left in the buffer.  This address is the address
d570a8
+     of the nearest symbol forwards from the start of the disassembly,
d570a8
+     and it is assumed that it lies on the boundary between instructions.
d570a8
+     If an instruction spans this address then this is an error in the
d570a8
+     file being disassembled.  */
d570a8
+  bfd_vma stop_vma;
d570a8
+
d570a8
 } disassemble_info;
d570a8
 
d570a8
 
d570a8
diff -Nrup a/opcodes/dis-buf.c b/opcodes/dis-buf.c
d570a8
--- a/opcodes/dis-buf.c	2013-02-27 13:28:03.000000000 -0700
d570a8
+++ b/opcodes/dis-buf.c	2015-06-23 09:44:23.941268959 -0600
d570a8
@@ -39,7 +39,9 @@ buffer_read_memory (bfd_vma memaddr,
d570a8
 
d570a8
   if (memaddr < info->buffer_vma
d570a8
       || memaddr - info->buffer_vma > max_addr_offset
d570a8
-      || memaddr - info->buffer_vma + end_addr_offset > max_addr_offset)
d570a8
+      || memaddr - info->buffer_vma + end_addr_offset > max_addr_offset
d570a8
+      || (info->stop_vma && (memaddr >= info->stop_vma
d570a8
+			     || memaddr + end_addr_offset > info->stop_vma)))
d570a8
     /* Out of bounds.  Use EIO because GDB uses it.  */
d570a8
     return EIO;
d570a8
   memcpy (myaddr, info->buffer + octets, length);
d570a8
diff -Nrup a/opcodes/mcore-dis.c b/opcodes/mcore-dis.c
d570a8
--- a/opcodes/mcore-dis.c	2013-02-27 13:28:03.000000000 -0700
d570a8
+++ b/opcodes/mcore-dis.c	2015-06-23 09:44:23.941268959 -0600
d570a8
@@ -89,9 +89,8 @@ static const char *crname[] = {
d570a8
 static const unsigned isiz[] = { 2, 0, 1, 0 };
d570a8
 
d570a8
 int
d570a8
-print_insn_mcore (memaddr, info)
d570a8
-     bfd_vma memaddr;
d570a8
-     struct disassemble_info *info;
d570a8
+print_insn_mcore (bfd_vma memaddr,
d570a8
+		  struct disassemble_info *info)
d570a8
 {
d570a8
   unsigned char ibytes[4];
d570a8
   fprintf_ftype print_func = info->fprintf_func;
d570a8
@@ -234,6 +233,9 @@ print_insn_mcore (memaddr, info)
d570a8
 
d570a8
 	    val = (memaddr + 2 + ((inst & 0xFF) << 2)) & 0xFFFFFFFC;
d570a8
 
d570a8
+	    /* We are not reading an instruction, so allow
d570a8
+	       reads to extend beyond the next symbol.  */
d570a8
+	    info->stop_vma = 0;
d570a8
 	    status = info->read_memory_func (val, ibytes, 4, info);
d570a8
 	    if (status != 0)
d570a8
 	      {
d570a8
@@ -264,6 +266,9 @@ print_insn_mcore (memaddr, info)
d570a8
 
d570a8
 	    val = (memaddr + 2 + ((inst & 0xFF) << 2)) & 0xFFFFFFFC;
d570a8
 
d570a8
+	    /* We are not reading an instruction, so allow
d570a8
+	       reads to extend beyond the next symbol.  */
d570a8
+	    info->stop_vma = 0;
d570a8
 	    status = info->read_memory_func (val, ibytes, 4, info);
d570a8
 	    if (status != 0)
d570a8
 	      {
d570a8
diff -Nrup a/opcodes/sh-dis.c b/opcodes/sh-dis.c
d570a8
--- a/opcodes/sh-dis.c	2013-02-27 13:28:03.000000000 -0700
d570a8
+++ b/opcodes/sh-dis.c	2015-06-23 09:44:23.941268959 -0600
d570a8
@@ -906,6 +906,8 @@ print_insn_sh (bfd_vma memaddr, struct d
d570a8
 	    size = 2;
d570a8
 	  else
d570a8
 	    size = 4;
d570a8
+	  /* Not reading an instruction - disable stop_vma.  */
d570a8
+	  info->stop_vma = 0;
d570a8
 	  status = info->read_memory_func (disp_pc_addr, bytes, size, info);
d570a8
 	  if (status == 0)
d570a8
 	    {
d570a8
diff -Nrup a/opcodes/tic6x-dis.c b/opcodes/tic6x-dis.c
d570a8
--- a/opcodes/tic6x-dis.c	2013-02-27 13:28:03.000000000 -0700
d570a8
+++ b/opcodes/tic6x-dis.c	2015-06-23 09:44:23.941268959 -0600
d570a8
@@ -178,6 +178,9 @@ print_insn_tic6x (bfd_vma addr, struct d
d570a8
 
d570a8
   fp_offset = addr & 0x1f;
d570a8
   fp_addr = addr - fp_offset;
d570a8
+  /* Read in a block of instructions.  Since there might be a
d570a8
+     symbol in the middle of this block, disable stop_vma.  */
d570a8
+  info->stop_vma = 0;
d570a8
   status = info->read_memory_func (fp_addr, fp, 32, info);
d570a8
   if (status)
d570a8
     {
d570a8
diff -Nrup a/opcodes/vax-dis.c b/opcodes/vax-dis.c
d570a8
--- a/opcodes/vax-dis.c	2013-02-27 13:28:03.000000000 -0700
d570a8
+++ b/opcodes/vax-dis.c	2015-06-23 09:44:23.941268959 -0600
d570a8
@@ -403,7 +403,8 @@ print_insn_vax (bfd_vma memaddr, disasse
d570a8
   argp = NULL;
d570a8
   /* Check if the info buffer has more than one byte left since
d570a8
      the last opcode might be a single byte with no argument data.  */
d570a8
-  if (info->buffer_length - (memaddr - info->buffer_vma) > 1)
d570a8
+  if (info->buffer_length - (memaddr - info->buffer_vma) > 1
d570a8
+      && (info->stop_vma == 0 || memaddr < (info->stop_vma - 1)))
d570a8
     {
d570a8
       FETCH_DATA (info, buffer + 2);
d570a8
     }