PATCH octets vs bytes for objdump

Ian Lance Taylor ian@zembu.com
Wed Jan 26 07:33:00 GMT 2000


   Date: Wed, 26 Jan 2000 07:28:57 -0500
   From: Timothy Wall <twall@tiac.net>

   *************** buffer_read_memory (memaddr, myaddr, len
   *** 29,39 ****
	  int length;
	  struct disassemble_info *info;
     {
       if (memaddr < info->buffer_vma
   !       || memaddr - info->buffer_vma + length > info->buffer_length)
	 /* Out of bounds.  Use EIO because GDB uses it.  */
	 return EIO;
   !   memcpy (myaddr, info->buffer + (memaddr - info->buffer_vma), length);
       return 0;
     }

   --- 29,45 ----
	  int length;
	  struct disassemble_info *info;
     {
   +   int opb = info->octets_per_byte;
   +   int end_addr_offset = length / opb;
   +   int max_addr_offset = info->buffer_length / opb; 
   +   int octets = (memaddr - info->buffer_vma) * opb;
   + 
       if (memaddr < info->buffer_vma
   !       || memaddr + end_addr_offset > info->buffer_vma + max_addr_offset)
	 /* Out of bounds.  Use EIO because GDB uses it.  */
	 return EIO;
   !   memcpy (myaddr, info->buffer + octets, length);
   ! 
       return 0;
     }

Note that the original version of the condition was careful to never
form an address which extended past the end of the buffer.  The new
condition does not preserve that property, because memaddr +
end_addr_offset might be past the end of the buffer.  ISO C does not
guarantee that you can form an address beyond the end of a buffer.  I
admit that this is just a quibble.

Ian


More information about the Binutils mailing list